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 <sys/types.h>
25 #include <netinet/in.h>
28 * The number of bytes in an ethernet (MAC) address.
30 #define ETHER_ADDR_LEN 6
33 * Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
35 struct ethernet_header {
36 u_int8_t ethernet_dhost[ETHER_ADDR_LEN];
37 u_int8_t ethernet_shost[ETHER_ADDR_LEN];
38 u_int16_t ethernet_type;
42 * Length of a DEC/Intel/Xerox or 802.3 Ethernet header.
43 * Note that some compilers may pad "struct ether_header" to
44 * a multiple of 4 *bytes, for example, so "sizeof (struct
45 * ether_header)" may not give the right answer.
47 #define ETHER_HDRLEN 14
50 * Structure of an internet header, naked of options.
53 u_int8_t ip_vhl; /* header length, version */
54 #define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
55 #define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
56 u_int8_t ip_tos; /* type of service */
57 u_int16_t ip_len; /* total length */
58 u_int16_t ip_id; /* identification */
59 u_int16_t ip_off; /* fragment offset field */
60 #define IP_DF 0x4000 /* dont fragment flag */
61 #define IP_MF 0x2000 /* more fragments flag */
62 #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
63 u_int8_t ip_ttl; /* time to live */
64 u_int8_t ip_p; /* protocol */
65 u_int16_t ip_sum; /* checksum */
66 struct in_addr ip_src,ip_dst; /* source and dest address */
70 * UDP protocol header.
71 * Per RFC 768, September, 1981.
74 u_int16_t udp_sport; /* source port */
75 u_int16_t udp_dport; /* destination port */
76 u_int16_t udp_ulen; /* udp length */
77 u_int16_t udp_sum; /* udp checksum */
81 * RADIUS packet length.
82 * RFC 2865, Section 3., subsection 'length' says:
83 * " ... and maximum length is 4096."
85 #define MAX_RADIUS_LEN 4096
86 #define MIN_RADIUS_LEN 20
87 #define SNAPLEN (sizeof(struct ethernet_header) + sizeof(struct ip_header) + sizeof(struct udp_header) + MAX_RADIUS_LEN)
89 typedef struct radius_packet_t {
93 uint8_t vector[AUTH_VECTOR_LEN];
97 #define AUTH_HDR_LEN 20