Fixed BACnetHostNPort known property decoding. (#700)
* Fixed BACnetHostNPort known property decoding. * Added BDT-Entry and FDT-Entry to BACapp for known property encoding/decoding.
This commit is contained in:
+375
-263
@@ -51,7 +51,7 @@
|
||||
#include "bacnet/basic/object/netport.h"
|
||||
|
||||
#if defined(BACDL_BIP6) || defined(BACDL_ALL)
|
||||
#include "bacnet/datalink/bvlc6.h"
|
||||
#include "bacnet/datalink/bvlc6.h"
|
||||
#endif
|
||||
|
||||
#ifndef BBMD_ENABLED
|
||||
@@ -93,13 +93,13 @@ struct bacnet_ipv6_port {
|
||||
uint8_t IP_DHCP_Server[IPV6_ADDR_SIZE];
|
||||
uint16_t Port;
|
||||
BACNET_IP_MODE Mode;
|
||||
bool Auto_Addressing_Enable;
|
||||
bool Auto_Addressing_Enable;
|
||||
char Zone_Index[ZONE_INDEX_SIZE];
|
||||
bool BBMD_Accept_FD_Registrations;
|
||||
void *BBMD_BD_Table;
|
||||
void *BBMD_FD_Table;
|
||||
/* used for foreign device registration to remote BBMD */
|
||||
uint8_t BBMD_IP_Address[16];
|
||||
uint8_t BBMD_IP_Address[16];
|
||||
uint16_t BBMD_Port;
|
||||
uint16_t BBMD_Lifetime;
|
||||
};
|
||||
@@ -138,49 +138,74 @@ struct object_data {
|
||||
static struct object_data Object_List[BACNET_NETWORK_PORTS_MAX];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Network_Port_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_STATUS_FLAGS, PROP_RELIABILITY,
|
||||
PROP_OUT_OF_SERVICE, PROP_NETWORK_TYPE, PROP_PROTOCOL_LEVEL,
|
||||
PROP_NETWORK_NUMBER, PROP_NETWORK_NUMBER_QUALITY, PROP_CHANGES_PENDING,
|
||||
PROP_APDU_LENGTH, PROP_LINK_SPEED, -1 };
|
||||
static const int Network_Port_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE, PROP_STATUS_FLAGS,
|
||||
PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
PROP_NETWORK_TYPE, PROP_PROTOCOL_LEVEL,
|
||||
PROP_NETWORK_NUMBER, PROP_NETWORK_NUMBER_QUALITY,
|
||||
PROP_CHANGES_PENDING, PROP_APDU_LENGTH,
|
||||
PROP_LINK_SPEED, -1
|
||||
};
|
||||
|
||||
static const int Ethernet_Port_Properties_Optional[] = { PROP_MAC_ADDRESS, -1 };
|
||||
|
||||
static const int MSTP_Port_Properties_Optional[] = { PROP_MAC_ADDRESS,
|
||||
PROP_MAX_MASTER, PROP_MAX_INFO_FRAMES, -1 };
|
||||
PROP_MAX_MASTER,
|
||||
PROP_MAX_INFO_FRAMES, -1 };
|
||||
|
||||
static const int BIP_Port_Properties_Optional[] = { PROP_MAC_ADDRESS,
|
||||
PROP_BACNET_IP_MODE, PROP_IP_ADDRESS, PROP_BACNET_IP_UDP_PORT,
|
||||
PROP_IP_SUBNET_MASK, PROP_IP_DEFAULT_GATEWAY, PROP_IP_DNS_SERVER,
|
||||
static const int BIP_Port_Properties_Optional[] = {
|
||||
PROP_MAC_ADDRESS,
|
||||
PROP_BACNET_IP_MODE,
|
||||
PROP_IP_ADDRESS,
|
||||
PROP_BACNET_IP_UDP_PORT,
|
||||
PROP_IP_SUBNET_MASK,
|
||||
PROP_IP_DEFAULT_GATEWAY,
|
||||
PROP_IP_DNS_SERVER,
|
||||
PROP_IP_DHCP_ENABLE,
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP)) && (BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP)) && \
|
||||
(BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
#if (BBMD_ENABLED)
|
||||
PROP_BBMD_ACCEPT_FD_REGISTRATIONS, PROP_BBMD_BROADCAST_DISTRIBUTION_TABLE,
|
||||
PROP_BBMD_ACCEPT_FD_REGISTRATIONS,
|
||||
PROP_BBMD_BROADCAST_DISTRIBUTION_TABLE,
|
||||
PROP_BBMD_FOREIGN_DEVICE_TABLE,
|
||||
#endif
|
||||
#if (BBMD_CLIENT_ENABLED)
|
||||
PROP_FD_BBMD_ADDRESS, PROP_FD_SUBSCRIPTION_LIFETIME,
|
||||
PROP_FD_BBMD_ADDRESS,
|
||||
PROP_FD_SUBSCRIPTION_LIFETIME,
|
||||
#endif
|
||||
#endif
|
||||
-1 };
|
||||
-1
|
||||
};
|
||||
|
||||
static const int BIP6_Port_Properties_Optional[] = { PROP_MAC_ADDRESS,
|
||||
PROP_BACNET_IPV6_MODE, PROP_IPV6_ADDRESS, PROP_IPV6_PREFIX_LENGTH,
|
||||
PROP_BACNET_IPV6_UDP_PORT, PROP_IPV6_DEFAULT_GATEWAY,
|
||||
PROP_BACNET_IPV6_MULTICAST_ADDRESS, PROP_IPV6_DNS_SERVER,
|
||||
PROP_IPV6_AUTO_ADDRESSING_ENABLE, PROP_IPV6_DHCP_LEASE_TIME,
|
||||
PROP_IPV6_DHCP_LEASE_TIME_REMAINING, PROP_IPV6_DHCP_SERVER,
|
||||
static const int BIP6_Port_Properties_Optional[] = {
|
||||
PROP_MAC_ADDRESS,
|
||||
PROP_BACNET_IPV6_MODE,
|
||||
PROP_IPV6_ADDRESS,
|
||||
PROP_IPV6_PREFIX_LENGTH,
|
||||
PROP_BACNET_IPV6_UDP_PORT,
|
||||
PROP_IPV6_DEFAULT_GATEWAY,
|
||||
PROP_BACNET_IPV6_MULTICAST_ADDRESS,
|
||||
PROP_IPV6_DNS_SERVER,
|
||||
PROP_IPV6_AUTO_ADDRESSING_ENABLE,
|
||||
PROP_IPV6_DHCP_LEASE_TIME,
|
||||
PROP_IPV6_DHCP_LEASE_TIME_REMAINING,
|
||||
PROP_IPV6_DHCP_SERVER,
|
||||
PROP_IPV6_ZONE_INDEX,
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP6)) && (BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP6)) && \
|
||||
(BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
#if (BBMD_ENABLED)
|
||||
PROP_BBMD_ACCEPT_FD_REGISTRATIONS, PROP_BBMD_BROADCAST_DISTRIBUTION_TABLE,
|
||||
PROP_BBMD_ACCEPT_FD_REGISTRATIONS,
|
||||
PROP_BBMD_BROADCAST_DISTRIBUTION_TABLE,
|
||||
PROP_BBMD_FOREIGN_DEVICE_TABLE,
|
||||
#endif
|
||||
#if (BBMD_CLIENT_ENABLED)
|
||||
PROP_FD_BBMD_ADDRESS, PROP_FD_SUBSCRIPTION_LIFETIME,
|
||||
PROP_FD_BBMD_ADDRESS,
|
||||
PROP_FD_SUBSCRIPTION_LIFETIME,
|
||||
#endif
|
||||
#endif
|
||||
-1 };
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Network_Port_Properties_Proprietary[] = { -1 };
|
||||
|
||||
@@ -196,7 +221,8 @@ static const int Network_Port_Properties_Proprietary[] = { -1 };
|
||||
* @param pProprietary - pointer to list of int terminated by -1, of
|
||||
* BACnet proprietary properties for this object.
|
||||
*/
|
||||
void Network_Port_Property_List(uint32_t object_instance,
|
||||
void Network_Port_Property_List(
|
||||
uint32_t object_instance,
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
@@ -257,16 +283,15 @@ void Network_Port_Property_Lists(
|
||||
* @param object_property - object-property to be checked
|
||||
* @return true if the property is a member of this object instance
|
||||
*/
|
||||
static bool Property_List_Member(
|
||||
uint32_t object_instance, int object_property)
|
||||
static bool Property_List_Member(uint32_t object_instance, int object_property)
|
||||
{
|
||||
bool found = false;
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
|
||||
Network_Port_Property_List(object_instance,
|
||||
&pRequired, &pOptional, &pProprietary);
|
||||
Network_Port_Property_List(
|
||||
object_instance, &pRequired, &pOptional, &pProprietary);
|
||||
found = property_list_member(pRequired, object_property);
|
||||
if (!found) {
|
||||
found = property_list_member(pOptional, object_property);
|
||||
@@ -725,8 +750,8 @@ bool Network_Port_MAC_Address(
|
||||
uint8_t mac_len = 0;
|
||||
|
||||
if (mac_address) {
|
||||
mac_len = Network_Port_MAC_Address_Value(object_instance,
|
||||
mac_address->value, sizeof(mac_address->value));
|
||||
mac_len = Network_Port_MAC_Address_Value(
|
||||
object_instance, mac_address->value, sizeof(mac_address->value));
|
||||
}
|
||||
|
||||
return mac_len > 0;
|
||||
@@ -1256,17 +1281,17 @@ bool Network_Port_IP_Gateway_Set(
|
||||
*/
|
||||
bool Network_Port_IP_DHCP_Enable(uint32_t object_instance)
|
||||
{
|
||||
bool dhcp_enable = false;
|
||||
unsigned index = 0;
|
||||
bool dhcp_enable = false;
|
||||
unsigned index = 0;
|
||||
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP) {
|
||||
dhcp_enable = Object_List[index].Network.IPv4.IP_DHCP_Enable;
|
||||
}
|
||||
}
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP) {
|
||||
dhcp_enable = Object_List[index].Network.IPv4.IP_DHCP_Enable;
|
||||
}
|
||||
}
|
||||
|
||||
return dhcp_enable;
|
||||
return dhcp_enable;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1279,18 +1304,18 @@ bool Network_Port_IP_DHCP_Enable(uint32_t object_instance)
|
||||
*/
|
||||
bool Network_Port_IP_DHCP_Enable_Set(uint32_t object_instance, bool value)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP) {
|
||||
Object_List[index].Network.IPv4.IP_DHCP_Enable = value;
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP) {
|
||||
Object_List[index].Network.IPv4.IP_DHCP_Enable = value;
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1304,7 +1329,8 @@ bool Network_Port_IP_DHCP_Enable_Set(uint32_t object_instance, bool value)
|
||||
*
|
||||
* @return true if ip-address was retrieved
|
||||
*/
|
||||
bool Network_Port_IP_DNS_Server(uint32_t object_instance,
|
||||
bool Network_Port_IP_DNS_Server(
|
||||
uint32_t object_instance,
|
||||
unsigned dns_index,
|
||||
BACNET_OCTET_STRING *ip_address)
|
||||
{
|
||||
@@ -1315,7 +1341,8 @@ bool Network_Port_IP_DNS_Server(uint32_t object_instance,
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP) {
|
||||
if (dns_index < BIP_DNS_MAX) {
|
||||
status = octetstring_init(ip_address,
|
||||
status = octetstring_init(
|
||||
ip_address,
|
||||
&Object_List[index]
|
||||
.Network.IPv4.IP_DNS_Server[dns_index][0],
|
||||
4);
|
||||
@@ -1366,7 +1393,8 @@ static int Network_Port_IP_DNS_Server_Encode(
|
||||
*
|
||||
* @return true if ip-address was set
|
||||
*/
|
||||
bool Network_Port_IP_DNS_Server_Set(uint32_t object_instance,
|
||||
bool Network_Port_IP_DNS_Server_Set(
|
||||
uint32_t object_instance,
|
||||
unsigned dns_index,
|
||||
uint8_t a,
|
||||
uint8_t b,
|
||||
@@ -1648,7 +1676,8 @@ bool Network_Port_BBMD_FD_Table_Set(uint32_t object_instance, void *fdt_head)
|
||||
return status;
|
||||
}
|
||||
|
||||
#if (defined(BACDL_BIP) || defined(BACDL_ALL)) && (BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
#if (defined(BACDL_BIP) || defined(BACDL_ALL)) && \
|
||||
(BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
/**
|
||||
* For a given object instance-number, gets the ip-address and port
|
||||
* Note: depends on Network_Type being set for this object
|
||||
@@ -1668,8 +1697,8 @@ static bool Network_Port_Remote_BBMD_IP_Address_And_Port(
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP) {
|
||||
bvlc_address_set(addr,
|
||||
Object_List[index].Network.IPv4.BBMD_IP_Address[0],
|
||||
bvlc_address_set(
|
||||
addr, Object_List[index].Network.IPv4.BBMD_IP_Address[0],
|
||||
Object_List[index].Network.IPv4.BBMD_IP_Address[1],
|
||||
Object_List[index].Network.IPv4.BBMD_IP_Address[2],
|
||||
Object_List[index].Network.IPv4.BBMD_IP_Address[3]);
|
||||
@@ -1745,10 +1774,10 @@ bool Network_Port_Remote_BBMD_IP_Address_Set(
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP) {
|
||||
if((Object_List[index].Network.IPv4.BBMD_IP_Address[0] != a) ||
|
||||
(Object_List[index].Network.IPv4.BBMD_IP_Address[1] != b) ||
|
||||
(Object_List[index].Network.IPv4.BBMD_IP_Address[2] != c) ||
|
||||
(Object_List[index].Network.IPv4.BBMD_IP_Address[3] != d)) {
|
||||
if ((Object_List[index].Network.IPv4.BBMD_IP_Address[0] != a) ||
|
||||
(Object_List[index].Network.IPv4.BBMD_IP_Address[1] != b) ||
|
||||
(Object_List[index].Network.IPv4.BBMD_IP_Address[2] != c) ||
|
||||
(Object_List[index].Network.IPv4.BBMD_IP_Address[3] != d)) {
|
||||
Object_List[index].Changes_Pending = true;
|
||||
}
|
||||
Object_List[index].Network.IPv4.BBMD_IP_Address[0] = a;
|
||||
@@ -1922,7 +1951,6 @@ bool Network_Port_BBMD_IP6_Accept_FD_Registrations_Set(
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For a given object instance-number, returns the BBMD-BD-Table head
|
||||
* property value
|
||||
@@ -1956,7 +1984,8 @@ void *Network_Port_BBMD_IP6_BD_Table(uint32_t object_instance)
|
||||
* @return true if the Broadcast Distribution Table linked list head
|
||||
* property value was set
|
||||
*/
|
||||
bool Network_Port_BBMD_IP6_BD_Table_Set(uint32_t object_instance, void *bdt_head)
|
||||
bool Network_Port_BBMD_IP6_BD_Table_Set(
|
||||
uint32_t object_instance, void *bdt_head)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -2007,7 +2036,8 @@ void *Network_Port_BBMD_IP6_FD_Table(uint32_t object_instance)
|
||||
*
|
||||
* @return true if the BBMD-Accept-FD-Registrations property value was set
|
||||
*/
|
||||
bool Network_Port_BBMD_IP6_FD_Table_Set(uint32_t object_instance, void *fdt_head)
|
||||
bool Network_Port_BBMD_IP6_FD_Table_Set(
|
||||
uint32_t object_instance, void *fdt_head)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -2046,7 +2076,10 @@ static bool Network_Port_Remote_BBMD_IP6_Address_And_Port(
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
memcpy(addr->address, Object_List[index].Network.IPv6.BBMD_IP_Address, sizeof(addr->address));
|
||||
memcpy(
|
||||
addr->address,
|
||||
Object_List[index].Network.IPv6.BBMD_IP_Address,
|
||||
sizeof(addr->address));
|
||||
addr->port = Object_List[index].Network.IPv6.BBMD_Port;
|
||||
status = true;
|
||||
}
|
||||
@@ -2077,8 +2110,10 @@ bool Network_Port_Remote_BBMD_IP6_Address(
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
if (addr) {
|
||||
memcpy(addr, Object_List[index].Network.IPv6.BBMD_IP_Address, IP6_ADDRESS_MAX);
|
||||
status = true;
|
||||
memcpy(
|
||||
addr, Object_List[index].Network.IPv6.BBMD_IP_Address,
|
||||
IP6_ADDRESS_MAX);
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2104,8 +2139,12 @@ bool Network_Port_Remote_BBMD_IP6_Address_Set(
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
if(memcmp(Object_List[index].Network.IPv6.BBMD_IP_Address, addr, IP6_ADDRESS_MAX)) {
|
||||
memcpy(Object_List[index].Network.IPv6.BBMD_IP_Address, addr, IP6_ADDRESS_MAX);
|
||||
if (memcmp(
|
||||
Object_List[index].Network.IPv6.BBMD_IP_Address, addr,
|
||||
IP6_ADDRESS_MAX)) {
|
||||
memcpy(
|
||||
Object_List[index].Network.IPv6.BBMD_IP_Address, addr,
|
||||
IP6_ADDRESS_MAX);
|
||||
Object_List[index].Changes_Pending = true;
|
||||
}
|
||||
status = true;
|
||||
@@ -2290,8 +2329,9 @@ bool Network_Port_IPv6_Address(
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
status = octetstring_init(ip_address,
|
||||
&Object_List[index].Network.IPv6.IP_Address[0], IPV6_ADDR_SIZE);
|
||||
status = octetstring_init(
|
||||
ip_address, &Object_List[index].Network.IPv6.IP_Address[0],
|
||||
IPV6_ADDR_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2400,8 +2440,9 @@ bool Network_Port_IPv6_Gateway(
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
status = octetstring_init(ip_address,
|
||||
&Object_List[index].Network.IPv6.IP_Gateway[0], IPV6_ADDR_SIZE);
|
||||
status = octetstring_init(
|
||||
ip_address, &Object_List[index].Network.IPv6.IP_Gateway[0],
|
||||
IPV6_ADDR_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2448,7 +2489,8 @@ bool Network_Port_IPv6_Gateway_Set(
|
||||
*
|
||||
* @return true if ip-address was retrieved
|
||||
*/
|
||||
bool Network_Port_IPv6_DNS_Server(uint32_t object_instance,
|
||||
bool Network_Port_IPv6_DNS_Server(
|
||||
uint32_t object_instance,
|
||||
unsigned dns_index,
|
||||
BACNET_OCTET_STRING *ip_address)
|
||||
{
|
||||
@@ -2459,7 +2501,8 @@ bool Network_Port_IPv6_DNS_Server(uint32_t object_instance,
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
if (dns_index < BIP_DNS_MAX) {
|
||||
status = octetstring_init(ip_address,
|
||||
status = octetstring_init(
|
||||
ip_address,
|
||||
&Object_List[index]
|
||||
.Network.IPv6.IP_DNS_Server[dns_index][0],
|
||||
IPV6_ADDR_SIZE);
|
||||
@@ -2547,7 +2590,8 @@ bool Network_Port_IPv6_Multicast_Address(
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
status = octetstring_init(ip_address,
|
||||
status = octetstring_init(
|
||||
ip_address,
|
||||
&Object_List[index].Network.IPv6.IP_Multicast_Address[0],
|
||||
IPV6_ADDR_SIZE);
|
||||
}
|
||||
@@ -2605,8 +2649,8 @@ bool Network_Port_IPv6_DHCP_Server(
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
status = octetstring_init(ip_address,
|
||||
&Object_List[index].Network.IPv6.IP_DHCP_Server[0],
|
||||
status = octetstring_init(
|
||||
ip_address, &Object_List[index].Network.IPv6.IP_DHCP_Server[0],
|
||||
IPV6_ADDR_SIZE);
|
||||
}
|
||||
}
|
||||
@@ -2723,8 +2767,8 @@ bool Network_Port_IPv6_Zone_Index(
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given object instance-number, returns the BACnet IPv6 Auto Addressing Enable
|
||||
* property value
|
||||
* For a given object instance-number, returns the BACnet IPv6 Auto Addressing
|
||||
* Enable property value
|
||||
*
|
||||
* @param object_instance - object-instance number of the object
|
||||
*
|
||||
@@ -2746,15 +2790,17 @@ bool Network_Port_IPv6_Auto_Addressing_Enable(uint32_t object_instance)
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given object instance-number, sets the BACnet/IP6 Auto Addressing Enable
|
||||
* Note: depends on Network_Type being set to PORT_TYPE_BIP6 for this object
|
||||
* For a given object instance-number, sets the BACnet/IP6 Auto Addressing
|
||||
* Enable Note: depends on Network_Type being set to PORT_TYPE_BIP6 for this
|
||||
* object
|
||||
*
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param value - BACnet/IP6 Audo Addressing Enable (default false)
|
||||
*
|
||||
* @return true if values are within range and property is set.
|
||||
*/
|
||||
bool Network_Port_IPv6_Auto_Addressing_Enable_Set(uint32_t object_instance, bool value)
|
||||
bool Network_Port_IPv6_Auto_Addressing_Enable_Set(
|
||||
uint32_t object_instance, bool value)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -2762,7 +2808,8 @@ bool Network_Port_IPv6_Auto_Addressing_Enable_Set(uint32_t object_instance, bool
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
if (Object_List[index].Network.IPv6.Auto_Addressing_Enable != value) {
|
||||
if (Object_List[index].Network.IPv6.Auto_Addressing_Enable !=
|
||||
value) {
|
||||
Object_List[index].Changes_Pending = true;
|
||||
}
|
||||
Object_List[index].Network.IPv6.Auto_Addressing_Enable = value;
|
||||
@@ -2792,14 +2839,95 @@ bool Network_Port_IPv6_Gateway_Zone_Index_Set(
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if ((Object_List[index].Network_Type == PORT_TYPE_BIP6) &&
|
||||
(zone_index)) {
|
||||
snprintf(&Object_List[index].Network.IPv6.Zone_Index[0],
|
||||
ZONE_INDEX_SIZE, "%s", zone_index);
|
||||
snprintf(
|
||||
&Object_List[index].Network.IPv6.Zone_Index[0], ZONE_INDEX_SIZE,
|
||||
"%s", zone_index);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write the FD BBMD Address
|
||||
* @param object_instance [in] BACnet network port object instance number
|
||||
* @param value [in] BACnet IP address and port
|
||||
* @param error_class [out] BACnet error class
|
||||
* @param error_code [out] BACnet error code
|
||||
* @return true if the value was written
|
||||
*/
|
||||
static bool Network_Port_FD_BBMD_Address_Write(
|
||||
uint32_t object_instance,
|
||||
BACNET_HOST_N_PORT *value,
|
||||
BACNET_ERROR_CLASS *error_class,
|
||||
BACNET_ERROR_CODE *error_code)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
if (!error_class || !error_code) {
|
||||
return status;
|
||||
}
|
||||
if (!value) {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
return status;
|
||||
}
|
||||
switch (Network_Port_Type(object_instance)) {
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP))
|
||||
case PORT_TYPE_BIP:
|
||||
if (Network_Port_BIP_Mode(object_instance) !=
|
||||
BACNET_IP_MODE_FOREIGN) {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
break;
|
||||
} else if (value->host.ip_address.length == 4) {
|
||||
status = Network_Port_Remote_BBMD_IP_Address_Set(
|
||||
object_instance, value->host.ip_address.value[0],
|
||||
value->host.ip_address.value[1],
|
||||
value->host.ip_address.value[2],
|
||||
value->host.ip_address.value[3]);
|
||||
if (status) {
|
||||
status = Network_Port_Remote_BBMD_BIP_Port_Set(
|
||||
object_instance, value->port);
|
||||
}
|
||||
}
|
||||
if (!status) {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
|
||||
case PORT_TYPE_BIP6:
|
||||
if (Network_Port_BIP6_Mode(object_instance) !=
|
||||
BACNET_IP_MODE_FOREIGN) {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
break;
|
||||
} else if (value->host.ip_address.length == 16) {
|
||||
status = Network_Port_Remote_BBMD_IP6_Address_Set(
|
||||
object_instance, &value->host.ip_address.value[0]);
|
||||
|
||||
if (status) {
|
||||
status = Network_Port_Remote_BBMD_BIP6_Port_Set(
|
||||
object_instance, value->port);
|
||||
}
|
||||
}
|
||||
if (!status) {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given object instance-number, gets the MS/TP Max_Info_Frames value
|
||||
* Note: depends on Network_Type being set to PORT_TYPE_MSTP for this object
|
||||
@@ -2897,7 +3025,8 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
BACNET_BIT_STRING bit_string;
|
||||
BACNET_OCTET_STRING octet_string;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP)) && (BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP)) && \
|
||||
(BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
BACNET_IP_ADDRESS ip_address;
|
||||
#endif
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP6)) && (BBMD_CLIENT_ENABLED)
|
||||
@@ -2908,7 +3037,7 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
|
||||
uint8_t network_type = PORT_TYPE_NON_BACNET;
|
||||
uint8_t network_type = PORT_TYPE_NON_BACNET;
|
||||
unsigned int index = 0;
|
||||
|
||||
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||
@@ -2917,11 +3046,12 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
}
|
||||
|
||||
#if (!BBMD_CLIENT_ENABLED)
|
||||
(void) network_type;
|
||||
(void)network_type;
|
||||
#endif
|
||||
|
||||
if ((index = Network_Port_Instance_To_Index(rpdata->object_instance)) < BACNET_NETWORK_PORTS_MAX) {
|
||||
network_type = Object_List[index].Network_Type;
|
||||
if ((index = Network_Port_Instance_To_Index(rpdata->object_instance)) <
|
||||
BACNET_NETWORK_PORTS_MAX) {
|
||||
network_type = Object_List[index].Network_Type;
|
||||
}
|
||||
|
||||
Network_Port_Property_List(
|
||||
@@ -3001,7 +3131,8 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
&apdu[0], Network_Port_Link_Speed(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_CHANGES_PENDING:
|
||||
apdu_len = encode_application_boolean(&apdu[0],
|
||||
apdu_len = encode_application_boolean(
|
||||
&apdu[0],
|
||||
Network_Port_Changes_Pending(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_APDU_LENGTH:
|
||||
@@ -3009,11 +3140,13 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
&apdu[0], Network_Port_APDU_Length(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_MAX_MASTER:
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
apdu_len = encode_application_unsigned(
|
||||
&apdu[0],
|
||||
Network_Port_MSTP_Max_Master(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_MAX_INFO_FRAMES:
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
apdu_len = encode_application_unsigned(
|
||||
&apdu[0],
|
||||
Network_Port_MSTP_Max_Info_Frames(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_BACNET_IP_MODE:
|
||||
@@ -3041,9 +3174,10 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
&apdu[0], Network_Port_IP_DHCP_Enable(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_IP_DNS_SERVER:
|
||||
apdu_len = bacnet_array_encode(rpdata->object_instance,
|
||||
rpdata->array_index, Network_Port_IP_DNS_Server_Encode,
|
||||
BIP_DNS_MAX, apdu, apdu_size);
|
||||
apdu_len = bacnet_array_encode(
|
||||
rpdata->object_instance, rpdata->array_index,
|
||||
Network_Port_IP_DNS_Server_Encode, BIP_DNS_MAX, apdu,
|
||||
apdu_size);
|
||||
if (apdu_len == BACNET_STATUS_ABORT) {
|
||||
rpdata->error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
@@ -3053,105 +3187,114 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
}
|
||||
break;
|
||||
#if (defined(BACDL_BIP) || defined (BACDL_BIP6) || defined(BACDL_ALL)) && (BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
#if (defined(BACDL_BIP) || defined(BACDL_BIP6) || defined(BACDL_ALL)) && \
|
||||
(BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
#if (BBMD_ENABLED)
|
||||
case PROP_BBMD_ACCEPT_FD_REGISTRATIONS:
|
||||
apdu_len = encode_application_boolean(&apdu[0],
|
||||
apdu_len = encode_application_boolean(
|
||||
&apdu[0],
|
||||
Network_Port_BBMD_Accept_FD_Registrations(
|
||||
rpdata->object_instance));
|
||||
break;
|
||||
case PROP_BBMD_BROADCAST_DISTRIBUTION_TABLE:
|
||||
switch(network_type) {
|
||||
switch (network_type) {
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP))
|
||||
case PORT_TYPE_BIP:
|
||||
apdu_len = bvlc_broadcast_distribution_table_encode(&apdu[0],
|
||||
rpdata->application_data_len,
|
||||
Network_Port_BBMD_BD_Table(rpdata->object_instance));
|
||||
break;
|
||||
case PORT_TYPE_BIP:
|
||||
apdu_len = bvlc_broadcast_distribution_table_encode(
|
||||
&apdu[0], rpdata->application_data_len,
|
||||
Network_Port_BBMD_BD_Table(rpdata->object_instance));
|
||||
break;
|
||||
#endif
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
|
||||
case PORT_TYPE_BIP6:
|
||||
apdu_len = bvlc6_broadcast_distribution_table_encode(&apdu[0],
|
||||
rpdata->application_data_len,
|
||||
Network_Port_BBMD_IP6_BD_Table(rpdata->object_instance));
|
||||
break;
|
||||
case PORT_TYPE_BIP6:
|
||||
apdu_len = bvlc6_broadcast_distribution_table_encode(
|
||||
&apdu[0], rpdata->application_data_len,
|
||||
Network_Port_BBMD_IP6_BD_Table(
|
||||
rpdata->object_instance));
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PROP_BBMD_FOREIGN_DEVICE_TABLE:
|
||||
switch(network_type) {
|
||||
switch (network_type) {
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP))
|
||||
case PORT_TYPE_BIP:
|
||||
apdu_len = bvlc_foreign_device_table_encode(&apdu[0],
|
||||
rpdata->application_data_len,
|
||||
Network_Port_BBMD_FD_Table(rpdata->object_instance));
|
||||
break;
|
||||
case PORT_TYPE_BIP:
|
||||
apdu_len = bvlc_foreign_device_table_encode(
|
||||
&apdu[0], rpdata->application_data_len,
|
||||
Network_Port_BBMD_FD_Table(rpdata->object_instance));
|
||||
break;
|
||||
#endif
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
|
||||
case PORT_TYPE_BIP6:
|
||||
apdu_len = bvlc6_foreign_device_table_encode(&apdu[0],
|
||||
rpdata->application_data_len,
|
||||
Network_Port_BBMD_IP6_FD_Table(rpdata->object_instance));
|
||||
break;
|
||||
case PORT_TYPE_BIP6:
|
||||
apdu_len = bvlc6_foreign_device_table_encode(
|
||||
&apdu[0], rpdata->application_data_len,
|
||||
Network_Port_BBMD_IP6_FD_Table(
|
||||
rpdata->object_instance));
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#endif /* BBMD_ENABLED */
|
||||
#if (BBMD_CLIENT_ENABLED)
|
||||
case PROP_FD_BBMD_ADDRESS:
|
||||
switch(network_type) {
|
||||
#if (defined(BACDL_BIP) || defined(BACDL_ALL)) && (BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
case PORT_TYPE_BIP:
|
||||
Network_Port_Remote_BBMD_IP_Address_And_Port(
|
||||
rpdata->object_instance, &ip_address);
|
||||
apdu_len = bvlc_foreign_device_bbmd_host_address_encode(
|
||||
&apdu[0], apdu_size, &ip_address);
|
||||
break;
|
||||
switch (network_type) {
|
||||
#if (defined(BACDL_BIP) || defined(BACDL_ALL)) && \
|
||||
(BBMD_ENABLED || BBMD_CLIENT_ENABLED)
|
||||
case PORT_TYPE_BIP:
|
||||
Network_Port_Remote_BBMD_IP_Address_And_Port(
|
||||
rpdata->object_instance, &ip_address);
|
||||
apdu_len = bvlc_foreign_device_bbmd_host_address_encode(
|
||||
&apdu[0], apdu_size, &ip_address);
|
||||
break;
|
||||
#endif
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
|
||||
case PORT_TYPE_BIP6:
|
||||
Network_Port_Remote_BBMD_IP6_Address_And_Port(
|
||||
rpdata->object_instance, &ip6_address);
|
||||
apdu_len = bvlc6_foreign_device_bbmd_host_address_encode(
|
||||
&apdu[0], apdu_size, &ip6_address);
|
||||
break;
|
||||
case PORT_TYPE_BIP6:
|
||||
Network_Port_Remote_BBMD_IP6_Address_And_Port(
|
||||
rpdata->object_instance, &ip6_address);
|
||||
apdu_len = bvlc6_foreign_device_bbmd_host_address_encode(
|
||||
&apdu[0], apdu_size, &ip6_address);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PROP_FD_SUBSCRIPTION_LIFETIME:
|
||||
switch(network_type) {
|
||||
switch (network_type) {
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP))
|
||||
case PORT_TYPE_BIP:
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
Network_Port_Remote_BBMD_BIP_Lifetime(rpdata->object_instance));
|
||||
break;
|
||||
case PORT_TYPE_BIP:
|
||||
apdu_len = encode_application_unsigned(
|
||||
&apdu[0],
|
||||
Network_Port_Remote_BBMD_BIP_Lifetime(
|
||||
rpdata->object_instance));
|
||||
break;
|
||||
#endif
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
|
||||
case PORT_TYPE_BIP6:
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
Network_Port_Remote_BBMD_BIP6_Lifetime(rpdata->object_instance));
|
||||
break;
|
||||
case PORT_TYPE_BIP6:
|
||||
apdu_len = encode_application_unsigned(
|
||||
&apdu[0],
|
||||
Network_Port_Remote_BBMD_BIP6_Lifetime(
|
||||
rpdata->object_instance));
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@@ -3165,7 +3308,8 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
apdu_len = encode_application_octet_string(&apdu[0], &octet_string);
|
||||
break;
|
||||
case PROP_IPV6_PREFIX_LENGTH:
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
apdu_len = encode_application_unsigned(
|
||||
&apdu[0],
|
||||
Network_Port_IPv6_Subnet_Prefix(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_BACNET_IPV6_UDP_PORT:
|
||||
@@ -3182,9 +3326,10 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
apdu_len = encode_application_octet_string(&apdu[0], &octet_string);
|
||||
break;
|
||||
case PROP_IPV6_DNS_SERVER:
|
||||
apdu_len = bacnet_array_encode(rpdata->object_instance,
|
||||
rpdata->array_index, Network_Port_IPv6_DNS_Server_Encode,
|
||||
BIP_DNS_MAX, apdu, apdu_size);
|
||||
apdu_len = bacnet_array_encode(
|
||||
rpdata->object_instance, rpdata->array_index,
|
||||
Network_Port_IPv6_DNS_Server_Encode, BIP_DNS_MAX, apdu,
|
||||
apdu_size);
|
||||
if (apdu_len == BACNET_STATUS_ABORT) {
|
||||
rpdata->error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
@@ -3195,7 +3340,10 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
}
|
||||
break;
|
||||
case PROP_IPV6_AUTO_ADDRESSING_ENABLE:
|
||||
apdu_len = encode_application_boolean(&apdu[0], Network_Port_IPv6_Auto_Addressing_Enable(rpdata->object_instance));
|
||||
apdu_len = encode_application_boolean(
|
||||
&apdu[0],
|
||||
Network_Port_IPv6_Auto_Addressing_Enable(
|
||||
rpdata->object_instance));
|
||||
break;
|
||||
case PROP_IPV6_DHCP_LEASE_TIME:
|
||||
apdu_len = encode_application_unsigned(&apdu[0], 0);
|
||||
@@ -3258,7 +3406,8 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->application_data, wp_data->application_data_len, &value);
|
||||
#else
|
||||
len = bacapp_decode_generic_property(
|
||||
wp_data->application_data, wp_data->application_data_len, &value, wp_data->object_property);
|
||||
wp_data->application_data, wp_data->application_data_len, &value,
|
||||
wp_data->object_property);
|
||||
#endif
|
||||
if (len < 0) {
|
||||
/* error while decoding - a value larger than we can handle */
|
||||
@@ -3317,110 +3466,73 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
#if (BBMD_CLIENT_ENABLED)
|
||||
case PROP_FD_BBMD_ADDRESS:
|
||||
if(write_property_type_valid( wp_data, &value, BACNET_APPLICATION_TAG_HOST_N_PORT)) {
|
||||
switch(Network_Port_Type(wp_data->object_instance)) {
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP))
|
||||
case PORT_TYPE_BIP:
|
||||
if(Network_Port_BIP_Mode(wp_data->object_instance) == BACNET_IP_MODE_FOREIGN) {
|
||||
if(value.type.Host_Address.host.ip_address.length == 4) {
|
||||
status = Network_Port_Remote_BBMD_IP_Address_Set(
|
||||
wp_data->object_instance,
|
||||
value.type.Host_Address.host.ip_address.value[0],
|
||||
value.type.Host_Address.host.ip_address.value[1],
|
||||
value.type.Host_Address.host.ip_address.value[2],
|
||||
value.type.Host_Address.host.ip_address.value[3]);
|
||||
|
||||
if(status) {
|
||||
status = Network_Port_Remote_BBMD_BIP_Port_Set(wp_data->object_instance, value.type.Host_Address.port);
|
||||
}
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
|
||||
case PORT_TYPE_BIP6:
|
||||
if(Network_Port_BIP_Mode(wp_data->object_instance) == BACNET_IP_MODE_FOREIGN) {
|
||||
if(value.type.Host_Address.host.ip_address.length == 16) {
|
||||
status = Network_Port_Remote_BBMD_IP6_Address_Set(
|
||||
wp_data->object_instance,
|
||||
&value.type.Host_Address.host.ip_address.value[0]);
|
||||
|
||||
if(status) {
|
||||
status = Network_Port_Remote_BBMD_BIP6_Port_Set(wp_data->object_instance, value.type.Host_Address.port);
|
||||
}
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
break;
|
||||
}
|
||||
if (write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_HOST_N_PORT)) {
|
||||
status = Network_Port_FD_BBMD_Address_Write(
|
||||
wp_data->object_instance, &value.type.Host_Address,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
break;
|
||||
case PROP_FD_SUBSCRIPTION_LIFETIME:
|
||||
if(write_property_type_valid(wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
|
||||
if (value.type.Unsigned_Int <= 65535) {
|
||||
switch(Network_Port_Type(wp_data->object_instance)) {
|
||||
if (write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
|
||||
if (value.type.Unsigned_Int <= 65535) {
|
||||
switch (Network_Port_Type(wp_data->object_instance)) {
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP))
|
||||
case PORT_TYPE_BIP:
|
||||
if(Network_Port_BIP_Mode(wp_data->object_instance) == BACNET_IP_MODE_FOREIGN) {
|
||||
status = Network_Port_Remote_BBMD_BIP_Lifetime_Set(
|
||||
wp_data->object_instance, value.type.Unsigned_Int);
|
||||
if (!status) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
}
|
||||
break;
|
||||
case PORT_TYPE_BIP:
|
||||
if (Network_Port_BIP_Mode(
|
||||
wp_data->object_instance) ==
|
||||
BACNET_IP_MODE_FOREIGN) {
|
||||
status =
|
||||
Network_Port_Remote_BBMD_BIP_Lifetime_Set(
|
||||
wp_data->object_instance,
|
||||
value.type.Unsigned_Int);
|
||||
if (!status) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code =
|
||||
ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code =
|
||||
ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
|
||||
case PORT_TYPE_BIP6:
|
||||
if(Network_Port_BIP6_Mode(wp_data->object_instance) == BACNET_IP_MODE_FOREIGN) {
|
||||
status = Network_Port_Remote_BBMD_BIP6_Lifetime_Set(
|
||||
wp_data->object_instance, value.type.Unsigned_Int);
|
||||
if (!status) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
}
|
||||
break;
|
||||
case PORT_TYPE_BIP6:
|
||||
if (Network_Port_BIP6_Mode(
|
||||
wp_data->object_instance) ==
|
||||
BACNET_IP_MODE_FOREIGN) {
|
||||
status =
|
||||
Network_Port_Remote_BBMD_BIP6_Lifetime_Set(
|
||||
wp_data->object_instance,
|
||||
value.type.Unsigned_Int);
|
||||
if (!status) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code =
|
||||
ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code =
|
||||
ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
default:
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code =
|
||||
ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
break;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user