From ae33cc6557790a502a01b380b0926944ca2f3cfa Mon Sep 17 00:00:00 2001 From: Miguel Date: Wed, 26 Sep 2018 10:22:37 +0200 Subject: ntp and udp --- net/udp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 net/udp.c (limited to 'net/udp.c') diff --git a/net/udp.c b/net/udp.c new file mode 100644 index 0000000..6913256 --- /dev/null +++ b/net/udp.c @@ -0,0 +1,16 @@ +#include "udp.h" +#include "inet.h" +#include "ipv4.h" + +uint32_t udp_generic(struct netdev *dev, uint32_t ip, uint16_t src, uint16_t dst, uint8_t* pos,uint8_t *end) +{ + pos-=8; //we need 64 bytes + struct udp_v4 *udp=pos; + + udp->src_port=htons(src); + udp->dst_port=htons(dst); + udp->len=htons(end-pos); + udp->csum=0; // TODO: optional + + return ipv4_generic(dev,ip,IPV4_P_UDP,pos,end); +} -- cgit v1.2.3