All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dhcp.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 #ifndef _FR_DHCP_H
17 #define _FR_DHCP_H
18 /**
19  * $Id: 4060daa8e946b236f96a375bb177fe5a5a9dd13d $
20  *
21  * @file include/dhcp.h
22  * @brief Implementation of the DHCPv4 protocol.
23  *
24  * @copyright 2008 The FreeRADIUS server project
25  * @copyright 2008 Alan DeKok <aland@deployingradius.com>
26  */
27 RCSIDH(dhcp_h, "$Id: 4060daa8e946b236f96a375bb177fe5a5a9dd13d $")
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * Not for production use.
35  */
38 
39 #ifdef HAVE_PCAP_H
40 typedef struct fr_pcap fr_pcap_t;
41 
42 RADIUS_PACKET *fr_dhcp_recv_pcap(fr_pcap_t *pcap);
43 
44 int fr_dhcp_send_pcap(fr_pcap_t *pcap, uint8_t *dst_ether_addr, RADIUS_PACKET *packet);
45 #endif
46 
47 int fr_dhcp_add_arp_entry(int fd, char const *interface, VALUE_PAIR *hwvp, VALUE_PAIR *clvp);
48 
49 int8_t fr_dhcp_attr_cmp(void const *a, void const *b);
50 
51 ssize_t fr_dhcp_encode_option(uint8_t *out, size_t outlen, vp_cursor_t *cursor, void *encoder_ctx);
52 
53 int fr_dhcp_encode(RADIUS_PACKET *packet);
54 
55 ssize_t fr_dhcp_decode_option(TALLOC_CTX *ctx, vp_cursor_t *cursor,
56  fr_dict_attr_t const *parent, uint8_t const *data, size_t len,
57  void *decoder_ctx);
58 
59 int fr_dhcp_decode(RADIUS_PACKET *packet);
60 
61 #ifdef HAVE_LINUX_IF_PACKET_H
62 #include <linux/if_packet.h>
63 int fr_socket_packet(int iface_index, struct sockaddr_ll *p_ll);
64 
65 int fr_dhcp_send_raw_packet(int sockfd, struct sockaddr_ll *p_ll, RADIUS_PACKET *packet);
66 
67 RADIUS_PACKET *fr_dhcp_recv_raw_packet(int sockfd, struct sockaddr_ll *p_ll, RADIUS_PACKET *request);
68 #endif
69 
70 /*
71  * This is a horrible hack.
72  */
73 #define PW_DHCP_OFFSET (1024)
74 
75 typedef enum {
93 
94 extern char const *dhcp_header_names[];
95 extern char const *dhcp_message_types[];
96 
97 #define DHCP_MAGIC_VENDOR (54)
98 
99 #define PW_DHCP_OPTION_82 (82)
100 #define DHCP_PACK_OPTION1(x,y) ((x) | ((y) << 8))
101 #define DHCP_BASE_ATTR(x) (x & 0xff)
102 #define DHCP_UNPACK_OPTION1(x) (((x) & 0xff00) >> 8)
103 
104 #define PW_DHCP_MESSAGE_TYPE (53)
105 #define PW_DHCP_YOUR_IP_ADDRESS (264)
106 #define PW_DHCP_SUBNET_MASK (1)
107 #define PW_DHCP_IP_ADDRESS_LEASE_TIME (51)
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* _FR_DHCP_H */
int fr_dhcp_add_arp_entry(int fd, char const *interface, VALUE_PAIR *hwvp, VALUE_PAIR *clvp)
static int sockfd
Definition: radclient.c:59
#define RCSIDH(h, id)
Definition: build.h:136
Dictionary attribute.
Definition: dict.h:77
ssize_t fr_dhcp_encode_option(uint8_t *out, size_t outlen, vp_cursor_t *cursor, void *encoder_ctx)
char const * dhcp_header_names[]
Definition: dhcp.c:121
ssize_t fr_dhcp_decode_option(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dict_attr_t const *parent, uint8_t const *data, size_t len, void *decoder_ctx)
int8_t fr_dhcp_attr_cmp(void const *a, void const *b)
Definition: dhcp.c:1309
Abstraction to allow iterating over different configurations of VALUE_PAIRs.
Definition: pair.h:144
int fr_dhcp_encode(RADIUS_PACKET *packet)
Definition: dhcp.c:1629
int fr_dhcp_decode(RADIUS_PACKET *packet)
Definition: dhcp.c:1103
Stores an attribute, a value and various bits of other data.
Definition: pair.h:112
uint8_t data[]
Definition: eap_pwd.h:625
char const * dhcp_message_types[]
Definition: dhcp.c:140
int fr_dhcp_send_socket(RADIUS_PACKET *packet)
Send DHCP packet using socket.
Definition: dhcp.c:561
RADIUS_PACKET * fr_dhcp_recv_socket(int sockfd)
Receive DHCP packet using socket.
Definition: dhcp.c:255
fr_dhcp_codes_t
Definition: dhcp.h:75
#define PW_DHCP_OFFSET
Definition: dhcp.h:73