0f7e6f145e367ea588f0e77f8f4a710c259f5898
[freeradius.git] / src / include / dhcp.h
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$
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 #include <freeradius-devel/ident.h>
29 RCSIDH(dhcp_h, "$Id$")
30
31 /*
32  *      Not for production use.
33  */
34 RADIUS_PACKET *fr_dhcp_recv(int sockfd);
35 int fr_dhcp_send(RADIUS_PACKET *packet);
36
37 int fr_dhcp_encode(RADIUS_PACKET *packet, RADIUS_PACKET *original);
38 int fr_dhcp_decode(RADIUS_PACKET *packet);
39
40 /*
41  *      This is a horrible hack.
42  */
43 #define PW_DHCP_OFFSET          (1024)
44 #define PW_DHCP_DISCOVER        (1024 + 1)
45 #define PW_DHCP_OFFER           (1024 + 2)
46 #define PW_DHCP_REQUEST         (1024 + 3)
47 #define PW_DHCP_DECLINE         (1024 + 4)
48 #define PW_DHCP_ACK             (1024 + 5)
49 #define PW_DHCP_NAK             (1024 + 6)
50 #define PW_DHCP_RELEASE         (1024 + 7)
51 #define PW_DHCP_INFORM          (1024 + 8)
52
53 #define DHCP_MAGIC_VENDOR (54)
54 #define DHCP2ATTR(x) ((DHCP_MAGIC_VENDOR << 16) | (x))
55 #define ATTR2DHCP(x) ((x) & 0xff)
56 #define IS_DHCP_ATTR(x) (VENDOR((x)->attribute) == DHCP_MAGIC_VENDOR)
57
58 #define PW_DHCP_OPTION_82 (82)
59 #define DHCP_PACK_OPTION1(x,y) ((x) | ((y) << 8))
60 #define DHCP_BASE_ATTR(x) (x & 0xff)
61 #define DHCP_UNPACK_OPTION1(x) (((x) & 0xff00) >> 8)
62
63 #endif /* FR_DHCP_H */