Skip to content

Commit 5404e56

Browse files
alfredhrichaas
authored andcommitted
udp: added udp_helper_find() (creytiv#28)
1 parent bf20728 commit 5404e56

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

include/re_udp.h

+1
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ int udp_register_helper(struct udp_helper **uhp, struct udp_sock *us,
5656
void *arg);
5757
int udp_send_helper(struct udp_sock *us, const struct sa *dst,
5858
struct mbuf *mb, struct udp_helper *uh);
59+
struct udp_helper *udp_helper_find(const struct udp_sock *us, int layer);

src/udp/udp.c

+27
Original file line numberDiff line numberDiff line change
@@ -808,3 +808,30 @@ int udp_send_helper(struct udp_sock *us, const struct sa *dst,
808808

809809
return udp_send_internal(us, dst, mb, uh->le.prev);
810810
}
811+
812+
813+
/**
814+
* Find a UDP-helper on a UDP socket
815+
*
816+
* @param us UDP socket
817+
* @param layer Layer number
818+
*
819+
* @return UDP-helper if found, NULL if not found
820+
*/
821+
struct udp_helper *udp_helper_find(const struct udp_sock *us, int layer)
822+
{
823+
struct le *le;
824+
825+
if (!us)
826+
return NULL;
827+
828+
for (le = us->helpers.head; le; le = le->next) {
829+
830+
struct udp_helper *uh = le->data;
831+
832+
if (layer == uh->layer)
833+
return uh;
834+
}
835+
836+
return NULL;
837+
}

0 commit comments

Comments
 (0)