Share ifchd command defines between ifchd and ndhc.

This commit is contained in:
Nicholas J. Kain
2011-07-25 02:01:38 -04:00
parent fe85e52a4b
commit 7e1e902b34
6 changed files with 28 additions and 28 deletions

View File

@@ -39,6 +39,7 @@
#include "io.h"
#include "strl.h"
#include "ifchange.h"
#include "ifch_proto.h"
static int cfg_deconfig; // Set if the interface has already been deconfigured.
static struct dhcpmsg cfg_packet; // Copy of the current configuration packet.
@@ -167,9 +168,9 @@ void ifchange_deconfig(void)
sockfd = open_ifch();
snprintf(buf, sizeof buf, "interface:%s:ip:0.0.0.0:",
snprintf(buf, sizeof buf, CMD_INTERFACE ":%s:" CMD_IP ":0.0.0.0:",
client_config.interface);
log_line("Sent to ifchd: ip:0.0.0.0:");
log_line("Resetting %s IP configuration.", client_config.interface);
sockwrite(sockfd, buf, strlen(buf));
cfg_deconfig = 1;
@@ -223,7 +224,7 @@ void ifchange_bind(struct dhcpmsg *packet)
if (!packet)
return;
snprintf(buf, sizeof buf, "interface:%s:", client_config.interface);
snprintf(buf, sizeof buf, CMD_INTERFACE ":%s:", client_config.interface);
tbs |= send_client_ip(buf, sizeof buf, packet);
tbs |= send_cmd(buf, sizeof buf, packet, DHCP_SUBNET);
tbs |= send_cmd(buf, sizeof buf, packet, DHCP_ROUTER);

View File

@@ -24,6 +24,7 @@
#include "options.h"
#include "log.h"
#include "ifch_proto.h"
struct dhcp_option {
char name[10];
@@ -36,35 +37,30 @@ struct dhcp_option {
#define OPTION_REQ 16
// Marks an option that can be sent as a list of multiple items.
#define OPTION_LIST 32
static const struct dhcp_option options[] = {
// name[10] type code
{"subnet" , OPTION_IP | OPTION_LIST | OPTION_REQ, 0x01},
{"timezone" , OPTION_S32, 0x02},
{"router" , OPTION_IP | OPTION_REQ, 0x03},
{"timesvr" , OPTION_IP | OPTION_LIST, 0x04},
{"namesvr" , OPTION_IP | OPTION_LIST, 0x05},
{"dns" , OPTION_IP | OPTION_LIST | OPTION_REQ, 0x06},
{"logsvr" , OPTION_IP | OPTION_LIST, 0x07},
{"cookiesvr", OPTION_IP | OPTION_LIST, 0x08},
{"lprsvr" , OPTION_IP | OPTION_LIST, 0x09},
{"hostname" , OPTION_STRING | OPTION_REQ, 0x0c},
{"bootsize" , OPTION_U16, 0x0d},
{"domain" , OPTION_STRING | OPTION_REQ, 0x0f},
{"swapsvr" , OPTION_IP, 0x10},
{"rootpath" , OPTION_STRING, 0x11},
{"ipttl" , OPTION_U8, 0x17},
{"mtu" , OPTION_U16, 0x1a},
{"broadcast", OPTION_IP | OPTION_REQ, 0x1c},
{"ntpsrv" , OPTION_IP | OPTION_LIST, 0x2a},
{"wins" , OPTION_IP | OPTION_LIST, 0x2c},
{CMD_SUBNET , OPTION_IP | OPTION_LIST | OPTION_REQ, 0x01},
{CMD_TIMEZONE , OPTION_S32, 0x02},
{CMD_ROUTER , OPTION_IP | OPTION_REQ, 0x03},
{CMD_TIMESVR , OPTION_IP | OPTION_LIST, 0x04},
{CMD_DNS , OPTION_IP | OPTION_LIST | OPTION_REQ, 0x06},
{CMD_LPRSVR , OPTION_IP | OPTION_LIST, 0x09},
{CMD_HOSTNAME , OPTION_STRING | OPTION_REQ, 0x0c},
{CMD_DOMAIN , OPTION_STRING | OPTION_REQ, 0x0f},
{CMD_IPTTL , OPTION_U8, 0x17},
{CMD_MTU , OPTION_U16, 0x1a},
{CMD_BROADCAST, OPTION_IP | OPTION_REQ, 0x1c},
{CMD_NTPSRV , OPTION_IP | OPTION_LIST, 0x2a},
{CMD_WINS , OPTION_IP | OPTION_LIST, 0x2c},
// Past this point, these options are not useful for client configuration
// and contain DHCP protocol metadata. Perhaps they can be removed.
{"requestip", OPTION_IP, 0x32},
{"lease" , OPTION_U32, 0x33},
{"dhcptype" , OPTION_U8, 0x35},
{"serverid" , OPTION_IP, 0x36},
{"message" , OPTION_STRING, 0x38},
{"maxsize" , OPTION_U16, 0x39},
{"tftp" , OPTION_STRING, 0x42},
{"bootfile" , OPTION_STRING, 0x43},
{"NONE" , OPTION_NONE, 0x00}
};