udp: added udp_helper_find() (#28)

This commit is contained in:
Alfred E. Heggestad 2016-11-08 18:48:52 +01:00 committed by Richard Aas
parent bf20728f04
commit 5404e5630f
2 changed files with 28 additions and 0 deletions

View file

@ -56,3 +56,4 @@ int udp_register_helper(struct udp_helper **uhp, struct udp_sock *us,
void *arg);
int udp_send_helper(struct udp_sock *us, const struct sa *dst,
struct mbuf *mb, struct udp_helper *uh);
struct udp_helper *udp_helper_find(const struct udp_sock *us, int layer);

View file

@ -808,3 +808,30 @@ int udp_send_helper(struct udp_sock *us, const struct sa *dst,
return udp_send_internal(us, dst, mb, uh->le.prev);
}
/**
* Find a UDP-helper on a UDP socket
*
* @param us UDP socket
* @param layer Layer number
*
* @return UDP-helper if found, NULL if not found
*/
struct udp_helper *udp_helper_find(const struct udp_sock *us, int layer)
{
struct le *le;
if (!us)
return NULL;
for (le = us->helpers.head; le; le = le->next) {
struct udp_helper *uh = le->data;
if (layer == uh->layer)
return uh;
}
return NULL;
}