Added externs declarations to header files to handle C++ compilation.

Cleaned up BACnet/IP API a little.
This commit is contained in:
skarg
2005-08-13 14:10:21 +00:00
parent fdbe2eab1e
commit 2e87236e9b
36 changed files with 307 additions and 76 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ bool bip_init(void)
// bind the socket to the local port number and IP address
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(INADDR_ANY);
sin.sin_port = bip_get_port();
sin.sin_port = htons(bip_get_port());
memset(&(sin.sin_zero), '\0', 8);
status = bind(sock_fd,
(const struct sockaddr*)&sin, sizeof(struct sockaddr));
+5 -29
View File
@@ -81,43 +81,19 @@ static int get_local_address_ioctl(
return rv;
}
static void decode_network_address(struct in_addr *net_address,
uint8_t *octet1, uint8_t *octet2, uint8_t *octet3, uint8_t *octet4)
{
union {
uint8_t byte[4];
uint32_t value;
} long_data = {{0}};
long_data.value = net_address->s_addr;
*octet1 = long_data.byte[0];
*octet2 = long_data.byte[1];
*octet3 = long_data.byte[2];
*octet4 = long_data.byte[3];
}
static void Init_Network(char *ifname)
{
struct in_addr local_address;
struct in_addr broadcast_address;
uint8_t octet1;
uint8_t octet2;
uint8_t octet3;
uint8_t octet4;
/* setup local address */
get_local_address_ioctl(ifname, &local_address, SIOCGIFADDR);
decode_network_address(&local_address, &octet1, &octet2, &octet3, &octet4);
bip_set_address(octet1, octet2, octet3, octet4);
fprintf(stderr,"IP Address: %d.%d.%d.%d\n",
(int)octet1, (int)octet2, (int)octet3, (int)octet4);
bip_set_addr(local_address.s_addr);
fprintf(stderr,"IP Address: %s\n",inet_ntoa(local_address));
/* setup local broadcast address */
get_local_address_ioctl(ifname, &broadcast_address, SIOCGIFBRDADDR);
decode_network_address(&broadcast_address, &octet1, &octet2, &octet3, &octet4);
bip_set_broadcast_address(octet1, octet2, octet3, octet4);
fprintf(stderr,"Broadcast Address: %d.%d.%d.%d\n",
(int)octet1, (int)octet2, (int)octet3, (int)octet4);
bip_set_broadcast_addr(broadcast_address.s_addr);
fprintf(stderr,"Broadcast Address: %s\n",inet_ntoa(broadcast_address));
}
#endif
@@ -360,7 +336,7 @@ int main(int argc, char *argv[])
{
case 1:
// used for testing, but kind of noisy on the network
//Read_Properties();
Read_Properties();
break;
case 2:
break;