#define FOR_dhcp
#include "toys.h"
+#include "log.h"
// TODO: headers not in posix:
#include <netinet/ip.h>
if (oip) {
xioctl(fd, SIOCGIFADDR, &req);
ip = (struct sockaddr_in*) &req.ifr_addr;
- dbg("IP %s\n", inet_ntoa(ip->sin_addr));
+ SERR("IP %s\n", inet_ntoa(ip->sin_addr));
*oip = ntohl(ip->sin_addr.s_addr);
}
if (ifindex) {
xioctl(fd, SIOCGIFINDEX, &req);
- dbg("Adapter index %d\n", req.ifr_ifindex);
+ SERR("Adapter index %d\n", req.ifr_ifindex);
*ifindex = req.ifr_ifindex;
}
if (mac) {
xioctl(fd, SIOCGIFHWADDR, &req);
memcpy(mac, req.ifr_hwaddr.sa_data, 6);
- dbg("MAC %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ SERR("MAC %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}
close(fd);
return 0;
option = strtok((char*)str, ":");
if (!option) return -1;
- dbg("-x option : %s ", option);
+ SERR("-x option : %s ", option);
optcode = strtou32(option);
if (optcode > 0 && optcode < 256) { // raw option
valstr = strtok(NULL, "\n");
if (!valstr) error_exit("option %s has no value defined.\n", option);
- dbg(" value : %-20s \n ", valstr);
+ SERR(" value : %-20s \n ", valstr);
switch (flag) {
case DHCP_NUM32:
options_list[count].len = sizeof(uint32_t);
if (stat(script, &sts) == -1 && errno == ENOENT) return;
if (fill_envp(res)) {
- dbg("Failed to create environment variables.");
+ SERR("Failed to create environment variables.");
return;
}
- dbg("Executing %s %s\n", script, name);
+ SERR("Executing %s %s\n", script, name);
argv[0] = (char*) script;
argv[1] = (char*) name;
argv[2] = NULL;
pid = vfork();
if (pid < 0) {
- dbg("Fork failed.\n");
+ SERR("Fork failed.\n");
return;
}
if (!pid) {
errno = error;
perror_msg("script exec failed");
}
- dbg("script complete.\n");
+ SERR("script complete.\n");
}
// returns a randome ID
struct sockaddr_ll sock;
if (state->sockfd > 0) close(state->sockfd);
- dbg("Opening raw socket on ifindex %d\n", state->ifindex);
+ SERR("Opening raw socket on ifindex %d\n", state->ifindex);
state->sockfd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
if (state->sockfd < 0) {
- dbg("MODE RAW : socket fail ERROR : %d\n", state->sockfd);
+ SERR("MODE RAW : socket fail ERROR : %d\n", state->sockfd);
return -1;
}
- dbg("Got raw socket fd %d\n", state->sockfd);
+ SERR("Got raw socket fd %d\n", state->sockfd);
memset(&sock, 0, sizeof(sock));
sock.sll_family = AF_PACKET;
sock.sll_protocol = htons(ETH_P_IP);
sock.sll_ifindex = state->ifindex;
if (bind(state->sockfd, (struct sockaddr *) &sock, sizeof(sock))) {
- dbg("MODE RAW : bind fail.\n");
+ SERR("MODE RAW : bind fail.\n");
close(state->sockfd);
return -1;
}
state->mode = MODE_RAW;
if (setsockopt(state->sockfd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog, sizeof(filter_prog)) < 0)
- dbg("MODE RAW : filter attach fail.\n");
+ SERR("MODE RAW : filter attach fail.\n");
- dbg("MODE RAW : success\n");
+ SERR("MODE RAW : success\n");
return 0;
}
state->mode = MODE_OFF;
if (state->sockfd > 0) close(state->sockfd);
- dbg("Opening listen socket on *:%d %s\n", DHCPC_CLIENT_PORT, state->iface);
+ SERR("Opening listen socket on *:%d %s\n", DHCPC_CLIENT_PORT, state->iface);
state->sockfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (state->sockfd < 0) {
- dbg("MODE APP : socket fail ERROR: %d\n", state->sockfd);
+ SERR("MODE APP : socket fail ERROR: %d\n", state->sockfd);
return -1;
}
setsockopt(state->sockfd, SOL_SOCKET, SO_REUSEADDR, &set, sizeof(set));
if (setsockopt(state->sockfd, SOL_SOCKET, SO_BROADCAST, &set, sizeof(set)) == -1) {
- dbg("MODE APP : brodcast failed.\n");
+ SERR("MODE APP : brodcast failed.\n");
close(state->sockfd);
return -1;
}
if (bind(state->sockfd, (struct sockaddr *) &addr, sizeof(addr))) {
close(state->sockfd);
- dbg("MODE APP : bind failed.\n");
+ SERR("MODE APP : bind failed.\n");
return -1;
}
state->mode = MODE_APP;
- dbg("MODE APP : success\n");
+ SERR("MODE APP : success\n");
return 0;
}
memset(&packet, 0, sizeof(packet));
if ((bytes = read(state->sockfd, &packet, sizeof(packet))) < 0) {
- dbg("\tPacket read error, ignoring\n");
+ SERR("\tPacket read error, ignoring\n");
return bytes;
}
if (bytes < (int) (sizeof(packet.iph) + sizeof(packet.udph))) {
- dbg("\tPacket is too short, ignoring\n");
+ SERR("\tPacket is too short, ignoring\n");
return -2;
}
if (bytes < ntohs(packet.iph.tot_len)) {
- dbg("\tOversized packet, ignoring\n");
+ SERR("\tOversized packet, ignoring\n");
return -2;
}
// ignore any extra garbage bytes
|| packet.iph.ihl != (sizeof(packet.iph) >> 2)
|| packet.udph.dest != htons(DHCPC_CLIENT_PORT)
|| ntohs(packet.udph.len) != (uint16_t)(bytes - sizeof(packet.iph))) {
- dbg("\tUnrelated/bogus packet, ignoring\n");
+ SERR("\tUnrelated/bogus packet, ignoring\n");
return -2;
}
// verify IP checksum
check = packet.iph.check;
packet.iph.check = 0;
if (check != dhcp_checksum(&packet.iph, sizeof(packet.iph))) {
- dbg("\tBad IP header checksum, ignoring\n");
+ SERR("\tBad IP header checksum, ignoring\n");
return -2;
}
memset(&packet.iph, 0, ((size_t) &((struct iphdr *)0)->protocol));
check = packet.udph.check;
packet.udph.check = 0;
if (check && check != dhcp_checksum(&packet, bytes)) {
- dbg("\tPacket with bad UDP checksum received, ignoring\n");
+ SERR("\tPacket with bad UDP checksum received, ignoring\n");
return -2;
}
memcpy(&state->pdhcp, &packet.dhcp, bytes - (sizeof(packet.iph) + sizeof(packet.udph)));
if (state->pdhcp.cookie != htonl(DHCP_MAGIC)) {
- dbg("\tPacket with bad magic, ignoring\n");
+ SERR("\tPacket with bad magic, ignoring\n");
return -2;
}
return bytes - sizeof(packet.iph) - sizeof(packet.udph);
memset(&state->pdhcp, 0, sizeof(dhcp_msg_t));
if ((ret = read(state->sockfd, &state->pdhcp, sizeof(dhcp_msg_t))) < 0) {
- dbg("Packet read error, ignoring\n");
+ SERR("Packet read error, ignoring\n");
return ret; /* returns -1 */
}
if (state->pdhcp.cookie != htonl(DHCP_MAGIC)) {
- dbg("Packet with bad magic, ignoring\n");
+ SERR("Packet with bad magic, ignoring\n");
return -2;
}
return ret;
memcpy(&packet.dhcp, &state->pdhcp, sizeof(dhcp_msg_t));
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
- dbg("SEND RAW: socket failed\n");
+ SERR("SEND RAW: socket failed\n");
return result;
}
memset(&dest_sll, 0, sizeof(dest_sll));
memcpy(dest_sll.sll_addr, bmacaddr , 6);
if (bind(fd, (struct sockaddr *) &dest_sll, sizeof(dest_sll)) < 0) {
- dbg("SEND RAW: bind failed\n");
+ SERR("SEND RAW: bind failed\n");
close(fd);
return result;
}
(struct sockaddr *) &dest_sll, sizeof(dest_sll));
close(fd);
- if (result < 0) dbg("SEND RAW: PACKET send error\n");
+ if (result < 0) SERR("SEND RAW: PACKET send error\n");
return result;
}
int fd, ret = -1;
if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- dbg("SEND APP: sock failed.\n");
+ SERR("SEND APP: sock failed.\n");
return ret;
}
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &set, sizeof(set));
cli.sin_port = htons(DHCPC_CLIENT_PORT);
cli.sin_addr.s_addr = state->pdhcp.ciaddr;
if (bind(fd, (struct sockaddr *)&cli, sizeof(cli)) == -1) {
- dbg("SEND APP: bind failed.\n");
+ SERR("SEND APP: bind failed.\n");
goto error_fd;
}
memset(&cli, 0, sizeof(cli));
cli.sin_port = htons(DHCPC_SERVER_PORT);
cli.sin_addr.s_addr = state->serverid.s_addr;
if (connect(fd, (struct sockaddr *)&cli, sizeof(cli)) == -1) {
- dbg("SEND APP: connect failed.\n");
+ SERR("SEND APP: connect failed.\n");
goto error_fd;
}
int padding = 308 - 1 - dhcp_opt_size(state->pdhcp.options);
if((ret = write(fd, &state->pdhcp, sizeof(dhcp_msg_t) - padding)) < 0) {
- dbg("SEND APP: write failed error %d\n", ret);
+ SERR("SEND APP: write failed error %d\n", ret);
goto error_fd;
}
- dbg("SEND APP: write success wrote %d\n", ret);
+ SERR("SEND APP: write success wrote %d\n", ret);
error_fd:
close(fd);
return ret;
static void signal_handler(int sig)
{
unsigned char ch = sig;
- if (write(sigfd.wr, &ch, 1) != 1) dbg("can't send signal\n");
+ if (write(sigfd.wr, &ch, 1) != 1) SERR("can't send signal\n");
}
// signal setup for SIGUSR1 SIGUSR2 SIGTERM
static int setup_signal()
{
if (pipe((int *)&sigfd) < 0) {
- dbg("signal pipe failed\n");
+ SERR("signal pipe failed\n");
return -1;
}
fcntl(sigfd.wr , F_SETFD, FD_CLOEXEC);
retval = 0;
int maxfd = (sigfd.rd > state->sockfd)? sigfd.rd : state->sockfd;
- dbg("select wait ....\n");
+ SERR("select wait ....\n");
uint32_t timestmp = time(NULL);
if((retval = select(maxfd + 1, &rfds, NULL, NULL, &tv)) < 0) {
if (errno == EINTR) {
goto lease_fail;
case STATE_BOUND:
state->status = STATE_RENEWING;
- dbg("Entering renew state\n");
+ SERR("Entering renew state\n");
// FALLTHROUGH
case STATE_RENEW_REQUESTED: // FALLTHROUGH
case STATE_RENEWING:
waited = 0;
continue;
}
- dbg("Entering rebinding state\n");
+ SERR("Entering rebinding state\n");
state->status = STATE_REBINDING;
// FALLTHROUGH
case STATE_REBINDING:
if (FD_ISSET(sigfd.rd, &rfds)) { // Some Activity on RDFDs : is signal
unsigned char sig;
if (read(sigfd.rd, &sig, 1) != 1) {
- dbg("signal read failed.\n");
+ SERR("signal read failed.\n");
continue;
}
switch (sig) {
}
}
if (FD_ISSET(state->sockfd, &rfds)) { // Some Activity on RDFDs : is socket
- dbg("main sock read\n");
+ SERR("main sock read\n");
uint8_t msgType;
if (state->mode == MODE_RAW) bufflen = read_raw();
if (state->mode == MODE_APP) bufflen = read_app();
waited = 0;
continue;
} else if (msgType == DHCPNAK) {
- dbg("NACK received.\n");
+ SERR("NACK received.\n");
run_script(&result, "nak");
if (state->status != STATE_REQUESTING) run_script(NULL, "deconfig");
mode_raw();
#define FOR_dhcpd
#include "toys.h"
+#include "log.h"
#include <linux/sockios.h>
#include <linux/if_ether.h>
for (i = 32; i; i--)
if ((*(ptr--) = ipv6_addr[i])) if (!(i&3)) *(ptr--) = ':';
- dbg("ipv6 %s\n", ipv6_addr);
+ SERR("ipv6 %s\n", ipv6_addr);
if(inet_pton(AF_INET6, ipv6_addr, &ip6.sin6_addr) <= 0)
error_msg("inet : the ipv6 address is not proper");
else
if (oip) {
xioctl(fd, SIOCGIFADDR, &req);
ip = (struct sockaddr_in*) &req.ifr_addr;
- dbg("IP %s\n", inet_ntoa(ip->sin_addr));
+ SERR("IP %s\n", inet_ntoa(ip->sin_addr));
*oip = ntohl(ip->sin_addr.s_addr);
}
}
if (ifindex) {
xioctl(fd, SIOCGIFINDEX, &req);
- dbg("Adapter index %d\n", req.ifr_ifindex);
+ SERR("Adapter index %d\n", req.ifr_ifindex);
*ifindex = req.ifr_ifindex;
}
if (mac) {
xioctl(fd, SIOCGIFHWADDR, &req);
memcpy(mac, req.ifr_hwaddr.sa_data, 6);
- dbg("MAC %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ SERR("MAC %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}
close(fd);
{
unsigned char ch = sig;
if (write(sigfd.wr, &ch, 1) != 1) {
- dbg("can't send signal\n");
+ SERR("can't send signal\n");
exit(0);
}
}
static int setup_signal()
{
if (pipe((int *)&sigfd) < 0) {
- dbg("signal pipe failed\n");
+ SERR("signal pipe failed\n");
return -1;
}
fcntl(sigfd.wr , F_SETFD, FD_CLOEXEC);
if (!flag || !optcode) return -1;
if (!(valstr = strtok(NULL, " \t"))) {
- dbg("config : option %s has no value defined.\n", option);
+ SERR("config : option %s has no value defined.\n", option);
return -1;
}
- dbg(" value : %-20s : ", valstr);
+ SERR(" value : %-20s : ", valstr);
switch (flag) {
case DHCP_NUM32:
options_list[count].len = sizeof(uint32_t);
if (tcount<=1) goto free_tk0_continue;
for (count = 0; count < size; count++) {
if (!strcmp(confkey[count].keyword,tokens[0])) {
- dbg("got config : %15s : ", confkey[count].keyword);
+ SERR("got config : %15s : ", confkey[count].keyword);
if (confkey[count].handler(tokens[1], confkey[count].var) == 0)
- dbg("%s \n", tokens[1]);
+ SERR("%s \n", tokens[1]);
break;
}
}
if (gstate.listensock > 0) close(gstate.listensock);
- dbg("Opening listen socket on *:%d %s\n", gconfig.port, gconfig.interface);
+ SERR("Opening listen socket on *:%d %s\n", gconfig.port, gconfig.interface);
gstate.listensock = xsocket(PF_INET6, SOCK_DGRAM, 0);
setsockopt(gstate.listensock, SOL_SOCKET, SO_REUSEADDR, &constone, sizeof(constone));
return -1;
}
- dbg("OPEN : success\n");
+ SERR("OPEN : success\n");
return 0;
}
if (gstate.listensock > 0) close(gstate.listensock);
- dbg("Opening listen socket on *:%d %s\n", gconfig.port, gconfig.interface);
+ SERR("Opening listen socket on *:%d %s\n", gconfig.port, gconfig.interface);
gstate.listensock = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
setsockopt(gstate.listensock, SOL_SOCKET, SO_REUSEADDR, &constone, sizeof(constone));
if (setsockopt(gstate.listensock, SOL_SOCKET, SO_BROADCAST, &constone, sizeof(constone)) == -1) {
close(gstate.listensock);
perror_exit("bind failed");
}
- dbg("OPEN : success\n");
+ SERR("OPEN : success\n");
return 0;
}
padding = sizeof(packet.dhcp6.options) - optlen;
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6))) < 0) {
- dbg("SEND : ipv6 socket failed\n");
+ SERR("SEND : ipv6 socket failed\n");
return -1;
}
memset(&dest_sll, 0, sizeof(dest_sll));
memcpy(dest_sll.sll_addr, client_lla, sizeof(client_lla));
if (bind(fd, (struct sockaddr *) &dest_sll, sizeof(dest_sll)) < 0) {
- dbg("SEND : bind failed\n");
+ SERR("SEND : bind failed\n");
close(fd);
return -1;
}
result = sendto(fd, &packet, sizeof(dhcp6_raw_t)-padding,
0, (struct sockaddr *) &dest_sll, sizeof(dest_sll));
- dbg("sendto %d\n", result);
+ SERR("sendto %d\n", result);
close(fd);
- if (result < 0) dbg("PACKET send error\n");
+ if (result < 0) SERR("PACKET send error\n");
return result;
}
memcpy(&packet.dhcp, &gstate.send.send_pkt, sizeof(dhcp_msg_t));
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
- dbg("SEND : socket failed\n");
+ SERR("SEND : socket failed\n");
return -1;
}
memset(&dest_sll, 0, sizeof(dest_sll));
memcpy(dest_sll.sll_addr, (broadcast)?bmacaddr:gstate.rcvd.rcvd_pkt.chaddr , 6);
if (bind(fd, (struct sockaddr *) &dest_sll, sizeof(dest_sll)) < 0) {
- dbg("SEND : bind failed\n");
+ SERR("SEND : bind failed\n");
close(fd);
return -1;
}
result = sendto(fd, &packet, sizeof(dhcp_raw_t) - padding, 0,
(struct sockaddr *) &dest_sll, sizeof(dest_sll));
- dbg("sendto %d\n", result);
+ SERR("sendto %d\n", result);
close(fd);
- if (result < 0) dbg("PACKET send error\n");
+ if (result < 0) SERR("PACKET send error\n");
return result;
}
memset(&gstate.rcvd.rcvd_pkt6, 0, sizeof(dhcp6_msg_t));
ret = read(gstate.listensock, &gstate.rcvd.rcvd_pkt6, sizeof(dhcp6_msg_t));
if (ret < 0) {
- dbg("Packet read error, ignoring. \n");
+ SERR("Packet read error, ignoring. \n");
return ret; // returns -1
}
if (gstate.rcvd.rcvd_pkt6.msgtype < 1) {
- dbg("Bad message type, igroning. \n");
+ SERR("Bad message type, igroning. \n");
return -2;
}
- dbg("Received an ipv6 packet. Size : %d \n", ret);
+ SERR("Received an ipv6 packet. Size : %d \n", ret);
return ret;
}
memset(&gstate.rcvd.rcvd_pkt, 0, sizeof(dhcp_msg_t));
ret = read(gstate.listensock, &gstate.rcvd.rcvd_pkt, sizeof(dhcp_msg_t));
if (ret < 0) {
- dbg("Packet read error, ignoring. \n");
+ SERR("Packet read error, ignoring. \n");
return ret; // returns -1
}
if (gstate.rcvd.rcvd_pkt.cookie != htonl(DHCP_MAGIC)) {
- dbg("Packet with bad magic, ignoring. \n");
+ SERR("Packet with bad magic, ignoring. \n");
return -2;
}
if (gstate.rcvd.rcvd_pkt.op != 1) { //BOOTPREQUEST
- dbg("Not a BOOT REQUEST ignoring. \n");
+ SERR("Not a BOOT REQUEST ignoring. \n");
return -2;
}
if (gstate.rcvd.rcvd_pkt.hlen != 6) {
- dbg("hlen != 6 ignoring. \n");
+ SERR("hlen != 6 ignoring. \n");
return -2;
}
- dbg("Received a packet. Size : %d \n", ret);
+ SERR("Received a packet. Size : %d \n", ret);
return ret;
}
memcpy(&optcode, optptr, sizeof(uint16_t));
memcpy(&len, optptr+2, sizeof(uint16_t));
if(!optcode) {
- dbg("Option %d is not exist.\n", opt);
+ SERR("Option %d is not exist.\n", opt);
return optptr;
}
optcode = ntohs(optcode);
volatile int error = 0;
pid_t pid;
int rv = 0;
- dbg("run_notify");
+ SERR("run_notify");
if (stat(argv[0], &sts) == -1 && errno == ENOENT) {
infomsg(infomode, "notify file: %s : not exist.", argv[0]);
pid = vfork();
if (pid < 0) {
- dbg("Fork failed.\n");
+ SERR("Fork failed.\n");
return;
}
if (!pid) {
}
waitpid(pid, &rv, 0);
errno = error;
- dbg("wait pid (%u) rv (%d)", pid, rv);
+ SERR("wait pid (%u) rv (%d)", pid, rv);
}
static void write_leasefile(void)
msgtype = 0;
int maxfd = (sigfd.rd > gstate.listensock)? sigfd.rd : gstate.listensock;
- dbg("select waiting ....\n");
+ SERR("select waiting ....\n");
if (tv.tv_sec < 0) {
- dbg("timestmp: %u waited: %u tv_sec: %u, reset tv_sec to default value\n", timestmp, waited, tv.tv_sec);
+ SERR("timestmp: %u waited: %u tv_sec: %ld, reset tv_sec to default value\n", timestmp, waited, tv.tv_sec);
waited = 0;
tv.tv_sec = gconfig.auto_time - waited;
tv.tv_usec = 0;
waited += (unsigned) time(NULL) - timestmp;
continue;
}
- dbg("Error in select wait again...\n");
+ SERR("Error in select wait again...\n");
continue;
}
if (!retval) { // Timed out
- dbg("select wait Timed Out...\n");
+ SERR("select wait Timed Out...\n");
waited = 0;
(addr_version==AF_INET6)? write_lease6file() : write_leasefile();
if (get_interface(gconfig.interface, &gconfig.ifindex,
if (FD_ISSET(sigfd.rd, &rfds)) { // Some Activity on RDFDs : is signal
unsigned char sig;
if (read(sigfd.rd, &sig, 1) != 1) {
- dbg("signal read failed.\n");
+ SERR("signal read failed.\n");
continue;
}
switch (sig) {
}
}
if (FD_ISSET(gstate.listensock, &rfds)) { // Some Activity on RDFDs : is socke
- dbg("select listen sock read\n");
+ SERR("select listen sock read\n");
if(addr_version==AF_INET6) {
void *client_duid, *server_duid, *client_ia_na, *server_ia_na,
*client_ia_pd, *server_ia_pd;
if (!gstate.rqcode || gstate.rqcode < DHCP6SOLICIT ||
gstate.rqcode > DHCP6RELAYREPLY) {
- dbg("no or bad message type option, ignoring packet.\n");
+ SERR("no or bad message type option, ignoring packet.\n");
continue;
}
if (!gstate.rcvd.rcvd_pkt6.transaction_id ||
memcmp(gstate.rcvd.rcvd_pkt6.transaction_id, transactionid, 3)) {
- dbg("no or bad transaction id, ignoring packet.\n");
+ SERR("no or bad transaction id, ignoring packet.\n");
continue;
}
waited += time(NULL) - timestmp;
switch (gstate.rqcode) {
case DHCP6SOLICIT:
- dbg("Message Type: DHCP6SOLICIT\n");
+ SERR("Message Type: DHCP6SOLICIT\n");
optptr = prepare_send_pkt6(DHCP6ADVERTISE);
optlen = 0;
write_lease6file();
break;
case DHCP6REQUEST:
- dbg("Message Type: DHCP6REQUEST\n");
+ SERR("Message Type: DHCP6REQUEST\n");
optptr = prepare_send_pkt6(DHCP6REPLY);
optlen = 0;
case DHCP6RENEW: //TODO
case DHCP6REBIND: //TODO
case DHCP6RELEASE:
- dbg("Message Type: DHCP6RELEASE\n");
+ SERR("Message Type: DHCP6RELEASE\n");
optptr = prepare_send_pkt6(DHCP6REPLY);
break;
default:
- dbg("Message Type : %u\n", gstate.rqcode);
+ SERR("Message Type : %u\n", gstate.rqcode);
break;
}
DHCP_OPT_MESSAGE_TYPE, &gstate.rqcode);
if (gstate.rqcode == 0 || gstate.rqcode < DHCPDISCOVER
|| gstate.rqcode > DHCPINFORM) {
- dbg("no or bad message type option, ignoring packet.\n");
+ SERR("no or bad message type option, ignoring packet.\n");
continue;
}
get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
DHCP_OPT_SERVER_ID, &serverid);
if (serverid && (serverid != gconfig.server_nip)) {
- dbg("server ID doesn't match, ignoring packet.\n");
+ SERR("server ID doesn't match, ignoring packet.\n");
continue;
}
switch (gstate.rqcode) {
case DHCPDISCOVER:
msgtype = DHCPOFFER;
- dbg("Message Type : DHCPDISCOVER\n");
+ SERR("Message Type : DHCPDISCOVER\n");
get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
DHCP_OPT_REQUESTED_IP, &requested_nip);
get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
msgtype = DHCPNAK;
optptr = set_optval(optptr, DHCP_OPT_MESSAGE_TYPE, &msgtype, 1);
send_packet(1);
- dbg("Send Message Type : DHCPNAK\n");
+ SERR("Send Message Type : DHCPNAK\n");
break;
}
get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
optptr = set_optval(optptr, DHCP_OPT_LEASE_TIME, &reqested_lease, 4);
optptr = set_reqparam(optptr, gstate.rqopt);
send_packet(1);
- dbg("Send Message Type : DHCPOFFER\n");
+ SERR("Send Message Type : DHCPOFFER\n");
break;
case DHCPREQUEST:
msgtype = DHCPACK;
- dbg("Message Type : DHCPREQUEST\n");
+ SERR("Message Type : DHCPREQUEST\n");
optptr = prepare_send_pkt();
get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
DHCP_OPT_REQUESTED_IP, &requested_nip);
msgtype = DHCPNAK;
optptr = set_optval(optptr, DHCP_OPT_MESSAGE_TYPE, &msgtype, 1);
send_packet(1);
- dbg("Send Message Type : DHCPNAK\n");
+ SERR("Send Message Type : DHCPNAK\n");
break;
}
get_reqparam(&gstate.rqopt);
optptr = set_optval(optptr, DHCP_OPT_LEASE_TIME, &reqested_lease, 4);
optptr = set_reqparam(optptr, gstate.rqopt);
send_packet(1);
- dbg("Send Message Type : DHCPACK\n");
+ SERR("Send Message Type : DHCPACK\n");
write_leasefile();
break;
case DHCPDECLINE:// FALL THROUGH
case DHCPRELEASE:
- dbg("Message Type : DHCPDECLINE or DHCPRELEASE \n");
+ SERR("Message Type : DHCPDECLINE or DHCPRELEASE \n");
get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
DHCP_OPT_SERVER_ID, &serverid);
if (serverid != gconfig.server_nip) break;
(gstate.rqcode==DHCPRELEASE)?0:gconfig.decline_time);
break;
default:
- dbg("Message Type : %u\n", gstate.rqcode);
+ SERR("Message Type : %u\n", gstate.rqcode);
break;
}
}