1 #ifndef FR_DHCP_H 2 #define FR_DHCP_H 3 4 /* 5 * dhcp.h Structures and prototypes for DHCP. 6 * Why DHCP in a RADIUS server? 7 * Why not? 8 * 9 * Version: $Id: 01fa781ded6d11d10881d3d09b879ff53ebfa73c $ 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 24 * 25 * Copyright 2008 The FreeRADIUS server project 26 * Copyright 2008 Alan DeKok <aland@deployingradius.com> 27 */ 28 RCSIDH(dhcp_h, "$Id: 01fa781ded6d11d10881d3d09b879ff53ebfa73c $") 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 /* 35 * Not for production use. 36 */ 37 RADIUS_PACKET *fr_dhcp_recv(int sockfd); 38 int fr_dhcp_send(RADIUS_PACKET *packet); 39 40 int fr_dhcp_add_arp_entry(int fd, char const *interface, VALUE_PAIR *hwvp, VALUE_PAIR *clvp); 41 42 int8_t fr_dhcp_attr_cmp(void const *a, void const *b); 43 ssize_t fr_dhcp_encode_option(TALLOC_CTX *ctx, uint8_t *out, size_t outlen, vp_cursor_t *cursor); 44 int fr_dhcp_encode(RADIUS_PACKET *packet); 45 ssize_t fr_dhcp_decode_options(TALLOC_CTX *ctx, VALUE_PAIR **out, uint8_t const *data, size_t len); 46 int fr_dhcp_decode(RADIUS_PACKET *packet); 47 48 #ifdef HAVE_LINUX_IF_PACKET_H 49 #include <linux/if_packet.h> 50 int fr_socket_packet(int iface_index, struct sockaddr_ll *p_ll); 51 int fr_dhcp_send_raw_packet(int sockfd, struct sockaddr_ll *p_ll, RADIUS_PACKET *packet); 52 RADIUS_PACKET *fr_dhcp_recv_raw_packet(int sockfd, struct sockaddr_ll *p_ll, RADIUS_PACKET *request); 53 #endif 54 55 /* 56 * This is a horrible hack. 57 */ 58 #define PW_DHCP_OFFSET (1024) 59 #define PW_DHCP_DISCOVER (1024 + 1) 60 #define PW_DHCP_OFFER (1024 + 2) 61 #define PW_DHCP_REQUEST (1024 + 3) 62 #define PW_DHCP_DECLINE (1024 + 4) 63 #define PW_DHCP_ACK (1024 + 5) 64 #define PW_DHCP_NAK (1024 + 6) 65 #define PW_DHCP_RELEASE (1024 + 7) 66 #define PW_DHCP_INFORM (1024 + 8) 67 #define PW_DHCP_LEASE_QUERY (1024 + 10) 68 69 #define DHCP_MAGIC_VENDOR (54) 70 71 #define PW_DHCP_OPTION_82 (82) 72 #define DHCP_PACK_OPTION1(x,y) ((x) | ((y) << 8)) 73 #define DHCP_BASE_ATTR(x) (x & 0xff) 74 #define DHCP_UNPACK_OPTION1(x) (((x) & 0xff00) >> 8) 75 76 #define PW_DHCP_MESSAGE_TYPE (53) 77 #define PW_DHCP_YOUR_IP_ADDRESS (264) 78 #define PW_DHCP_SUBNET_MASK (1) 79 #define PW_DHCP_IP_ADDRESS_LEASE_TIME (51) 80 81 #ifdef __cplusplus 82 } 83 #endif 84 85 #endif /* FR_DHCP_H */ 86