瀏覽代碼

minor changes

ambrop7 15 年之前
父節點
當前提交
749cc1fe3a

+ 1 - 1
CMakeLists.txt

@@ -32,7 +32,7 @@ link_directories(
 
 test_big_endian(BIG_ENDIAN)
 
-add_definitions(-std=gnu99 -Werror=implicit-function-declaration -Wno-unused-value -Wno-parentheses -Wno-switch-enum)
+add_definitions(-std=gnu99 -Werror=implicit-function-declaration -Wno-unused-value -Wno-parentheses -Wno-switch-enum -Wredundant-decls)
 
 # platform-specific stuff
 if (WIN32)

+ 2 - 0
blog_channels.txt

@@ -13,3 +13,5 @@ Listener 4
 DataProto 4
 FrameDecider 4
 BSocksClient 4
+BHDCPClientCore 4
+BHDCPClient 4

+ 50 - 47
dhcpclient/BDHCPClient.c

@@ -32,16 +32,18 @@
 #include <misc/ethernet_proto.h>
 #include <misc/ipv4_proto.h>
 #include <misc/udp_proto.h>
+#include <system/BLog.h>
 
 #include <dhcpclient/BDHCPClient.h>
 
+#include <generated/blog_channel_BHDCPClient.h>
+
 #define COMPONENT_SOURCE 1
 #define COMPONENT_SINK 2
 
 #define DHCP_SERVER_PORT 67
 #define DHCP_CLIENT_PORT 68
 
-#define ETH_HEADER_LEN sizeof(struct ethernet_header)
 #define IPUDP_OVERHEAD (sizeof(struct ipv4_header) + sizeof(struct udp_header))
 
 static void error_handler (BDHCPClient *o, int component, const void *data)
@@ -50,11 +52,11 @@ static void error_handler (BDHCPClient *o, int component, const void *data)
     
     switch (component) {
         case COMPONENT_SOURCE: {
-            DEBUG("source error");
+            BLog(BLOG_ERROR, "source error");
         } break;
         
         case COMPONENT_SINK: {
-            DEBUG("sink error");
+            BLog(BLOG_ERROR, "sink error");
         } break;
         
         default:
@@ -62,26 +64,26 @@ static void error_handler (BDHCPClient *o, int component, const void *data)
     }
 }
 
-static int bind_to_device (int sock, const char *ifname)
+static void dhcp_handler (BDHCPClient *o, int event)
 {
-    struct ifreq ifr;
-    memset(&ifr, 0, sizeof(ifr));
-    snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname);
-    if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr)) < 0) {
-        return 0;
-    }
+    DebugObject_Access(&o->d_obj);
     
-    return 1;
-}
-
-static int set_broadcast (int sock)
-{
-    int broadcast = 1;
-    if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (void *)&broadcast, sizeof(broadcast)) < 0) {
-        return 0;
+    switch (event) {
+        case BDHCPCLIENTCORE_EVENT_UP:
+            ASSERT(!o->up)
+            o->up = 1;
+            o->handler(o->user, BDHCPCLIENT_EVENT_UP);
+            return;
+            
+        case BDHCPCLIENTCORE_EVENT_DOWN:
+            ASSERT(o->up)
+            o->up = 0;
+            o->handler(o->user, BDHCPCLIENT_EVENT_DOWN);
+            return;
+            
+        default:
+            ASSERT(0);
     }
-    
-    return 1;
 }
 
 static int get_iface_info (const char *ifname, uint8_t *out_mac, int *out_mtu, int *out_ifindex)
@@ -90,7 +92,7 @@ static int get_iface_info (const char *ifname, uint8_t *out_mac, int *out_mtu, i
     
     int s = socket(AF_INET, SOCK_DGRAM, 0);
     if (!s) {
-        DEBUG("socket failed");
+        BLog(BLOG_ERROR, "socket failed");
         goto fail0;
     }
     
@@ -98,11 +100,11 @@ static int get_iface_info (const char *ifname, uint8_t *out_mac, int *out_mtu, i
     memset(&ifr, 0, sizeof(ifr));
     snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname);
     if (ioctl(s, SIOCGIFHWADDR, &ifr)) {
-        DEBUG("ioctl(SIOCGIFHWADDR) failed");
+        BLog(BLOG_ERROR, "ioctl(SIOCGIFHWADDR) failed");
         goto fail1;
     }
     if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
-        DEBUG("hardware address not ethernet");
+        BLog(BLOG_ERROR, "hardware address not ethernet");
         goto fail1;
     }
     memcpy(out_mac, ifr.ifr_hwaddr.sa_data, 6);
@@ -111,7 +113,7 @@ static int get_iface_info (const char *ifname, uint8_t *out_mac, int *out_mtu, i
     memset(&ifr, 0, sizeof(ifr));
     snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname);
     if (ioctl(s, SIOCGIFMTU, &ifr)) {
-        DEBUG("ioctl(SIOCGIFMTU) failed");
+        BLog(BLOG_ERROR, "ioctl(SIOCGIFMTU) failed");
         goto fail1;
     }
     *out_mtu = ifr.ifr_mtu;
@@ -120,7 +122,7 @@ static int get_iface_info (const char *ifname, uint8_t *out_mac, int *out_mtu, i
     memset(&ifr, 0, sizeof(ifr));
     snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname);
     if (ioctl(s, SIOCGIFINDEX, &ifr)) {
-        DEBUG("ioctl(SIOCGIFINDEX) failed");
+        BLog(BLOG_ERROR, "ioctl(SIOCGIFINDEX) failed");
         goto fail1;
     }
     *out_ifindex = ifr.ifr_ifindex;
@@ -135,25 +137,27 @@ fail0:
     return 0;
 }
 
-int BDHCPClient_Init (BDHCPClient *o, const char *ifname, BReactor *reactor, BDHCPClientCore_handler handler, void *user)
+int BDHCPClient_Init (BDHCPClient *o, const char *ifname, BReactor *reactor, BDHCPClient_handler handler, void *user)
 {
     // init arguments
     o->reactor = reactor;
+    o->handler = handler;
+    o->user = user;
     
     // get interface information
     uint8_t if_mac[6];
     int if_mtu;
     int if_index;
     if (!get_iface_info(ifname, if_mac, &if_mtu, &if_index)) {
-        DEBUG("failed to get interface information");
+        BLog(BLOG_ERROR, "failed to get interface information");
         goto fail0;
     }
     
-    DEBUG("if_mac=%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8" if_mtu=%d if_index=%d",
+    BLog(BLOG_INFO, "if_mac=%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8" if_mtu=%d if_index=%d",
           if_mac[0], if_mac[1], if_mac[2], if_mac[3], if_mac[4], if_mac[5], if_mtu, if_index);
     
     if (if_mtu < IPUDP_OVERHEAD) {
-        DEBUG("MTU is too small for UDP/IP !?!");
+        BLog(BLOG_ERROR, "MTU is too small for UDP/IP !?!");
         goto fail0;
     }
     
@@ -161,27 +165,15 @@ int BDHCPClient_Init (BDHCPClient *o, const char *ifname, BReactor *reactor, BDH
     
     // init socket
     if (BSocket_Init(&o->sock, o->reactor, BADDR_TYPE_PACKET, BSOCKET_TYPE_DGRAM) < 0) {
-        DEBUG("BSocket_Init failed");
+        BLog(BLOG_ERROR, "BSocket_Init failed");
         goto fail0;
     }
     
-    // set socket broadcast
-    if (!set_broadcast(o->sock.socket)) {
-        DEBUG("set_broadcast failed");
-        goto fail1;
-    }
-    
-    // bind socket to device
-    if (!bind_to_device(o->sock.socket, ifname)) {
-        DEBUG("bind_to_device failed");
-        goto fail1;
-    }
-    
     // bind socket
     BAddr bind_addr;
     BAddr_InitPacket(&bind_addr, hton16(ETHERTYPE_IPV4), if_index, BADDR_PACKET_HEADER_TYPE_ETHERNET, BADDR_PACKET_PACKET_TYPE_HOST, if_mac);
     if (BSocket_Bind(&o->sock, &bind_addr) < 0) {
-        DEBUG("BSocket_Bind failed");
+        BLog(BLOG_ERROR, "BSocket_Bind failed");
         goto fail1;
     }
     
@@ -206,7 +198,7 @@ int BDHCPClient_Init (BDHCPClient *o, const char *ifname, BReactor *reactor, BDH
     
     // init buffer
     if (!SinglePacketBuffer_Init(&o->send_buffer, DHCPIpUdpEncoder_GetOutput(&o->send_encoder), DatagramSocketSink_GetInput(&o->send_sink), BReactor_PendingGroup(o->reactor))) {
-        DEBUG("SinglePacketBuffer_Init failed");
+        BLog(BLOG_ERROR, "SinglePacketBuffer_Init failed");
         goto fail2;
     }
     
@@ -223,16 +215,19 @@ int BDHCPClient_Init (BDHCPClient *o, const char *ifname, BReactor *reactor, BDH
     
     // init buffer
     if (!SinglePacketBuffer_Init(&o->recv_buffer, DatagramSocketSource_GetOutput(&o->recv_source), DHCPIpUdpDecoder_GetInput(&o->recv_decoder), BReactor_PendingGroup(o->reactor))) {
-        DEBUG("SinglePacketBuffer_Init failed");
+        BLog(BLOG_ERROR, "SinglePacketBuffer_Init failed");
         goto fail3;
     }
     
     // init dhcp
-    if (!BDHCPClientCore_Init(&o->dhcp, PacketCopier_GetInput(&o->send_copier), PacketCopier_GetOutput(&o->recv_copier), if_mac, o->reactor, handler, user)) {
-        DEBUG("BDHCPClientCore_Init failed");
+    if (!BDHCPClientCore_Init(&o->dhcp, PacketCopier_GetInput(&o->send_copier), PacketCopier_GetOutput(&o->recv_copier), if_mac, o->reactor, (BDHCPClientCore_handler)dhcp_handler, o)) {
+        BLog(BLOG_ERROR, "BDHCPClientCore_Init failed");
         goto fail4;
     }
     
+    // set not up
+    o->up = 0;
+    
     DebugObject_Init(&o->d_obj);
     
     return 1;
@@ -279,20 +274,28 @@ void BDHCPClient_Free (BDHCPClient *o)
 
 void BDHCPClient_GetClientIP (BDHCPClient *o, uint32_t *out_ip)
 {
+    ASSERT(o->up)
+    
     BDHCPClientCore_GetClientIP(&o->dhcp, out_ip);
 }
 
 void BDHCPClient_GetClientMask (BDHCPClient *o, uint32_t *out_mask)
 {
+    ASSERT(o->up)
+    
     BDHCPClientCore_GetClientMask(&o->dhcp, out_mask);
 }
 
 int BDHCPClient_GetRouter (BDHCPClient *o, uint32_t *out_router)
 {
+    ASSERT(o->up)
+    
     return BDHCPClientCore_GetRouter(&o->dhcp, out_router);
 }
 
 int BDHCPClient_GetDNS (BDHCPClient *o, uint32_t *out_dns_servers, size_t max_dns_servers)
 {
+    ASSERT(o->up)
+    
     return BDHCPClientCore_GetDNS(&o->dhcp, out_dns_servers, max_dns_servers);
 }

+ 11 - 4
dhcpclient/BDHCPClient.h

@@ -37,26 +37,33 @@
 #include <dhcpclient/DHCPIpUdpDecoder.h>
 #include <dhcpclient/DHCPIpUdpEncoder.h>
 
+#define BDHCPCLIENT_EVENT_UP 1
+#define BDHCPCLIENT_EVENT_DOWN 2
+
+#define BDHCPCLIENT_MAX_DOMAIN_NAME_SERVERS BDHCPCLIENTCORE_MAX_DOMAIN_NAME_SERVERS
+
+typedef void (*BDHCPClient_handler) (void *user, int event);
+
 typedef struct {
     BReactor *reactor;
     BSocket sock;
+    BDHCPClient_handler handler;
+    void *user;
     FlowErrorDomain domain;
-    
     PacketCopier send_copier;
     DHCPIpUdpEncoder send_encoder;
     SinglePacketBuffer send_buffer;
     DatagramSocketSink send_sink;
-    
     DatagramSocketSource recv_source;
     SinglePacketBuffer recv_buffer;
     DHCPIpUdpDecoder recv_decoder;
     PacketCopier recv_copier;
-    
     BDHCPClientCore dhcp;
+    int up;
     DebugObject d_obj;
 } BDHCPClient;
 
-int BDHCPClient_Init (BDHCPClient *o, const char *ifname, BReactor *reactor, BDHCPClientCore_handler handler, void *user);
+int BDHCPClient_Init (BDHCPClient *o, const char *ifname, BReactor *reactor, BDHCPClient_handler handler, void *user);
 void BDHCPClient_Free (BDHCPClient *o);
 void BDHCPClient_GetClientIP (BDHCPClient *o, uint32_t *out_ip);
 void BDHCPClient_GetClientMask (BDHCPClient *o, uint32_t *out_mask);

+ 36 - 5
dhcpclient/BDHCPClientCore.c

@@ -26,14 +26,19 @@
 #include <misc/byteorder.h>
 #include <misc/minmax.h>
 #include <security/BRandom.h>
+#include <system/BLog.h>
 
 #include <dhcpclient/BDHCPClientCore.h>
 
+#include <generated/blog_channel_BHDCPClientCore.h>
+
 #define RESET_TIMEOUT 10000
 #define REQUEST_TIMEOUT 3000
 #define RENEW_REQUEST_TIMEOUT 20000
-
 #define MAX_REQUESTS 4
+#define RENEW_TIMEOUT(lease) ((btime_t)500 * (lease))
+
+#define LEASE_TIMEOUT(lease) ((btime_t)1000 * (lease) - RENEW_TIMEOUT(lease))
 
 #define STATE_RESETTING 1
 #define STATE_SENT_DISCOVER 2
@@ -66,7 +71,7 @@ static void send_message (
     ASSERT(type == DHCP_MESSAGE_TYPE_DISCOVER || type == DHCP_MESSAGE_TYPE_REQUEST)
     
     if (o->sending) {
-        DEBUG("already sending!");
+        BLog(BLOG_ERROR, "already sending");
         return;
     }
     
@@ -335,6 +340,8 @@ static void recv_handler_done (BDHCPClientCore *o, int data_len)
         }
         
         if (o->state == STATE_SENT_REQUEST) {
+            BLog(BLOG_INFO, "received NAK (in sent request)");
+            
             // stop request timer
             BReactor_RemoveTimer(o->reactor, &o->request_timer);
             
@@ -345,6 +352,8 @@ static void recv_handler_done (BDHCPClientCore *o, int data_len)
             o->state = STATE_RESETTING;
         }
         else if (o->state == STATE_FINISHED) {
+            BLog(BLOG_INFO, "received NAK (in finished)");
+            
             // stop renew timer
             BReactor_RemoveTimer(o->reactor, &o->renew_timer);
             
@@ -359,6 +368,8 @@ static void recv_handler_done (BDHCPClientCore *o, int data_len)
             return;
         }
         else { // STATE_RENEWING
+            BLog(BLOG_INFO, "received NAK (in renewing)");
+            
             // stop renew request timer
             BReactor_RemoveTimer(o->reactor, &o->renew_request_timer);
             
@@ -392,6 +403,8 @@ static void recv_handler_done (BDHCPClientCore *o, int data_len)
     }
     
     if (o->state == STATE_SENT_DISCOVER && dhcp_message_type == DHCP_MESSAGE_TYPE_OFFER) {
+        BLog(BLOG_INFO, "received OFFER");
+        
         // remember offer
         o->offered.yiaddr = o->recv_buf->yiaddr;
         o->offered.dhcp_server_identifier = dhcp_server_identifier;
@@ -420,6 +433,8 @@ static void recv_handler_done (BDHCPClientCore *o, int data_len)
             return;
         }
         
+        BLog(BLOG_INFO, "received ACK (in sent request)");
+        
         // remember stuff
         o->acked.ip_address_lease_time = ip_address_lease_time;
         o->acked.subnet_mask = subnet_mask;
@@ -434,7 +449,7 @@ static void recv_handler_done (BDHCPClientCore *o, int data_len)
         BReactor_RemoveTimer(o->reactor, &o->request_timer);
         
         // start renew timer
-        BReactor_SetTimerAfter(o->reactor, &o->renew_timer, 500 * o->acked.ip_address_lease_time);
+        BReactor_SetTimerAfter(o->reactor, &o->renew_timer, RENEW_TIMEOUT(o->acked.ip_address_lease_time));
         
         // set state
         o->state = STATE_FINISHED;
@@ -454,6 +469,8 @@ static void recv_handler_done (BDHCPClientCore *o, int data_len)
         
         // TODO: check parameters?
         
+        BLog(BLOG_INFO, "received ACK (in renewing)");
+        
         // remember stuff
         o->acked.ip_address_lease_time = ip_address_lease_time;
         
@@ -464,7 +481,7 @@ static void recv_handler_done (BDHCPClientCore *o, int data_len)
         BReactor_RemoveTimer(o->reactor, &o->lease_timer);
         
         // start renew timer
-        BReactor_SetTimerAfter(o->reactor, &o->renew_timer, 500 * o->acked.ip_address_lease_time);
+        BReactor_SetTimerAfter(o->reactor, &o->renew_timer, RENEW_TIMEOUT(o->acked.ip_address_lease_time));
         
         // set state
         o->state = STATE_FINISHED;
@@ -491,6 +508,8 @@ static void reset_timer_handler (BDHCPClientCore *o)
     ASSERT(o->state == STATE_RESETTING || o->state == STATE_SENT_DISCOVER)
     DebugObject_Access(&o->d_obj);
     
+    BLog(BLOG_INFO, "reset timer");
+    
     start_process(o);
 }
 
@@ -503,10 +522,14 @@ static void request_timer_handler (BDHCPClientCore *o)
     
     // if we have sent enough requests, start again
     if (o->request_count == MAX_REQUESTS) {
+        BLog(BLOG_INFO, "request timer, aborting");
+        
         start_process(o);
         return;
     }
     
+    BLog(BLOG_INFO, "request timer, retrying");
+    
     // send request
     send_message(o, DHCP_MESSAGE_TYPE_REQUEST, o->xid, 1, o->offered.yiaddr, 1, o->offered.dhcp_server_identifier);
     
@@ -522,6 +545,8 @@ static void renew_timer_handler (BDHCPClientCore *o)
     ASSERT(o->state == STATE_FINISHED)
     DebugObject_Access(&o->d_obj);
     
+    BLog(BLOG_INFO, "renew timer");
+    
     // send request
     send_message(o, DHCP_MESSAGE_TYPE_REQUEST, o->xid, 1, o->offered.yiaddr, 0, 0);
     
@@ -529,7 +554,7 @@ static void renew_timer_handler (BDHCPClientCore *o)
     BReactor_SetTimer(o->reactor, &o->renew_request_timer);
     
     // start lease timer
-    BReactor_SetTimerAfter(o->reactor, &o->lease_timer, 500 * o->acked.ip_address_lease_time);
+    BReactor_SetTimerAfter(o->reactor, &o->lease_timer, LEASE_TIMEOUT(o->acked.ip_address_lease_time));
     
     // set state
     o->state = STATE_RENEWING;
@@ -540,6 +565,8 @@ static void renew_request_timer_handler (BDHCPClientCore *o)
     ASSERT(o->state == STATE_RENEWING)
     DebugObject_Access(&o->d_obj);
     
+    BLog(BLOG_INFO, "renew request timer");
+    
     // send request
     send_message(o, DHCP_MESSAGE_TYPE_REQUEST, o->xid, 1, o->offered.yiaddr, 0, 0);
     
@@ -552,6 +579,8 @@ static void lease_timer_handler (BDHCPClientCore *o)
     ASSERT(o->state == STATE_RENEWING)
     DebugObject_Access(&o->d_obj);
     
+    BLog(BLOG_INFO, "lease timer");
+    
     // stop renew request timer
     BReactor_RemoveTimer(o->reactor, &o->renew_request_timer);
     
@@ -578,9 +607,11 @@ int BDHCPClientCore_Init (BDHCPClientCore *o, PacketPassInterface *send_if, Pack
     
     // allocate buffers
     if (!(o->send_buf = malloc(PacketPassInterface_GetMTU(send_if)))) {
+        BLog(BLOG_ERROR, "malloc send buf failed");
         goto fail0;
     }
     if (!(o->recv_buf = malloc(PacketRecvInterface_GetMTU(recv_if)))) {
+        BLog(BLOG_ERROR, "malloc recv buf failed");
         goto fail1;
     }
     

+ 1 - 1
dhcpclient/BDHCPClientCore.h

@@ -21,7 +21,7 @@
  * 
  * @section DESCRIPTION
  * 
- * DHCP client, without I/O details.
+ * DHCP client, excluding system-dependent details.
  */
 
 #ifndef BADVPN_DHCPCLIENT_BDHCPCLIENTCORE_H

+ 0 - 7
dhcpclient/DHCPIpUdpDecoder.c

@@ -46,38 +46,31 @@ static void input_handler_send (DHCPIpUdpDecoder *o, uint8_t *data, int data_len
     int pl_len;
     
     if (!ipv4_check(data, data_len, &iph, &pl, &pl_len)) {
-        DEBUG("ipv4_check failed");
         return;
     }
     
     if (ntoh8(iph->protocol) != IPV4_PROTOCOL_UDP) {
-        DEBUG("not UDP");
         return;
     }
     
     if (pl_len < sizeof(struct udp_header)) {
-        DEBUG("no UDP header");
         return;
     }
     struct udp_header *udph = (void *)pl;
     
     if (ntoh16(udph->source_port) != DHCP_SERVER_PORT) {
-        DEBUG("wrong source port");
         return;
     }
     
     if (ntoh16(udph->dest_port) != DHCP_CLIENT_PORT) {
-        DEBUG("wrong dest port");
         return;
     }
     
     int udph_length = ntoh16(udph->length);
     if (udph_length < sizeof(*udph)) {
-        DEBUG("udp length too small");
         return;
     }
     if (udph_length > data_len - (pl - data)) {
-        DEBUG("udp length too big");
         return;
     }
     

+ 4 - 9
examples/dhcpclient_test.c

@@ -113,15 +113,10 @@ void signal_handler (void *user)
     terminate(1);
 }
 
-void BDHCPClient_GetClientIP (BDHCPClient *o, uint32_t *out_ip);
-void BDHCPClient_GetClientMask (BDHCPClient *o, uint32_t *out_mask);
-int BDHCPClient_GetRouter (BDHCPClient *o, uint32_t *out_router);
-int BDHCPClient_GetDNS (BDHCPClient *o, uint32_t *out_dns_servers, size_t max_dns_servers);
-
 void dhcp_handler (void *unused, int event)
 {
     switch (event) {
-        case BDHCPCLIENTCORE_EVENT_UP: {
+        case BDHCPCLIENT_EVENT_UP: {
             printf("DHCP: up");
             
             uint32_t ip;
@@ -137,8 +132,8 @@ void dhcp_handler (void *unused, int event)
                 printf(" Router=%"PRIu8".%"PRIu8".%"PRIu8".%"PRIu8, ipb[0], ipb[1], ipb[2], ipb[3]);
             }
             
-            uint32_t dns[BDHCPCLIENTCORE_MAX_DOMAIN_NAME_SERVERS];
-            int num = BDHCPClient_GetDNS(&dhcp, dns, BDHCPCLIENTCORE_MAX_DOMAIN_NAME_SERVERS);
+            uint32_t dns[BDHCPCLIENT_MAX_DOMAIN_NAME_SERVERS];
+            int num = BDHCPClient_GetDNS(&dhcp, dns, BDHCPCLIENT_MAX_DOMAIN_NAME_SERVERS);
             for (int i = 0; i < num; i++) {
                 ip=dns[i];
                 printf(" DNS=%"PRIu8".%"PRIu8".%"PRIu8".%"PRIu8, ipb[0], ipb[1], ipb[2], ipb[3]);
@@ -147,7 +142,7 @@ void dhcp_handler (void *unused, int event)
             printf("\n");
         } break;
         
-        case BDHCPCLIENTCORE_EVENT_DOWN: {
+        case BDHCPCLIENT_EVENT_DOWN: {
             printf("DHCP: down\n");
         } break;
         

+ 4 - 0
generated/blog_channel_BHDCPClient.h

@@ -0,0 +1,4 @@
+#ifdef BLOG_CURRENT_CHANNEL
+#undef BLOG_CURRENT_CHANNEL
+#endif
+#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BHDCPClient

+ 4 - 0
generated/blog_channel_BHDCPClientCore.h

@@ -0,0 +1,4 @@
+#ifdef BLOG_CURRENT_CHANNEL
+#undef BLOG_CURRENT_CHANNEL
+#endif
+#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BHDCPClientCore

+ 3 - 1
generated/blog_channels_defines.h

@@ -13,4 +13,6 @@
 #define BLOG_CHANNEL_DataProto 12
 #define BLOG_CHANNEL_FrameDecider 13
 #define BLOG_CHANNEL_BSocksClient 14
-#define BLOG_NUM_CHANNELS 15
+#define BLOG_CHANNEL_BHDCPClientCore 15
+#define BLOG_CHANNEL_BHDCPClient 16
+#define BLOG_NUM_CHANNELS 17

+ 2 - 0
generated/blog_channels_list.h

@@ -13,3 +13,5 @@
 {.name = "DataProto", .loglevel = 4},
 {.name = "FrameDecider", .loglevel = 4},
 {.name = "BSocksClient", .loglevel = 4},
+{.name = "BHDCPClientCore", .loglevel = 4},
+{.name = "BHDCPClient", .loglevel = 4},