1/*
2 * udp.h
3 *
4 * User Datagram Protocol (RFC 768).
5 *
6 * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
7 *
8 * $Id: udp.h,v 1.8 2002/04/02 05:05:39 dugsong Exp $
9 */
10
11#ifndef DNET_UDP_H
12#define DNET_UDP_H
13
14#define UDP_HDR_LEN	8
15
16struct udp_hdr {
17        uint16_t	uh_sport;	/* source port */
18        uint16_t	uh_dport;	/* destination port */
19        uint16_t	uh_ulen;	/* udp length (including header) */
20        uint16_t	uh_sum;		/* udp checksum */
21};
22
23#define UDP_PORT_MAX	65535
24
25#define udp_pack_hdr(hdr, sport, dport, ulen) do {		\
26        struct udp_hdr *udp_pack_p = (struct udp_hdr *)(hdr);	\
27        udp_pack_p->uh_sport = htons(sport);			\
28        udp_pack_p->uh_dport = htons(dport);			\
29        udp_pack_p->uh_ulen = htons(ulen);			\
30} while (0)
31
32#endif /* DNET_UDP_H */
33