Add "extern C {...} to header files for C++ builds.
[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 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /*
36  *      Not for production use.
37  */
38 RADIUS_PACKET *fr_dhcp_recv(int sockfd);
39 int fr_dhcp_send(RADIUS_PACKET *packet);
40
41 int fr_dhcp_encode(RADIUS_PACKET *packet, RADIUS_PACKET *original);
42 int fr_dhcp_decode(RADIUS_PACKET *packet);
43
44 /*
45  *      This is a horrible hack.
46  */
47 #define PW_DHCP_OFFSET          (1024)
48 #define PW_DHCP_DISCOVER        (1024 + 1)
49 #define PW_DHCP_OFFER           (1024 + 2)
50 #define PW_DHCP_REQUEST         (1024 + 3)
51 #define PW_DHCP_DECLINE         (1024 + 4)
52 #define PW_DHCP_ACK             (1024 + 5)
53 #define PW_DHCP_NAK             (1024 + 6)
54 #define PW_DHCP_RELEASE         (1024 + 7)
55 #define PW_DHCP_INFORM          (1024 + 8)
56
57 #define DHCP_MAGIC_VENDOR (54)
58 #define DHCP2ATTR(x) ((DHCP_MAGIC_VENDOR << 16) | (x))
59 #define ATTR2DHCP(x) ((x) & 0xff)
60 #define IS_DHCP_ATTR(x) (VENDOR((x)->attribute) == DHCP_MAGIC_VENDOR)
61
62 #define PW_DHCP_OPTION_82 (82)
63 #define DHCP_PACK_OPTION1(x,y) ((x) | ((y) << 8))
64 #define DHCP_BASE_ATTR(x) (x & 0xff)
65 #define DHCP_UNPACK_OPTION1(x) (((x) & 0xff00) >> 8)
66
67 #ifdef __cplusplus
68 }
69 #endif
70
71 #endif /* FR_DHCP_H */