2022-02-07 06:35:29 +05:30
|
|
|
// Copyright 2004-2018 Nicholas J. Kain <njkain at gmail dot com>
|
|
|
|
// SPDX-License-Identifier: MIT
|
2010-11-12 14:32:18 +05:30
|
|
|
#include <string.h>
|
2014-03-19 16:12:39 +05:30
|
|
|
#include <stdbool.h>
|
2010-11-12 14:32:18 +05:30
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <errno.h>
|
2014-03-19 15:37:01 +05:30
|
|
|
#include <limits.h>
|
2014-03-31 02:32:48 +05:30
|
|
|
#include "nk/log.h"
|
|
|
|
#include "nk/io.h"
|
2010-11-12 14:32:18 +05:30
|
|
|
|
|
|
|
#include "options.h"
|
2014-03-13 01:54:02 +05:30
|
|
|
#include "ndhc.h"
|
2011-07-02 13:21:44 +05:30
|
|
|
#include "dhcp.h"
|
2010-11-12 14:32:18 +05:30
|
|
|
#include "options.h"
|
2011-03-31 08:47:27 +05:30
|
|
|
#include "arp.h"
|
2010-12-24 20:42:41 +05:30
|
|
|
#include "ifchange.h"
|
2010-11-12 14:32:18 +05:30
|
|
|
|
2011-07-05 07:40:14 +05:30
|
|
|
static struct dhcpmsg cfg_packet; // Copy of the current configuration packet.
|
2011-07-05 07:10:32 +05:30
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static int ifcmd_raw(char *buf, size_t buflen, const char *optname,
|
2018-02-09 13:09:46 +05:30
|
|
|
char *optdata, size_t optlen)
|
2014-03-19 15:37:01 +05:30
|
|
|
{
|
2014-03-21 09:20:58 +05:30
|
|
|
if (!optdata) {
|
2020-11-25 07:32:51 +05:30
|
|
|
log_line("%s: (%s) '%s' option has no data",
|
|
|
|
client_config.interface, __func__, optname);
|
2014-03-19 15:37:01 +05:30
|
|
|
return -1;
|
2014-03-21 09:20:58 +05:30
|
|
|
}
|
2018-02-09 13:09:46 +05:30
|
|
|
if (optlen > INT_MAX) {
|
2020-11-25 07:32:51 +05:30
|
|
|
log_line("%s: (%s) '%s' option optlen out of bounds",
|
|
|
|
client_config.interface, __func__, optname);
|
2014-03-19 15:37:01 +05:30
|
|
|
return -1;
|
2014-03-21 09:20:58 +05:30
|
|
|
}
|
|
|
|
if (buflen < strlen(optname) + optlen + 3) {
|
2020-11-25 07:32:51 +05:30
|
|
|
log_line("%s: (%s) '%s' option buf too short",
|
|
|
|
client_config.interface, __func__, optname);
|
2014-03-19 15:37:01 +05:30
|
|
|
return -1;
|
2014-03-21 09:20:58 +05:30
|
|
|
}
|
2014-03-19 15:37:01 +05:30
|
|
|
int ioptlen = (int)optlen;
|
|
|
|
ssize_t olen = snprintf(buf, buflen, "%s:%.*s;",
|
|
|
|
optname, ioptlen, optdata);
|
2022-02-25 16:41:16 +05:30
|
|
|
if (olen < 0 || (size_t)olen > buflen) {
|
2020-11-25 07:32:51 +05:30
|
|
|
log_line("%s: (%s) '%s' option would truncate, so it was dropped.",
|
|
|
|
client_config.interface, __func__, optname);
|
2014-03-19 15:44:50 +05:30
|
|
|
memset(buf, 0, buflen);
|
|
|
|
return -1;
|
|
|
|
}
|
2014-03-19 15:37:01 +05:30
|
|
|
return olen;
|
|
|
|
}
|
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static int ifcmd_bytes(char *buf, size_t buflen, const char *optname,
|
2018-02-09 13:09:46 +05:30
|
|
|
uint8_t *optdata, size_t optlen)
|
2014-03-19 15:37:01 +05:30
|
|
|
{
|
|
|
|
return ifcmd_raw(buf, buflen, optname, (char *)optdata, optlen);
|
|
|
|
}
|
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static int ifcmd_u8(char *buf, size_t buflen, const char *optname,
|
2018-02-09 13:09:46 +05:30
|
|
|
uint8_t *optdata, size_t optlen)
|
2010-11-12 14:32:18 +05:30
|
|
|
{
|
2011-07-26 15:45:21 +05:30
|
|
|
if (!optdata || optlen < 1)
|
|
|
|
return -1;
|
2014-03-19 15:37:01 +05:30
|
|
|
char numbuf[16];
|
|
|
|
uint8_t c = optdata[0];
|
|
|
|
ssize_t olen = snprintf(numbuf, sizeof numbuf, "%c", c);
|
2022-02-25 16:41:16 +05:30
|
|
|
if (olen < 0 || (size_t)olen > sizeof numbuf)
|
2014-03-19 15:37:01 +05:30
|
|
|
return -1;
|
|
|
|
return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf));
|
2011-07-26 15:45:21 +05:30
|
|
|
}
|
2010-11-13 01:03:17 +05:30
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static int ifcmd_u16(char *buf, size_t buflen, const char *optname,
|
2018-02-09 13:09:46 +05:30
|
|
|
uint8_t *optdata, size_t optlen)
|
2011-07-26 15:45:21 +05:30
|
|
|
{
|
|
|
|
if (!optdata || optlen < 2)
|
2010-11-13 06:13:16 +05:30
|
|
|
return -1;
|
2014-03-19 15:37:01 +05:30
|
|
|
char numbuf[16];
|
2011-07-26 15:45:21 +05:30
|
|
|
uint16_t v;
|
|
|
|
memcpy(&v, optdata, 2);
|
|
|
|
v = ntohs(v);
|
2014-03-19 15:37:01 +05:30
|
|
|
ssize_t olen = snprintf(numbuf, sizeof numbuf, "%hu", v);
|
2022-02-25 16:41:16 +05:30
|
|
|
if (olen < 0 || (size_t)olen > sizeof numbuf)
|
2014-03-19 15:37:01 +05:30
|
|
|
return -1;
|
|
|
|
return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf));
|
2011-07-26 15:45:21 +05:30
|
|
|
}
|
2011-03-30 20:09:11 +05:30
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static int ifcmd_s32(char *buf, size_t buflen, const char *optname,
|
2018-02-09 13:09:46 +05:30
|
|
|
uint8_t *optdata, size_t optlen)
|
2011-07-26 15:45:21 +05:30
|
|
|
{
|
|
|
|
if (!optdata || optlen < 4)
|
|
|
|
return -1;
|
2014-03-19 15:37:01 +05:30
|
|
|
char numbuf[16];
|
2018-02-09 13:09:46 +05:30
|
|
|
uint32_t v;
|
2011-07-26 15:45:21 +05:30
|
|
|
memcpy(&v, optdata, 4);
|
|
|
|
v = ntohl(v);
|
2014-03-19 15:37:01 +05:30
|
|
|
ssize_t olen = snprintf(numbuf, sizeof numbuf, "%d", v);
|
2022-02-25 16:41:16 +05:30
|
|
|
if (olen < 0 || (size_t)olen > sizeof numbuf)
|
2014-03-19 15:37:01 +05:30
|
|
|
return -1;
|
|
|
|
return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf));
|
2011-07-26 15:45:21 +05:30
|
|
|
}
|
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static int ifcmd_ip(char *buf, size_t buflen, const char *optname,
|
2018-02-09 13:09:46 +05:30
|
|
|
uint8_t *optdata, size_t optlen)
|
2011-07-26 15:45:21 +05:30
|
|
|
{
|
|
|
|
if (!optdata || optlen < 4)
|
|
|
|
return -1;
|
2014-03-19 15:37:01 +05:30
|
|
|
char ipbuf[INET_ADDRSTRLEN];
|
2014-03-20 04:44:38 +05:30
|
|
|
inet_ntop(AF_INET, optdata, ipbuf, sizeof ipbuf);
|
2014-03-19 15:37:01 +05:30
|
|
|
return ifcmd_raw(buf, buflen, optname, ipbuf, strlen(ipbuf));
|
2011-07-26 15:45:21 +05:30
|
|
|
}
|
2011-03-30 20:09:11 +05:30
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static int ifcmd_iplist(char *out, size_t outlen, const char *optname,
|
2018-02-09 13:09:46 +05:30
|
|
|
uint8_t *optdata, size_t optlen)
|
2011-07-26 15:45:21 +05:30
|
|
|
{
|
2014-03-19 15:37:01 +05:30
|
|
|
char buf[2048];
|
2011-07-26 15:45:21 +05:30
|
|
|
char ipbuf[INET_ADDRSTRLEN];
|
2014-03-19 15:37:01 +05:30
|
|
|
size_t bufoff = 0;
|
|
|
|
size_t optoff = 0;
|
|
|
|
|
2013-05-10 23:16:58 +05:30
|
|
|
if (!optdata || optlen < 4)
|
2011-07-26 15:45:21 +05:30
|
|
|
return -1;
|
2014-03-19 15:37:01 +05:30
|
|
|
|
2014-03-20 04:44:38 +05:30
|
|
|
inet_ntop(AF_INET, optdata + optoff, ipbuf, sizeof ipbuf);
|
2014-03-21 09:20:58 +05:30
|
|
|
ssize_t wc = snprintf(buf + bufoff, sizeof buf, "%s", ipbuf);
|
2022-02-25 16:41:16 +05:30
|
|
|
if (wc < 0 || (size_t)wc > sizeof buf)
|
2014-03-19 15:37:01 +05:30
|
|
|
return -1;
|
|
|
|
optoff += 4;
|
2018-02-09 13:09:46 +05:30
|
|
|
bufoff += (size_t)wc;
|
|
|
|
while (optlen >= 4 + optoff) {
|
2014-03-20 04:44:38 +05:30
|
|
|
inet_ntop(AF_INET, optdata + optoff, ipbuf, sizeof ipbuf);
|
2014-03-19 15:37:01 +05:30
|
|
|
wc = snprintf(buf + bufoff, sizeof buf, ",%s", ipbuf);
|
2022-02-25 16:41:16 +05:30
|
|
|
if (wc < 0 || (size_t)wc > sizeof buf)
|
2014-03-19 15:37:01 +05:30
|
|
|
return -1;
|
|
|
|
optoff += 4;
|
2018-02-09 13:09:46 +05:30
|
|
|
bufoff += (size_t)wc;
|
2014-03-19 15:37:01 +05:30
|
|
|
}
|
|
|
|
return ifcmd_raw(out, outlen, optname, buf, strlen(buf));
|
2011-07-26 15:45:21 +05:30
|
|
|
}
|
2010-11-13 01:03:17 +05:30
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static int ifchd_cmd(char *b, size_t bl, uint8_t *od,
|
2018-02-09 13:09:46 +05:30
|
|
|
size_t ol, uint8_t code)
|
2011-07-26 15:45:21 +05:30
|
|
|
{
|
|
|
|
switch (code) {
|
2014-03-19 16:10:42 +05:30
|
|
|
case DCODE_ROUTER: return ifcmd_ip(b, bl, "routr", od, ol);
|
|
|
|
case DCODE_DNS: return ifcmd_iplist(b, bl, "dns", od, ol);
|
|
|
|
case DCODE_LPRSVR: return ifcmd_iplist(b, bl, "lpr", od, ol);
|
|
|
|
case DCODE_NTPSVR: return ifcmd_iplist(b, bl, "ntp", od, ol);
|
|
|
|
case DCODE_WINS: return ifcmd_iplist(b, bl, "wins", od, ol);
|
|
|
|
case DCODE_HOSTNAME: return ifcmd_bytes(b, bl, "host", od, ol);
|
|
|
|
case DCODE_DOMAIN: return ifcmd_bytes(b, bl, "dom", od, ol);
|
|
|
|
case DCODE_TIMEZONE: return ifcmd_s32(b, bl, "tzone", od, ol);
|
|
|
|
case DCODE_MTU: return ifcmd_u16(b, bl, "mtu", od, ol);
|
|
|
|
case DCODE_IPTTL: return ifcmd_u8(b, bl, "ipttl", od, ol);
|
|
|
|
default: break;
|
2010-11-13 01:03:17 +05:30
|
|
|
}
|
2020-11-25 07:32:51 +05:30
|
|
|
log_line("%s: Invalid option code (%c) for ifchd cmd.",
|
|
|
|
client_config.interface, code);
|
2014-03-19 16:10:42 +05:30
|
|
|
return -1;
|
2010-11-12 14:32:18 +05:30
|
|
|
}
|
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static int ifchwrite(const char *buf, size_t count)
|
2010-11-12 14:32:18 +05:30
|
|
|
{
|
2014-04-07 13:14:02 +05:30
|
|
|
ssize_t r = safe_write(ifchSock[0], buf, count);
|
2014-04-04 13:31:49 +05:30
|
|
|
if (r < 0 || (size_t)r != count) {
|
2020-11-25 07:32:51 +05:30
|
|
|
log_line("%s: (%s) write failed: %zd", client_config.interface, __func__, r);
|
2015-02-15 03:19:50 +05:30
|
|
|
return -1;
|
2014-03-15 14:02:44 +05:30
|
|
|
}
|
2015-02-15 03:19:50 +05:30
|
|
|
char data[256], control[256];
|
|
|
|
struct iovec iov = {
|
|
|
|
.iov_base = data,
|
|
|
|
.iov_len = sizeof data - 1,
|
|
|
|
};
|
|
|
|
struct msghdr msg = {
|
|
|
|
.msg_iov = &iov,
|
|
|
|
.msg_iovlen = 1,
|
|
|
|
.msg_control = control,
|
|
|
|
.msg_controllen = sizeof control
|
|
|
|
};
|
|
|
|
r = safe_recvmsg(ifchSock[0], &msg, 0);
|
|
|
|
if (r == 0) {
|
|
|
|
// Remote end hung up.
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
} else if (r < 0) {
|
|
|
|
suicide("%s: (%s) recvmsg failed: %s", client_config.interface,
|
|
|
|
__func__, strerror(errno));
|
|
|
|
}
|
|
|
|
data[iov.iov_len] = '\0';
|
|
|
|
if (r == 1 && data[0] == '+')
|
|
|
|
return 0;
|
|
|
|
return -1;
|
2010-11-13 01:03:17 +05:30
|
|
|
}
|
2010-11-12 14:32:18 +05:30
|
|
|
|
2021-04-25 14:56:19 +05:30
|
|
|
bool ifchange_carrier_isup(void)
|
2015-02-15 13:20:29 +05:30
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
snprintf(buf, sizeof buf, "carrier:;");
|
2017-01-12 15:55:15 +05:30
|
|
|
return ifchwrite(buf, strlen(buf)) == 0;
|
2015-02-15 13:20:29 +05:30
|
|
|
}
|
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
int ifchange_deconfig(struct client_state_t *cs)
|
2010-11-12 14:32:18 +05:30
|
|
|
{
|
2010-11-13 01:03:17 +05:30
|
|
|
char buf[256];
|
2015-02-15 05:40:23 +05:30
|
|
|
int ret = -1;
|
2010-11-13 01:03:17 +05:30
|
|
|
|
2014-03-17 12:25:47 +05:30
|
|
|
if (cs->ifDeconfig)
|
2015-02-15 05:40:23 +05:30
|
|
|
return 0;
|
2011-07-05 07:40:14 +05:30
|
|
|
|
2014-03-10 10:22:56 +05:30
|
|
|
snprintf(buf, sizeof buf, "ip4:0.0.0.0,255.255.255.255;");
|
2014-04-04 13:31:49 +05:30
|
|
|
log_line("%s: Resetting IP configuration.", client_config.interface);
|
2015-02-15 05:40:23 +05:30
|
|
|
ret = ifchwrite(buf, strlen(buf));
|
2010-11-13 01:03:17 +05:30
|
|
|
|
2015-02-15 05:40:23 +05:30
|
|
|
if (ret >= 0) {
|
|
|
|
cs->ifDeconfig = 1;
|
|
|
|
memset(&cfg_packet, 0, sizeof cfg_packet);
|
|
|
|
}
|
|
|
|
return ret;
|
2010-11-12 14:32:18 +05:30
|
|
|
}
|
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static size_t send_client_ip(char *out, size_t olen,
|
|
|
|
struct dhcpmsg *packet)
|
2011-07-06 04:55:19 +05:30
|
|
|
{
|
2014-03-09 23:27:37 +05:30
|
|
|
uint8_t optdata[MAX_DOPT_SIZE], olddata[MAX_DOPT_SIZE];
|
2014-03-19 16:02:13 +05:30
|
|
|
char ip[INET_ADDRSTRLEN], sn[INET_ADDRSTRLEN], bc[INET_ADDRSTRLEN];
|
2018-02-09 13:09:46 +05:30
|
|
|
size_t optlen, oldlen;
|
2014-03-09 23:27:37 +05:30
|
|
|
bool change_ipaddr = false;
|
|
|
|
bool have_subnet = false;
|
|
|
|
bool change_subnet = false;
|
|
|
|
bool have_bcast = false;
|
|
|
|
bool change_bcast = false;
|
|
|
|
|
|
|
|
if (memcmp(&packet->yiaddr, &cfg_packet.yiaddr, sizeof packet->yiaddr))
|
|
|
|
change_ipaddr = true;
|
2014-03-20 04:44:38 +05:30
|
|
|
inet_ntop(AF_INET, &packet->yiaddr, ip, sizeof ip);
|
2014-03-09 23:27:37 +05:30
|
|
|
|
|
|
|
optlen = get_dhcp_opt(packet, DCODE_SUBNET, optdata, sizeof optdata);
|
|
|
|
if (optlen >= 4) {
|
|
|
|
have_subnet = true;
|
2014-03-20 04:44:38 +05:30
|
|
|
inet_ntop(AF_INET, optdata, sn, sizeof sn);
|
2014-03-09 23:27:37 +05:30
|
|
|
oldlen = get_dhcp_opt(&cfg_packet, DCODE_SUBNET, olddata,
|
|
|
|
sizeof olddata);
|
|
|
|
if (oldlen != optlen || memcmp(optdata, olddata, optlen))
|
|
|
|
change_subnet = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
optlen = get_dhcp_opt(packet, DCODE_BROADCAST, optdata, sizeof optdata);
|
|
|
|
if (optlen >= 4) {
|
|
|
|
have_bcast = true;
|
2014-03-20 04:44:38 +05:30
|
|
|
inet_ntop(AF_INET, optdata, bc, sizeof bc);
|
2014-03-09 23:27:37 +05:30
|
|
|
oldlen = get_dhcp_opt(&cfg_packet, DCODE_BROADCAST, olddata,
|
|
|
|
sizeof olddata);
|
|
|
|
if (oldlen != optlen || memcmp(optdata, olddata, optlen))
|
|
|
|
change_bcast = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Nothing to change.
|
|
|
|
if (!change_ipaddr && !change_subnet && !change_bcast)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!have_subnet) {
|
2014-03-19 15:30:08 +05:30
|
|
|
static char snClassC[] = "255.255.255.0";
|
2014-04-04 13:31:49 +05:30
|
|
|
log_line("%s: Server did not send a subnet mask. Assuming 255.255.255.0.",
|
|
|
|
client_config.interface);
|
2014-03-09 23:27:37 +05:30
|
|
|
memcpy(sn, snClassC, sizeof snClassC);
|
|
|
|
}
|
|
|
|
|
2014-03-19 16:02:13 +05:30
|
|
|
int snlen;
|
2014-03-09 23:27:37 +05:30
|
|
|
if (have_bcast) {
|
2014-03-19 16:02:13 +05:30
|
|
|
snlen = snprintf(out, olen, "ip4:%s,%s,%s;", ip, sn, bc);
|
2014-03-09 23:27:37 +05:30
|
|
|
} else {
|
2014-03-19 16:02:13 +05:30
|
|
|
snlen = snprintf(out, olen, "ip4:%s,%s;", ip, sn);
|
2014-03-09 23:27:37 +05:30
|
|
|
}
|
2022-02-25 16:41:16 +05:30
|
|
|
if (snlen < 0 || (size_t)snlen > olen) {
|
2020-11-25 07:32:51 +05:30
|
|
|
log_line("%s: (%s) ip4 command would truncate so it was dropped.",
|
|
|
|
client_config.interface, __func__);
|
2014-03-19 16:02:13 +05:30
|
|
|
memset(out, 0, olen);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-02-09 13:09:46 +05:30
|
|
|
return (size_t)snlen;
|
2011-07-06 04:55:19 +05:30
|
|
|
}
|
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
static size_t send_cmd(char *out, size_t olen,
|
|
|
|
struct dhcpmsg *packet, uint8_t code)
|
2010-11-13 01:03:17 +05:30
|
|
|
{
|
2011-07-27 17:09:45 +05:30
|
|
|
uint8_t optdata[MAX_DOPT_SIZE], olddata[MAX_DOPT_SIZE];
|
2018-02-09 13:09:46 +05:30
|
|
|
size_t optlen, oldlen;
|
2010-11-13 01:03:17 +05:30
|
|
|
|
2011-07-27 17:09:45 +05:30
|
|
|
optlen = get_dhcp_opt(packet, code, optdata, sizeof optdata);
|
2011-07-05 05:37:16 +05:30
|
|
|
if (!optlen)
|
2011-07-06 04:55:19 +05:30
|
|
|
return 0;
|
2011-07-27 17:09:45 +05:30
|
|
|
oldlen = get_dhcp_opt(&cfg_packet, code, olddata, sizeof olddata);
|
2011-07-05 07:10:32 +05:30
|
|
|
if (oldlen == optlen && !memcmp(optdata, olddata, optlen))
|
2011-07-06 04:55:19 +05:30
|
|
|
return 0;
|
2014-03-19 16:02:13 +05:30
|
|
|
int r = ifchd_cmd(out, olen, optdata, optlen, code);
|
2018-02-09 13:09:46 +05:30
|
|
|
return r > 0 ? (size_t)r : 0;
|
2010-11-12 14:32:18 +05:30
|
|
|
}
|
|
|
|
|
2022-01-12 09:05:19 +05:30
|
|
|
int ifchange_bind(struct client_state_t *cs, struct dhcpmsg *packet)
|
2010-11-12 14:32:18 +05:30
|
|
|
{
|
2011-07-06 04:55:19 +05:30
|
|
|
char buf[2048];
|
2014-03-19 16:02:13 +05:30
|
|
|
size_t bo;
|
2015-02-15 05:40:23 +05:30
|
|
|
int ret = -1;
|
2010-11-13 01:03:17 +05:30
|
|
|
|
2014-03-15 14:02:44 +05:30
|
|
|
memset(buf, 0, sizeof buf);
|
2014-03-19 16:02:13 +05:30
|
|
|
bo = send_client_ip(buf, sizeof buf, packet);
|
|
|
|
bo += send_cmd(buf + bo, sizeof buf - bo, packet, DCODE_ROUTER);
|
|
|
|
bo += send_cmd(buf + bo, sizeof buf - bo, packet, DCODE_DNS);
|
|
|
|
bo += send_cmd(buf + bo, sizeof buf - bo, packet, DCODE_HOSTNAME);
|
|
|
|
bo += send_cmd(buf + bo, sizeof buf - bo, packet, DCODE_DOMAIN);
|
|
|
|
bo += send_cmd(buf + bo, sizeof buf - bo, packet, DCODE_MTU);
|
|
|
|
bo += send_cmd(buf + bo, sizeof buf - bo, packet, DCODE_WINS);
|
2015-02-15 13:28:51 +05:30
|
|
|
if (bo) {
|
|
|
|
log_line("%s: bind command: '%s'", client_config.interface, buf);
|
2015-02-15 05:40:23 +05:30
|
|
|
ret = ifchwrite(buf, bo);
|
2015-02-15 13:28:51 +05:30
|
|
|
}
|
2010-11-13 01:03:17 +05:30
|
|
|
|
2015-02-15 05:40:23 +05:30
|
|
|
if (ret >= 0) {
|
|
|
|
cs->ifDeconfig = 0;
|
|
|
|
memcpy(&cfg_packet, packet, sizeof cfg_packet);
|
|
|
|
}
|
|
|
|
return ret;
|
2010-11-12 14:32:18 +05:30
|
|
|
}
|
2015-02-15 05:40:23 +05:30
|
|
|
|