Skip to content

Commit

Permalink
udp: add udp_recv_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh authored and sreimers committed Jul 3, 2021
1 parent 4915d6f commit fb0b004
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/re_udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ 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);
void udp_recv_helper(struct udp_sock *us, const struct sa *src,
struct mbuf *mb, struct udp_helper *uh);
struct udp_helper *udp_helper_find(const struct udp_sock *us, int layer);
30 changes: 30 additions & 0 deletions src/udp/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,36 @@ int udp_send_helper(struct udp_sock *us, const struct sa *dst,
}


void udp_recv_helper(struct udp_sock *us, const struct sa *src,
struct mbuf *mb, struct udp_helper *uhx)
{
struct sa hsrc;
struct le *le;

if (!us || !src || !mb || !uhx)
return;

le = uhx->le.next;
while (le) {
struct udp_helper *uh = le->data;
bool hdld;

le = le->next;

if (src != &hsrc) {
sa_cpy(&hsrc, src);
src = &hsrc;
}

hdld = uh->recvh(&hsrc, mb, uh->arg);
if (hdld)
return;
}

us->rh(src, mb, us->arg);
}


/**
* Find a UDP-helper on a UDP socket
*
Expand Down

0 comments on commit fb0b004

Please sign in to comment.