Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

udp: add udp_recv_helper #122

Merged
merged 1 commit into from
Jul 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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