summaryrefslogtreecommitdiff
path: root/net/udp.c
blob: 69132569b0afcbbcf1fcf3ab0d62c5bc26258fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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);
}