Fixed ipv6 destination port and multicast interface issues. (#1161)
This commit is contained in:
@@ -1037,10 +1037,11 @@ static void datalink_init(void)
|
|||||||
}
|
}
|
||||||
pEnv = getenv("BACNET_BIP6_BROADCAST");
|
pEnv = getenv("BACNET_BIP6_BROADCAST");
|
||||||
if (pEnv) {
|
if (pEnv) {
|
||||||
BACNET_IP6_ADDRESS addr;
|
BACNET_IP6_ADDRESS addr = { 0 };
|
||||||
bvlc6_address_set(
|
bvlc6_address_set(
|
||||||
&addr, (uint16_t)strtol(pEnv, NULL, 0), 0, 0, 0, 0, 0, 0,
|
&addr, (uint16_t)strtol(pEnv, NULL, 16), 0, 0, 0, 0, 0, 0,
|
||||||
BIP6_MULTICAST_GROUP_ID);
|
BIP6_MULTICAST_GROUP_ID);
|
||||||
|
addr.port = bip6_get_port();
|
||||||
bip6_set_broadcast_addr(&addr);
|
bip6_set_broadcast_addr(&addr);
|
||||||
}
|
}
|
||||||
if (!bip6_init(getenv("BACNET_BIP6_IFACE"))) {
|
if (!bip6_init(getenv("BACNET_BIP6_IFACE"))) {
|
||||||
|
|||||||
@@ -484,12 +484,24 @@ bool bip6_init(char *ifname)
|
|||||||
bvlc6_address_set(
|
bvlc6_address_set(
|
||||||
&BIP6_Broadcast_Addr, BIP6_MULTICAST_SITE_LOCAL, 0, 0, 0, 0, 0, 0,
|
&BIP6_Broadcast_Addr, BIP6_MULTICAST_SITE_LOCAL, 0, 0, 0, 0, 0, 0,
|
||||||
BIP6_MULTICAST_GROUP_ID);
|
BIP6_MULTICAST_GROUP_ID);
|
||||||
|
BIP6_Broadcast_Addr.port = BIP6_Addr.port;
|
||||||
}
|
}
|
||||||
/* assumes that the driver has already been initialized */
|
/* assumes that the driver has already been initialized */
|
||||||
BIP6_Socket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
BIP6_Socket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
if (BIP6_Socket < 0) {
|
if (BIP6_Socket < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (BIP6_Socket_Scope_Id > 0) {
|
||||||
|
unsigned int idx = BIP6_Socket_Scope_Id;
|
||||||
|
/* Explicitly set the interface for OUTGOING multicast packets */
|
||||||
|
status = setsockopt(
|
||||||
|
BIP6_Socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, &idx, sizeof(idx));
|
||||||
|
if (status < 0) {
|
||||||
|
debug_perror("BIP6: setsockopt(IPV6_MULTICAST_IF)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Allow us to use the same socket for sending and receiving */
|
/* Allow us to use the same socket for sending and receiving */
|
||||||
/* This makes sure that the src port is correct when sending */
|
/* This makes sure that the src port is correct when sending */
|
||||||
sockopt = 1;
|
sockopt = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user