Changed BIP debug from define to variable since we are using a lib. Affects Win32 and Linux.
This commit is contained in:
@@ -151,6 +151,7 @@ int main(int argc, char *argv[])
|
||||
Device_Object_Instance_Number(),
|
||||
MAX_APDU);
|
||||
Init_Service_Handlers();
|
||||
BIP_Debug = true;
|
||||
if (!datalink_init(getenv("BACNET_IFACE")))
|
||||
return 1;
|
||||
atexit(cleanup);
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
|
||||
#define BVLL_TYPE_BACNET_IP (0x81)
|
||||
|
||||
extern bool BIP_Debug;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
|
||||
/* optional debug info for BACnet/IP datalink layers */
|
||||
#if defined(BACDL_BIP)
|
||||
#if !defined(BIP_DEBUG)
|
||||
#define BIP_DEBUG 1
|
||||
#endif
|
||||
#if !defined(USE_INADDR)
|
||||
#define USE_INADDR 1
|
||||
#endif
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
#include "bip.h"
|
||||
#include "net.h"
|
||||
|
||||
bool BIP_Debug = false;
|
||||
|
||||
static int get_local_ifr_ioctl(char *ifname, struct ifreq *ifr,
|
||||
int request)
|
||||
{
|
||||
@@ -83,10 +85,10 @@ static void bip_set_interface(char *ifname)
|
||||
local_address.s_addr = 0;
|
||||
}
|
||||
bip_set_addr(local_address.s_addr);
|
||||
#if BIP_DEBUG
|
||||
fprintf(stderr, "Interface: %s\n", ifname);
|
||||
fprintf(stderr, "IP Address: %s\n", inet_ntoa(local_address));
|
||||
#endif
|
||||
if (BIP_Debug) {
|
||||
fprintf(stderr, "Interface: %s\n", ifname);
|
||||
fprintf(stderr, "IP Address: %s\n", inet_ntoa(local_address));
|
||||
}
|
||||
/* setup local broadcast address */
|
||||
rv = get_local_address_ioctl(ifname, &broadcast_address,
|
||||
SIOCGIFBRDADDR);
|
||||
@@ -94,13 +96,13 @@ static void bip_set_interface(char *ifname)
|
||||
broadcast_address.s_addr = ~0;
|
||||
}
|
||||
bip_set_broadcast_addr(broadcast_address.s_addr);
|
||||
#if BIP_DEBUG
|
||||
fprintf(stderr, "IP Broadcast Address: %s\n",
|
||||
inet_ntoa(broadcast_address));
|
||||
fprintf(stderr, "UDP Port: 0x%04X [%hu]\n",
|
||||
bip_get_port(),
|
||||
bip_get_port());
|
||||
#endif
|
||||
if (BIP_Debug) {
|
||||
fprintf(stderr, "IP Broadcast Address: %s\n",
|
||||
inet_ntoa(broadcast_address));
|
||||
fprintf(stderr, "UDP Port: 0x%04X [%hu]\n",
|
||||
bip_get_port(),
|
||||
bip_get_port());
|
||||
}
|
||||
}
|
||||
|
||||
bool bip_init(char *ifname)
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "bip.h"
|
||||
#include "net.h"
|
||||
|
||||
bool BIP_Debug = false;
|
||||
/* To fill a need, we invent the gethostaddr() function. */
|
||||
static long gethostaddr(void)
|
||||
{
|
||||
@@ -51,13 +52,13 @@ static long gethostaddr(void)
|
||||
|
||||
if ((host_ent = gethostbyname(host_name)) == NULL)
|
||||
return -1;
|
||||
#if BIP_DEBUG
|
||||
printf("host: %s at %u.%u.%u.%u\n", host_name,
|
||||
((uint8_t*)host_ent->h_addr)[0],
|
||||
((uint8_t*)host_ent->h_addr)[1],
|
||||
((uint8_t*)host_ent->h_addr)[2],
|
||||
((uint8_t*)host_ent->h_addr)[3]);
|
||||
#endif
|
||||
if (BIP_Debug) {
|
||||
printf("host: %s at %u.%u.%u.%u\n", host_name,
|
||||
((uint8_t*)host_ent->h_addr)[0],
|
||||
((uint8_t*)host_ent->h_addr)[1],
|
||||
((uint8_t*)host_ent->h_addr)[2],
|
||||
((uint8_t*)host_ent->h_addr)[3]);
|
||||
}
|
||||
/* note: network byte order */
|
||||
return *(long *) host_ent->h_addr;
|
||||
}
|
||||
@@ -105,10 +106,10 @@ void bip_set_interface(char *ifname)
|
||||
if (bip_get_addr() == 0) {
|
||||
bip_set_addr(inet_addr(ifname));
|
||||
}
|
||||
#if BIP_DEBUG
|
||||
address.s_addr = htonl(bip_get_addr());
|
||||
fprintf(stderr, "Interface: %s\n", ifname);
|
||||
#endif
|
||||
if (BIP_Debug) {
|
||||
address.s_addr = htonl(bip_get_addr());
|
||||
fprintf(stderr, "Interface: %s\n", ifname);
|
||||
}
|
||||
/* setup local broadcast address */
|
||||
if (bip_get_broadcast_addr() == 0) {
|
||||
address.s_addr = htonl(bip_get_addr());
|
||||
@@ -263,21 +264,21 @@ bool bip_init(char *ifname)
|
||||
}
|
||||
bip_set_addr(address.s_addr);
|
||||
}
|
||||
#if BIP_DEBUG
|
||||
fprintf(stderr, "IP Address: %s\n", inet_ntoa(address));
|
||||
#endif
|
||||
if (BIP_Debug) {
|
||||
fprintf(stderr, "IP Address: %s\n", inet_ntoa(address));
|
||||
}
|
||||
/* has broadcast address been set? */
|
||||
if (bip_get_broadcast_addr() == 0) {
|
||||
set_broadcast_address(address.s_addr);
|
||||
}
|
||||
#if BIP_DEBUG
|
||||
broadcast_address.s_addr = htonl(bip_get_broadcast_addr());
|
||||
fprintf(stderr, "IP Broadcast Address: %s\n",
|
||||
inet_ntoa(broadcast_address));
|
||||
fprintf(stderr, "UDP Port: 0x%04X [%hu]\n",
|
||||
bip_get_port(),
|
||||
bip_get_port());
|
||||
#endif
|
||||
if (BIP_Debug) {
|
||||
broadcast_address.s_addr = htonl(bip_get_broadcast_addr());
|
||||
fprintf(stderr, "IP Broadcast Address: %s\n",
|
||||
inet_ntoa(broadcast_address));
|
||||
fprintf(stderr, "UDP Port: 0x%04X [%hu]\n",
|
||||
bip_get_port(),
|
||||
bip_get_port());
|
||||
}
|
||||
/* assumes that the driver has already been initialized */
|
||||
sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
bip_set_socket(sock_fd);
|
||||
|
||||
Reference in New Issue
Block a user