AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/arduino_uno/bip-init.c
void bip_set_interface(char *ifname)
{

    uint8_t local_address[] = { 0, 0, 0, 0 };
    uint8_t broadcast_address[] = { 0, 0, 0, 0 };
    uint8_t netmask[] = { 0, 0, 0, 0 };
    uint8_t invertedNetmask[] = { 0, 0, 0, 0 };

    getIPAddress_func(CW5100Class_new(), local_address);
    bip_set_addr(local_address);
    if (BIP_Debug) {
        fprintf(stderr, "Interface: %s\n", ifname);
        fprintf(stderr, "IP Address: %d.%d.%d.%d\n", local_address[0],
            local_address[1], local_address[2], local_address[3]);
    }

    /* setup local broadcast address */
    getSubnetMask_func(CW5100Class_new(), netmask);
    for (int i = 0; i < 4; i++) {       //FIXME: IPv4 ?
        invertedNetmask[i] = ~netmask[i];
        broadcast_address[i] = (local_address[i] | invertedNetmask[i]);
    }

    bip_set_broadcast_addr(broadcast_address);
    if (BIP_Debug) {
        fprintf(stderr, "IP Broadcast Address: %d.%d.%d.%d\n",
            broadcast_address[0], broadcast_address[1], broadcast_address[2],
            broadcast_address[3]);
    }
}
/** Gets the local IP address and local broadcast address from the system,
 *  and saves it into the BACnet/IP data structures.
 *
 * @param ifname [in] The named interface to use for the network layer.
 *        Eg, for Linux, ifname is eth0, ath0, arc0, and others.
 */
Gets the local IP address and local broadcast address from the system,
and saves it into the BACnet/IP data structures.

@param ifname [in] The named interface to use for the network layer.
Eg, for Linux, ifname is eth0, ath0, arc0, and others.
Gets the local IP address and local broadcast address from the system and saves it into the BACnet / IP data structures . @param ifname [ in ] The named interface to use for the network layer . Eg for Linux ifname is eth0 ath0 arc0 and others .
void bip_set_interface(char *ifname)
{
    uint8_t local_address[] = { 0, 0, 0, 0 };
    uint8_t broadcast_address[] = { 0, 0, 0, 0 };
    uint8_t netmask[] = { 0, 0, 0, 0 };
    uint8_t invertedNetmask[] = { 0, 0, 0, 0 };
    getIPAddress_func(CW5100Class_new(), local_address);
    bip_set_addr(local_address);
    if (BIP_Debug) {
        fprintf(stderr, "Interface: %s\n", ifname);
        fprintf(stderr, "IP Address: %d.%d.%d.%d\n", local_address[0],
            local_address[1], local_address[2], local_address[3]);
    }
    getSubnetMask_func(CW5100Class_new(), netmask);
    for (int i = 0; i < 4; i++) {       
        invertedNetmask[i] = ~netmask[i];
        broadcast_address[i] = (local_address[i] | invertedNetmask[i]);
    }
    bip_set_broadcast_addr(broadcast_address);
    if (BIP_Debug) {
        fprintf(stderr, "IP Broadcast Address: %d.%d.%d.%d\n",
            broadcast_address[0], broadcast_address[1], broadcast_address[2],
            broadcast_address[3]);
    }
}
void bip_set_interface ( char * ifname ) { uint8_t local_address [ ] = { 0 , 0 , 0 , 0 } ; uint8_t broadcast_address [ ] = { 0 , 0 , 0 , 0 } ; uint8_t netmask [ ] = { 0 , 0 , 0 , 0 } ; uint8_t invertedNetmask [ ] = { 0 , 0 , 0 , 0 } ; getIPAddress_func ( CW5100Class_new ( ) , local_address ) ; bip_set_addr ( local_address ) ; if ( BIP_Debug ) { fprintf ( stderr , " \n " , ifname ) ; fprintf ( stderr , " \n " , local_address [ 0 ] , local_address [ 1 ] , local_address [ 2 ] , local_address [ 3 ] ) ; } getSubnetMask_func ( CW5100Class_new ( ) , netmask ) ; for ( int i = 0 ; i < 4 ; i ++ ) { invertedNetmask [ i ] = ~ netmask [ i ] ; broadcast_address [ i ] = ( local_address [ i ] | invertedNetmask [ i ] ) ; } bip_set_broadcast_addr ( broadcast_address ) ; if ( BIP_Debug ) { fprintf ( stderr , " \n " , broadcast_address [ 0 ] , broadcast_address [ 1 ] , broadcast_address [ 2 ] , broadcast_address [ 3 ] ) ; } }
Gets the local IP address and local broadcast address from the system,
  and saves it into the BACnet/IP data structures.
Gets the local IP address and local broadcast address from the system and saves it into the BACnet / IP data structures .
/* setup local broadcast address */ //FIXME: IPv4 ?