File: udp.h

package info (click to toggle)
libdumbnet 1.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,768 kB
  • sloc: ansic: 11,563; sh: 4,203; python: 261; makefile: 92
file content (32 lines) | stat: -rw-r--r-- 680 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * udp.h
 *
 * User Datagram Protocol (RFC 768).
 *
 * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
 *
 * $Id$
 */

#ifndef DNET_UDP_H
#define DNET_UDP_H

#define UDP_HDR_LEN	8

struct udp_hdr {
	uint16_t	uh_sport;	/* source port */
	uint16_t	uh_dport;	/* destination port */
	uint16_t	uh_ulen;	/* udp length (including header) */
	uint16_t	uh_sum;		/* udp checksum */
};

#define UDP_PORT_MAX	65535

#define udp_pack_hdr(hdr, sport, dport, ulen) do {		\
	struct udp_hdr *udp_pack_p = (struct udp_hdr *)(hdr);	\
	udp_pack_p->uh_sport = htons(sport);			\
	udp_pack_p->uh_dport = htons(dport);			\
	udp_pack_p->uh_ulen = htons(ulen);			\
} while (0)

#endif /* DNET_UDP_H */