diff --git a/ports/linux/bip6.c b/ports/linux/bip6.c index ec0ba002..c100d106 100644 --- a/ports/linux/bip6.c +++ b/ports/linux/bip6.c @@ -40,24 +40,52 @@ #include "bacnet/bacdcode.h" #include "bacnet/config.h" #include "bacnet/datalink/bip6.h" -#include "bacnet/basic/sys/debug.h" #include "bacnet/basic/object/device.h" #include "bacnet/basic/bbmd6/h_bbmd6.h" #include "bacport.h" +/* enable debugging */ +static bool BIP6_Debug = false; +#if PRINT_ENABLED +#include +#include +#define PRINTF(...) \ + if (BIP6_Debug) { \ + fprintf(stderr,__VA_ARGS__); \ + fflush(stderr); \ + } +#else +#define PRINTF(...) +#endif + +/** + * @brief Print the IPv6 address with debug info + * @param str - debug info string + * @param addr - IPv4 address + */ static void debug_print_ipv6(const char *str, const struct in6_addr *addr) { - debug_printf("BIP6: %s " - "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%" - "02x:%02x%02x\n", + PRINTF("BIP6: %s " + "%02x%02x:%02x%02x:%02x%02x:%02x%02x:" + "%02x%02x:%02x%02x:%02x%02x:%02x%02x\n", str, (int)addr->s6_addr[0], (int)addr->s6_addr[1], - (int)addr->s6_addr[2], (int)addr->s6_addr[3], (int)addr->s6_addr[4], - (int)addr->s6_addr[5], (int)addr->s6_addr[6], (int)addr->s6_addr[7], - (int)addr->s6_addr[8], (int)addr->s6_addr[9], (int)addr->s6_addr[10], - (int)addr->s6_addr[11], (int)addr->s6_addr[12], (int)addr->s6_addr[13], + (int)addr->s6_addr[2], (int)addr->s6_addr[3], + (int)addr->s6_addr[4], (int)addr->s6_addr[5], + (int)addr->s6_addr[6], (int)addr->s6_addr[7], + (int)addr->s6_addr[8], (int)addr->s6_addr[9], + (int)addr->s6_addr[10], (int)addr->s6_addr[11], + (int)addr->s6_addr[12], (int)addr->s6_addr[13], (int)addr->s6_addr[14], (int)addr->s6_addr[15]); } +/** + * @brief Enabled debug printing of BACnet/IPv4 + */ +void bip6_debug_enable(void) +{ + BIP6_Debug = true; +} + /** @file linux/bip6.c Initializes BACnet/IPv6 interface (Linux). */ /* unix socket */ @@ -82,10 +110,12 @@ void bip6_set_interface(char *ifname) exit(1); } ifa_tmp = ifa; - debug_printf("BIP6: seeking interface: %s\n", ifname); + if (BIP6_Debug) { + PRINTF("BIP6: seeking interface: %s\n", ifname); + } while (ifa_tmp) { if ((ifa_tmp->ifa_addr) && (ifa_tmp->ifa_addr->sa_family == AF_INET6)) { - debug_printf("BIP6: found interface: %s\n", ifa_tmp->ifa_name); + PRINTF("BIP6: found interface: %s\n", ifa_tmp->ifa_name); } if ((ifa_tmp->ifa_addr) && (ifa_tmp->ifa_addr->sa_family == AF_INET6) && (strcasecmp(ifa_tmp->ifa_name, ifname) == 0)) { @@ -105,7 +135,7 @@ void bip6_set_interface(char *ifname) ifa_tmp = ifa_tmp->ifa_next; } if (!found) { - debug_printf("BIP6: unable to set interface: %s\n", ifname); + PRINTF("BIP6: unable to set interface: %s\n", ifname); exit(1); } } @@ -350,6 +380,7 @@ uint16_t bip6_receive( */ void bip6_cleanup(void) { + bvlc6_cleanup(); if (BIP6_Socket != -1) { close(BIP6_Socket); } @@ -391,7 +422,7 @@ bool bip6_init(char *ifname) if (BIP6_Addr.port == 0) { bip6_set_port(0xBAC0U); } - debug_printf("BIP6: IPv6 UDP port: 0x%04X\n", htons(BIP6_Addr.port)); + PRINTF("BIP6: IPv6 UDP port: 0x%04X\n", htons(BIP6_Addr.port)); if (BIP6_Broadcast_Addr.address[0] == 0) { bvlc6_address_set(&BIP6_Broadcast_Addr, BIP6_MULTICAST_SITE_LOCAL, 0, 0, 0, 0, 0, 0, BIP6_MULTICAST_GROUP_ID); diff --git a/ports/win32/bip6.c b/ports/win32/bip6.c index 8496bcb0..336d92eb 100644 --- a/ports/win32/bip6.c +++ b/ports/win32/bip6.c @@ -50,9 +50,28 @@ static SOCKET BIP6_Socket = INVALID_SOCKET; static BACNET_IP6_ADDRESS BIP6_Addr; static BACNET_IP6_ADDRESS BIP6_Broadcast_Addr; +/* enable debugging */ +static bool BIP6_Debug = false; +#if PRINT_ENABLED +#include +#include +#define PRINTF(...) \ + if (BIP6_Debug) { \ + fprintf(stderr,__VA_ARGS__); \ + fflush(stderr); \ + } +#else +#define PRINTF(...) +#endif + +/** + * @brief Print the IPv6 address with debug info + * @param str - debug info string + * @param addr - IPv4 address + */ static void debug_print_ipv6(const char *str, const struct in6_addr *addr) { - debug_printf("BIP6: %s " + PRINTF("BIP6: %s " "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%" "02x:%02x%02x\n", str, (int)addr->s6_addr[0], (int)addr->s6_addr[1], @@ -63,6 +82,14 @@ static void debug_print_ipv6(const char *str, const struct in6_addr *addr) (int)addr->s6_addr[14], (int)addr->s6_addr[15]); } +/** + * @brief Enabled debug printing of BACnet/IPv4 + */ +void bip6_debug_enable(void) +{ + BIP6_Debug = true; +} + static LPSTR PrintError(int ErrorCode) { static char Message[1024]; @@ -104,7 +131,7 @@ void bip6_set_interface(char *ifname) Hints.ai_protocol = IPPROTO_UDP; Hints.ai_flags = AI_NUMERICHOST | AI_PASSIVE; snprintf(port, sizeof(port), "%u", BIP6_Addr.port); - debug_printf("BIP6: getaddrinfo - IPv6 address %s port %s\n", ifname, port); + PRINTF("BIP6: getaddrinfo - IPv6 address %s port %s\n", ifname, port); RetVal = getaddrinfo(ifname, &port[0], &Hints, &AddrInfo); if (RetVal != 0) { fprintf(stderr, "BIP6: getaddrinfo failed with error %d: %s\n", RetVal, @@ -512,7 +539,7 @@ bool bip6_init(char *ifname) if (BIP6_Addr.port == 0) { bip6_set_port(0xBAC0U); } - debug_printf("BIP6: IPv6 UDP port: 0x%04X\n", BIP6_Addr.port); + PRINTF("BIP6: IPv6 UDP port: 0x%04X\n", BIP6_Addr.port); bip6_set_interface(ifname); if (BIP6_Broadcast_Addr.address[0] == 0) { bvlc6_address_set(&BIP6_Broadcast_Addr, BIP6_MULTICAST_LINK_LOCAL, 0, 0, diff --git a/src/bacnet/basic/bbmd6/h_bbmd6.c b/src/bacnet/basic/bbmd6/h_bbmd6.c index d5786387..ba13c91b 100644 --- a/src/bacnet/basic/bbmd6/h_bbmd6.c +++ b/src/bacnet/basic/bbmd6/h_bbmd6.c @@ -44,6 +44,20 @@ #include "bacnet/basic/bbmd6/vmac.h" #include "bacnet/basic/bbmd6/h_bbmd6.h" + +static bool BVLC6_Debug; +#if PRINT_ENABLED +#include +#include +#define PRINTF(...) \ + if (BVLC6_Debug) { \ + fprintf(stderr,__VA_ARGS__); \ + fflush(stderr); \ + } +#else +#define PRINTF(...) +#endif + /** result from a client request */ static uint16_t BVLC6_Result_Code = BVLC6_RESULT_SUCCESSFUL_COMPLETION; /** incoming function */ @@ -68,6 +82,15 @@ static BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY static BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY FD_Table[MAX_FD6_ENTRIES]; #endif +/** + * @brief Enable debugging if print is enabled + */ +void bvlc6_debug_enable(void) +{ + BVLC6_Debug = true; + VMAC_Debug_Enable(); +} + /** A timer function that is called about once a second. * * @param seconds - number of elapsed seconds since the last call @@ -163,10 +186,21 @@ static bool bbmd6_add_vmac(uint32_t device_id, BACNET_IP6_ADDRESS *addr) vmac = VMAC_Find_By_Key(device_id); if (vmac) { /* already exists - replace? */ + PRINTF("VMAC existing %u [", (unsigned int)device_id); + for (unsigned i = 0; i < vmac->mac_len; i++) { + PRINTF("%02X", vmac->mac[i]); + } + PRINTF("]\n"); + PRINTF("VMAC ignoring %u [", (unsigned int)device_id); + for (unsigned i = 0; i < IP6_ADDRESS_MAX; i++) { + PRINTF("%02X", addr->address[i]); + } + PRINTF("%04X", addr->port); + PRINTF("]\n"); } else if (bbmd6_address_to_vmac(&new_vmac, addr)) { /* new entry - add it! */ status = VMAC_Add(device_id, &new_vmac); - debug_printf("BVLC6: Adding VMAC %lu.\n", (unsigned long)device_id); + PRINTF("BVLC6: Adding VMAC %lu.\n", (unsigned long)device_id); } } @@ -216,7 +250,7 @@ static bool bbmd6_address_from_bacnet_address( if (status) { vmac = VMAC_Find_By_Key(device_id); if (vmac) { - debug_printf("BVLC6: Found VMAC %lu (len=%u).\n", + PRINTF("BVLC6: Found VMAC %lu (len=%u).\n", (unsigned long)device_id, (unsigned)vmac->mac_len); status = bbmd6_address_from_vmac(addr, vmac); if (vmac_src) { @@ -264,13 +298,13 @@ int bvlc6_send_pdu(BACNET_ADDRESS *dest, vmac_src = Device_Object_Instance_Number(); mtu_len = bvlc6_encode_distribute_broadcast_to_network( mtu, sizeof(mtu), vmac_src, pdu, pdu_len); - debug_printf("BVLC6: Sent Distribute-Broadcast-to-Network.\n"); + PRINTF("BVLC6: Sent Distribute-Broadcast-to-Network.\n"); } else { bip6_get_broadcast_addr(&bvlc_dest); vmac_src = Device_Object_Instance_Number(); mtu_len = bvlc6_encode_original_broadcast( mtu, sizeof(mtu), vmac_src, pdu, pdu_len); - debug_printf("BVLC6: Sent Original-Broadcast-NPDU.\n"); + PRINTF("BVLC6: Sent Original-Broadcast-NPDU.\n"); } } else if ((dest->net > 0) && (dest->len == 0)) { /* net > 0 and net < 65535 are network specific broadcast if len = 0 */ @@ -283,17 +317,17 @@ int bvlc6_send_pdu(BACNET_ADDRESS *dest, vmac_src = Device_Object_Instance_Number(); mtu_len = bvlc6_encode_original_broadcast( mtu, sizeof(mtu), vmac_src, pdu, pdu_len); - debug_printf("BVLC6: Sent Original-Broadcast-NPDU.\n"); + PRINTF("BVLC6: Sent Original-Broadcast-NPDU.\n"); } else if (dest->mac_len == 3) { /* valid unicast */ bbmd6_address_from_bacnet_address(&bvlc_dest, &vmac_dst, dest); - debug_printf("BVLC6: Sending to VMAC %lu.\n", (unsigned long)vmac_dst); + PRINTF("BVLC6: Sending to VMAC %lu.\n", (unsigned long)vmac_dst); vmac_src = Device_Object_Instance_Number(); mtu_len = bvlc6_encode_original_unicast( mtu, sizeof(mtu), vmac_src, vmac_dst, pdu, pdu_len); - debug_printf("BVLC6: Sent Original-Unicast-NPDU.\n"); + PRINTF("BVLC6: Sent Original-Unicast-NPDU.\n"); } else { - debug_printf("BVLC6: Send failure. Invalid Address.\n"); + PRINTF("BVLC6: Send failure. Invalid Address.\n"); return -1; } @@ -479,7 +513,7 @@ static void bbmd6_virtual_address_resolution_handler( uint32_t vmac_me = 0; if (addr && pdu) { - debug_printf("BIP6: Received Virtual-Address-Resolution.\n"); + PRINTF("BIP6: Received Virtual-Address-Resolution.\n"); if (bbmd6_address_match_self(addr)) { /* ignore messages from my IPv6 address */ } else { @@ -513,7 +547,7 @@ static void bbmd6_virtual_address_resolution_ack_handler( uint32_t vmac_dst = 0; if (addr && pdu) { - debug_printf("BIP6: Received Virtual-Address-Resolution-ACK.\n"); + PRINTF("BIP6: Received Virtual-Address-Resolution-ACK.\n"); if (bbmd6_address_match_self(addr)) { /* ignore messages from my IPv6 address */ } else { @@ -542,7 +576,7 @@ static void bbmd6_address_resolution_handler( uint32_t vmac_me = 0; if (addr && pdu) { - debug_printf("BIP6: Received Address-Resolution.\n"); + PRINTF("BIP6: Received Address-Resolution.\n"); if (bbmd6_address_match_self(addr)) { /* ignore messages from my IPv6 address */ } else { @@ -577,7 +611,7 @@ static void bbmd6_address_resolution_ack_handler( uint32_t vmac_dst = 0; if (addr && pdu) { - debug_printf("BIP6: Received Address-Resolution-ACK.\n"); + PRINTF("BIP6: Received Address-Resolution-ACK.\n"); if (bbmd6_address_match_self(addr)) { /* ignore messages from my IPv6 address */ } else { @@ -638,7 +672,7 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr, incoming messages. */ bbmd6_add_vmac(vmac_src, addr); bvlc6_vmac_address_set(src, vmac_src); - debug_printf( + PRINTF( "BIP6: Received Result Code=%d\n", BVLC6_Result_Code); } break; @@ -657,10 +691,10 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr, case BVLC6_ORIGINAL_UNICAST_NPDU: /* This message is used to send directed NPDUs to another B/IPv6 node or router. */ - debug_printf("BIP6: Received Original-Unicast-NPDU.\n"); + PRINTF("BIP6: Received Original-Unicast-NPDU.\n"); if (bbmd6_address_match_self(addr)) { /* ignore messages from my IPv6 address */ - debug_printf("BIP6: Original-Unicast-NPDU is me!.\n"); + PRINTF("BIP6: Original-Unicast-NPDU is me!.\n"); } else { function_len = bvlc6_decode_original_unicast( pdu, pdu_len, &vmac_src, &vmac_dst, NULL, 0, &npdu_len); @@ -673,20 +707,20 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr, bvlc6_vmac_address_set(src, vmac_src); offset = header_len + (function_len - npdu_len); } else { - debug_printf("BIP6: Original-Unicast-NPDU: " + PRINTF("BIP6: Original-Unicast-NPDU: " "VMAC is not me!\n"); } } else { - debug_printf( + PRINTF( "BIP6: Original-Unicast-NPDU: Unable to decode!\n"); } } break; case BVLC6_ORIGINAL_BROADCAST_NPDU: - debug_printf("BIP6: Received Original-Broadcast-NPDU.\n"); + PRINTF("BIP6: Received Original-Broadcast-NPDU.\n"); if (bbmd6_address_match_self(addr)) { /* ignore messages from my IPv6 address */ - debug_printf("BIP6: Original-Broadcast-NPDU is me!\n"); + PRINTF("BIP6: Original-Broadcast-NPDU is me!\n"); } else { function_len = bvlc6_decode_original_broadcast( pdu, pdu_len, &vmac_src, NULL, 0, &npdu_len); @@ -705,21 +739,21 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr, npdu = &mtu[offset]; if (npdu_confirmed_service(npdu, npdu_len)) { offset = 0; - debug_printf( + PRINTF( "BIP6: Original-Broadcast-NPDU: " "Confirmed Service! Discard!"); } } else { - debug_printf("BIP6: Original-Broadcast-NPDU: Unable to " + PRINTF("BIP6: Original-Broadcast-NPDU: Unable to " "decode!\n"); } } break; case BVLC6_FORWARDED_NPDU: - debug_printf("BIP6: Received Forwarded-NPDU.\n"); + PRINTF("BIP6: Received Forwarded-NPDU.\n"); if (bbmd6_address_match_self(addr)) { /* ignore messages from my IPv6 address */ - debug_printf("BIP6: Forwarded-NPDU is me!\n"); + PRINTF("BIP6: Forwarded-NPDU is me!\n"); } else { function_len = bvlc6_decode_forwarded_npdu(pdu, pdu_len, &vmac_src, &fwd_address, NULL, 0, &npdu_len); @@ -731,7 +765,7 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr, bvlc6_vmac_address_set(src, vmac_src); offset = header_len + (function_len - npdu_len); } else { - debug_printf( + PRINTF( "BIP6: Forwarded-NPDU: Unable to decode!\n"); } } @@ -761,7 +795,7 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr, if (send_result) { vmac_src = Device_Object_Instance_Number(); bvlc6_send_result(addr, vmac_src, result_code); - debug_printf("BIP6: sent result code=%d\n", result_code); + PRINTF("BIP6: sent result code=%d\n", result_code); } } @@ -820,7 +854,7 @@ int bvlc6_bbmd_enabled_handler(BACNET_IP6_ADDRESS *addr, incoming messages. */ bbmd6_add_vmac(vmac_src, addr); bvlc6_vmac_address_set(src, vmac_src); - debug_printf( + PRINTF( "BIP6: Received Result Code=%d\n", BVLC6_Result_Code); } break; @@ -839,9 +873,9 @@ int bvlc6_bbmd_enabled_handler(BACNET_IP6_ADDRESS *addr, case BVLC6_ORIGINAL_UNICAST_NPDU: /* This message is used to send directed NPDUs to another B/IPv6 node or router. */ - debug_printf("BIP6: Received Original-Unicast-NPDU.\n"); + PRINTF("BIP6: Received Original-Unicast-NPDU.\n"); if (bbmd6_address_match_self(addr)) { - debug_printf("BIP6: Dropped Original-Unicast-NPDU.\n"); + PRINTF("BIP6: Dropped Original-Unicast-NPDU.\n"); /* ignore messages from my IPv6 address */ offset = 0; } else { @@ -860,7 +894,7 @@ int bvlc6_bbmd_enabled_handler(BACNET_IP6_ADDRESS *addr, } break; case BVLC6_ORIGINAL_BROADCAST_NPDU: - debug_printf("BIP6: Received Original-Broadcast-NPDU.\n"); + PRINTF("BIP6: Received Original-Broadcast-NPDU.\n"); function_len = bvlc6_decode_original_broadcast( pdu, pdu_len, &vmac_src, NULL, 0, &npdu_len); if (function_len) { @@ -873,7 +907,7 @@ int bvlc6_bbmd_enabled_handler(BACNET_IP6_ADDRESS *addr, network layer. */ if (npdu_confirmed_service(npdu, npdu_len)) { offset = 0; - debug_printf( + PRINTF( "BIP6: Original-Broadcast-NPDU: " "Confirmed Service! Discard!"); } else { @@ -900,7 +934,7 @@ int bvlc6_bbmd_enabled_handler(BACNET_IP6_ADDRESS *addr, } break; case BVLC6_FORWARDED_NPDU: - debug_printf("BIP6: Received Forwarded-NPDU.\n"); + PRINTF("BIP6: Received Forwarded-NPDU.\n"); function_len = bvlc6_decode_forwarded_npdu( pdu, pdu_len, &vmac_src, &fwd_address, NULL, 0, &npdu_len); if (function_len) { @@ -959,7 +993,7 @@ int bvlc6_bbmd_enabled_handler(BACNET_IP6_ADDRESS *addr, if (send_result) { vmac_src = Device_Object_Instance_Number(); bvlc6_send_result(addr, vmac_src, result_code); - debug_printf("BIP6: sent result code=%d\n", result_code); + PRINTF("BIP6: sent result code=%d\n", result_code); } } diff --git a/src/bacnet/basic/bbmd6/h_bbmd6.h b/src/bacnet/basic/bbmd6/h_bbmd6.h index 33341807..da8eaa65 100644 --- a/src/bacnet/basic/bbmd6/h_bbmd6.h +++ b/src/bacnet/basic/bbmd6/h_bbmd6.h @@ -84,6 +84,10 @@ extern "C" { void bvlc6_maintenance_timer( uint16_t seconds); + BACNET_STACK_EXPORT + void bvlc6_debug_enable( + void); + BACNET_STACK_EXPORT void bvlc6_cleanup(void); diff --git a/src/bacnet/basic/bbmd6/vmac.c b/src/bacnet/basic/bbmd6/vmac.c index e67a20e2..4389a81f 100644 --- a/src/bacnet/basic/bbmd6/vmac.c +++ b/src/bacnet/basic/bbmd6/vmac.c @@ -42,6 +42,28 @@ /* me! */ #include "bacnet/basic/bbmd6/vmac.h" +/* enable debugging */ +static bool VMAC_Debug = false; +#if PRINT_ENABLED +#include +#include +#define PRINTF(...) \ + if (VMAC_Debug) { \ + fprintf(stderr,__VA_ARGS__); \ + fflush(stderr); \ + } +#else +#define PRINTF(...) +#endif + +/** + * @brief Enable debugging if print is enabled + */ +void VMAC_Debug_Enable(void) +{ + VMAC_Debug = true; +} + /** @file Handle VMAC address binding */ @@ -90,7 +112,7 @@ bool VMAC_Add(uint32_t device_id, struct vmac_data *src) index = Keylist_Data_Add(VMAC_List, device_id, pVMAC); if (index >= 0) { status = true; - printf("VMAC %u added.\n", (unsigned int)device_id); + PRINTF("VMAC %u added.\n", (unsigned int)device_id); } } } @@ -234,11 +256,20 @@ bool VMAC_Find_By_Data(struct vmac_data *vmac, uint32_t *device_id) void VMAC_Cleanup(void) { struct vmac_data *pVMAC; + uint32_t device_id; + const int index = 0; if (VMAC_List) { do { - pVMAC = Keylist_Data_Pop(VMAC_List); + device_id = Keylist_Key(VMAC_List, index); + pVMAC = Keylist_Data_Delete_By_Index(VMAC_List, index); if (pVMAC) { + PRINTF("VMAC List: %lu [", (unsigned long)device_id); + /* print the MAC */ + for (unsigned i = 0; i < pVMAC->mac_len; i++) { + PRINTF("%02X", pVMAC->mac[i]); + } + PRINTF("]\n"); free(pVMAC); } } while (pVMAC); @@ -255,7 +286,7 @@ void VMAC_Init(void) VMAC_List = Keylist_Create(); if (VMAC_List) { atexit(VMAC_Cleanup); - printf("VMAC List initialized.\n"); + PRINTF("VMAC List initialized.\n"); } } diff --git a/src/bacnet/basic/bbmd6/vmac.h b/src/bacnet/basic/bbmd6/vmac.h index c206d931..0e6f9337 100644 --- a/src/bacnet/basic/bbmd6/vmac.h +++ b/src/bacnet/basic/bbmd6/vmac.h @@ -49,6 +49,8 @@ extern "C" { void VMAC_Cleanup(void); BACNET_STACK_EXPORT void VMAC_Init(void); + BACNET_STACK_EXPORT + void VMAC_Debug_Enable(void); #ifdef BAC_TEST #include "ctest.h" diff --git a/src/bacnet/datalink/bip6.h b/src/bacnet/datalink/bip6.h index 60f4a50e..44d29737 100644 --- a/src/bacnet/datalink/bip6.h +++ b/src/bacnet/datalink/bip6.h @@ -102,6 +102,10 @@ extern "C" { void bip6_receive_callback( void); + BACNET_STACK_EXPORT + void bip6_debug_enable( + void); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/bacnet/datalink/dlenv.c b/src/bacnet/datalink/dlenv.c index 3f17edb3..ca917847 100644 --- a/src/bacnet/datalink/dlenv.c +++ b/src/bacnet/datalink/dlenv.c @@ -431,6 +431,11 @@ void dlenv_init(void) #endif #if defined(BACDL_BIP6) BACNET_IP6_ADDRESS addr; + pEnv = getenv("BACNET_BIP6_DEBUG"); + if (pEnv) { + bip6_debug_enable(); + bvlc6_debug_enable(); + } pEnv = getenv("BACNET_BIP6_BROADCAST"); if (pEnv) { bvlc6_address_set(&addr, (uint16_t)strtol(pEnv, NULL, 0), 0, 0, 0, 0, 0,