In bip.c getter and setter functions of IP address and Port number expect and return values in the network byte order. All ntoh and hton were eliminated from bip.c.

All other modules changed to be consistent.
arm7 port left unchanged.
This commit is contained in:
bacpack
2010-11-04 13:30:26 +00:00
parent 437112cc52
commit a639864cc8
9 changed files with 46 additions and 46 deletions
+2 -2
View File
@@ -919,7 +919,7 @@ int main(
* My_BIP_Port will be non-zero in this case.
*/
if (My_BIP_Port > 0)
bip_set_port(My_BIP_Port);
bip_set_port(htons(My_BIP_Port));
address_init();
Init_Service_Handlers();
dlenv_init();
@@ -929,7 +929,7 @@ int main(
timeout_seconds = (apdu_timeout() / 1000) * apdu_retries();
if (My_BIP_Port > 0)
bip_set_port(0xBAC0); /* Set back to std BACnet/IP port */
bip_set_port(htons(0xBAC0)); /* Set back to std BACnet/IP port */
/* try to bind with the target device */
found =
address_bind_request(Target_Device_Object_Instance, &max_apdu,
+2 -2
View File
@@ -169,11 +169,11 @@ void Initialize_Device_Addresses( )
#if defined(BACDL_BIP)
struct in_addr *netPtr; /* Lets us cast to this type */
uint8_t *gatewayMac = NULL;
uint32_t myAddr = ntohl( bip_get_addr() );
uint32_t myAddr = bip_get_addr();
pDev = Get_Routed_Device_Object( i );
gatewayMac = pDev->bacDevAddr.mac; /* Keep pointer to the main MAC */
memcpy( pDev->bacDevAddr.mac, &myAddr, 4 );
myPort = ntohs( bip_get_port() );
myPort = bip_get_port();
memcpy( &pDev->bacDevAddr.mac[4], &myPort, 2 );
pDev->bacDevAddr.mac_len = 6;
#elif defined(BACDL_MSTP)
+3 -3
View File
@@ -167,7 +167,7 @@ void dlenv_init(
#endif
pEnv = getenv("BACNET_IP_PORT");
if (pEnv) {
bip_set_port((uint16_t) strtol(pEnv, NULL, 0));
bip_set_port(htons((uint16_t) strtol(pEnv, NULL, 0)));
} else {
/* BIP_Port is statically initialized to 0xBAC0,
* so if it is different, then it was programmatically altered,
@@ -175,8 +175,8 @@ void dlenv_init(
* Unless it is set below 1024, since:
* "The range for well-known ports managed by the IANA is 0-1023."
*/
if (bip_get_port() < 1024)
bip_set_port(0xBAC0);
if (ntohs(bip_get_port()) < 1024)
bip_set_port(htons(0xBAC0));
}
#elif defined(BACDL_MSTP)
pEnv = getenv("BACNET_MAX_INFO_FRAMES");