From fa6cb596cb622c755f65e6c5e1b245a3b7c6c83c Mon Sep 17 00:00:00 2001 From: skarg Date: Fri, 3 Feb 2006 21:54:26 +0000 Subject: [PATCH] Fixed up the USE_INADDR define and created a BIP_DEBUG define for Win32. --- bacnet-stack/ports/win32/bip-init.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bacnet-stack/ports/win32/bip-init.c b/bacnet-stack/ports/win32/bip-init.c index 2aee7027..fedc8f02 100644 --- a/bacnet-stack/ports/win32/bip-init.c +++ b/bacnet-stack/ports/win32/bip-init.c @@ -51,7 +51,9 @@ static long gethostaddr(void) if (gethostname(host_name, sizeof(host_name)) != 0) return -1; + #ifdef BIP_DEBUG printf("host name: %s\n",host_name); + #endif if ((host_ent = gethostbyname(host_name)) == NULL) return -1; @@ -63,6 +65,8 @@ static void set_broadcast_address(uint32_t net_address) long broadcast_address = 0; long mask = 0; + /* Note: sometimes INADDR_BROADCAST does not let me get + any unicast messages. Not sure why... */ #if USE_INADDR (void)net_address; bip_set_broadcast_addr(INADDR_BROADCAST); @@ -122,7 +126,9 @@ bool bip_init(void) Code); exit(1); } + #ifdef BIP_DEBUG printf("host address: %s\n",inet_ntoa(address)); + #endif bip_set_addr(address.s_addr); set_broadcast_address(address.s_addr); @@ -159,6 +165,7 @@ bool bip_init(void) // bind the socket to the local port number and IP address sin.sin_family = AF_INET; + #if USE_INADDR /* by setting sin.sin_addr.s_addr to INADDR_ANY, I am telling the IP stack to automatically fill in the IP address of the machine the process @@ -173,16 +180,14 @@ bool bip_init(void) IP addresses. Note: sometimes INADDR_ANY does not let me get - any unicast messages. Not sure why... - */ - #if USE_INADDR + any unicast messages. Not sure why... */ sin.sin_addr.s_addr = htonl(INADDR_ANY); #else /* or we could use the specific adapter address note: already in network byte order */ - //sin.sin_addr.s_addr = address.s_addr; - sin.sin_port = htons(bip_get_port()); + sin.sin_addr.s_addr = address.s_addr; #endif + sin.sin_port = htons(bip_get_port()); memset(&(sin.sin_zero), '\0', sizeof(sin.sin_zero)); rv = bind(sock_fd, (const struct sockaddr*)&sin, sizeof(struct sockaddr));