2 * radsniff.h Structures and defines for the RADIUS sniffer.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * Copyright 2006 The FreeRADIUS server project
21 * Copyright 2006 Nicolas Baradakis <nicolas.baradakis@cegetel.net>
24 #include <freeradius-devel/ident.h>
25 RCSIDH(radsniff_h, "$Id$")
27 #include <sys/types.h>
28 #include <netinet/in.h>
31 * The number of bytes in an ethernet (MAC) address.
33 #define ETHER_ADDR_LEN 6
36 * Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
38 struct ethernet_header {
39 uint8_t ethernet_dhost[ETHER_ADDR_LEN];
40 uint8_t ethernet_shost[ETHER_ADDR_LEN];
41 uint16_t ethernet_type;
45 * Length of a DEC/Intel/Xerox or 802.3 Ethernet header.
46 * Note that some compilers may pad "struct ether_header" to
47 * a multiple of 4 *bytes, for example, so "sizeof (struct
48 * ether_header)" may not give the right answer.
50 #define ETHER_HDRLEN 14
53 * Structure of an internet header, naked of options.
56 uint8_t ip_vhl; /* header length, version */
57 #define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
58 #define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
59 uint8_t ip_tos; /* type of service */
60 uint16_t ip_len; /* total length */
61 uint16_t ip_id; /* identification */
62 uint16_t ip_off; /* fragment offset field */
63 #define I_DF 0x4000 /* dont fragment flag */
64 #define IP_MF 0x2000 /* more fragments flag */
65 #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
66 uint8_t ip_ttl; /* time to live */
67 uint8_t ip_p; /* protocol */
68 uint16_t ip_sum; /* checksum */
69 struct in_addr ip_src,ip_dst; /* source and dest address */
73 * UDP protocol header.
74 * Per RFC 768, September, 1981.
77 uint16_t udp_sport; /* source port */
78 uint16_t udp_dport; /* destination port */
79 uint16_t udp_ulen; /* udp length */
80 uint16_t udp_sum; /* udp checksum */
84 * RADIUS packet length.
85 * RFC 2865, Section 3., subsection 'length' says:
86 * " ... and maximum length is 4096."
88 #define MAX_RADIUS_LEN 4096
89 #define MIN_RADIUS_LEN 20
90 #define SNAPLEN (sizeof(struct ethernet_header) + sizeof(struct ip_header) + sizeof(struct udp_header) + MAX_RADIUS_LEN)
92 typedef struct radius_packet_t {
96 uint8_t vector[AUTH_VECTOR_LEN];
100 #define AUTH_HDR_LEN 20