2011-03-31 01:27:01 +05:30
|
|
|
/* options.h - DHCP options handling
|
|
|
|
*
|
2015-02-13 12:24:57 +05:30
|
|
|
* Copyright (c) 2004-2015 Nicholas J. Kain <njkain at gmail dot com>
|
2011-07-25 12:00:57 +05:30
|
|
|
* All rights reserved.
|
2011-03-31 01:27:01 +05:30
|
|
|
*
|
2011-07-25 12:00:57 +05:30
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
2011-03-31 01:27:01 +05:30
|
|
|
*
|
2011-07-25 12:00:57 +05:30
|
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
2011-03-31 01:27:01 +05:30
|
|
|
*
|
2011-07-25 12:00:57 +05:30
|
|
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
2011-03-31 01:27:01 +05:30
|
|
|
*/
|
2010-11-13 17:21:57 +05:30
|
|
|
#ifndef OPTIONS_H_
|
|
|
|
#define OPTIONS_H_
|
2010-11-12 14:32:18 +05:30
|
|
|
|
2011-07-02 13:21:44 +05:30
|
|
|
#include "dhcp.h"
|
2010-11-12 14:32:18 +05:30
|
|
|
|
2011-07-25 13:56:34 +05:30
|
|
|
#define DCODE_PADDING 0x00
|
2011-07-25 12:41:47 +05:30
|
|
|
#define DCODE_SUBNET 0x01
|
|
|
|
#define DCODE_TIMEZONE 0x02
|
|
|
|
#define DCODE_ROUTER 0x03
|
|
|
|
#define DCODE_DNS 0x06
|
|
|
|
#define DCODE_LPRSVR 0x09
|
|
|
|
#define DCODE_HOSTNAME 0x0c
|
|
|
|
#define DCODE_DOMAIN 0x0f
|
|
|
|
#define DCODE_IPTTL 0x17
|
|
|
|
#define DCODE_MTU 0x1a
|
|
|
|
#define DCODE_BROADCAST 0x1c
|
|
|
|
#define DCODE_NTPSVR 0x2a
|
|
|
|
#define DCODE_WINS 0x2c
|
2011-07-25 13:56:34 +05:30
|
|
|
#define DCODE_REQIP 0x32
|
|
|
|
#define DCODE_LEASET 0x33
|
2011-07-25 12:41:47 +05:30
|
|
|
#define DCODE_OVERLOAD 0x34
|
2011-07-25 13:56:34 +05:30
|
|
|
#define DCODE_MSGTYPE 0x35
|
2011-07-25 12:41:47 +05:30
|
|
|
#define DCODE_SERVER_ID 0x36
|
|
|
|
#define DCODE_PARAM_REQ 0x37
|
|
|
|
#define DCODE_MAX_SIZE 0x39
|
|
|
|
#define DCODE_VENDOR 0x3c
|
|
|
|
#define DCODE_CLIENT_ID 0x3d
|
|
|
|
#define DCODE_END 0xff
|
2011-03-30 15:07:22 +05:30
|
|
|
|
2011-07-27 17:09:45 +05:30
|
|
|
#define MAX_DOPT_SIZE 500
|
|
|
|
|
2015-02-14 09:44:08 +05:30
|
|
|
ssize_t get_dhcp_opt(const struct dhcpmsg packet[static 1], uint8_t code,
|
|
|
|
uint8_t *dbuf, ssize_t dlen);
|
|
|
|
ssize_t get_end_option_idx(const struct dhcpmsg packet[static 1]);
|
2011-07-26 09:18:35 +05:30
|
|
|
|
2015-02-14 09:44:08 +05:30
|
|
|
size_t add_option_string(struct dhcpmsg packet[static 1], uint8_t code,
|
|
|
|
const char str[static 1], size_t slen);
|
|
|
|
size_t add_u32_option(struct dhcpmsg packet[static 1], uint8_t code,
|
|
|
|
uint32_t data);
|
2011-09-02 11:42:51 +05:30
|
|
|
|
2015-02-14 09:44:08 +05:30
|
|
|
size_t add_option_request_list(struct dhcpmsg packet[static 1]);
|
2014-03-19 15:30:45 +05:30
|
|
|
#ifdef NDHS_BUILD
|
2015-02-14 09:44:08 +05:30
|
|
|
size_t add_option_domain_name(struct dhcpmsg packet[static 1],
|
|
|
|
const char dom[static 1], size_t domlen);
|
|
|
|
void add_option_subnet_mask(struct dhcpmsg packet[static 1], uint32_t subnet);
|
|
|
|
void add_option_broadcast(struct dhcpmsg packet[static 1], uint32_t bc);
|
2014-03-19 15:30:45 +05:30
|
|
|
#endif
|
2015-02-14 09:44:08 +05:30
|
|
|
void add_option_msgtype(struct dhcpmsg packet[static 1], uint8_t type);
|
|
|
|
void add_option_reqip(struct dhcpmsg packet[static 1], uint32_t ip);
|
|
|
|
void add_option_serverid(struct dhcpmsg packet[static 1], uint32_t sid);
|
|
|
|
void add_option_clientid(struct dhcpmsg packet[static 1],
|
|
|
|
const char clientid[static 1], size_t clen);
|
2011-09-02 11:42:51 +05:30
|
|
|
#ifndef NDHS_BUILD
|
2015-02-14 09:44:08 +05:30
|
|
|
void add_option_maxsize(struct dhcpmsg packet[static 1]);
|
|
|
|
void add_option_vendor(struct dhcpmsg packet[static 1]);
|
|
|
|
void add_option_hostname(struct dhcpmsg packet[static 1]);
|
2011-09-02 11:42:51 +05:30
|
|
|
#endif
|
2015-02-14 09:44:08 +05:30
|
|
|
uint32_t get_option_router(const struct dhcpmsg packet[static 1]);
|
|
|
|
uint8_t get_option_msgtype(const struct dhcpmsg packet[static 1]);
|
|
|
|
uint32_t get_option_serverid(const struct dhcpmsg packet[static 1], int *found);
|
|
|
|
uint32_t get_option_leasetime(const struct dhcpmsg packet[static 1]);
|
|
|
|
size_t get_option_clientid(const struct dhcpmsg packet[static 1],
|
|
|
|
char cbuf[static 1], size_t clen);
|
2011-07-26 10:34:59 +05:30
|
|
|
|
2010-11-12 14:32:18 +05:30
|
|
|
#endif
|