udp: added udp_helper_find() (#28)
This commit is contained in:
parent
bf20728f04
commit
5404e5630f
2 changed files with 28 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue