make pretty

This commit is contained in:
Steve Karg
2022-09-10 10:32:50 -05:00
parent 7cdab61d72
commit cc4911a185
123 changed files with 1387 additions and 1604 deletions
+24 -33
View File
@@ -563,10 +563,10 @@ int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
len = encode_opening_tag(&apdu[apdu_len], 0);
apdu_len += len;
/* CHOICE - ip-address [1] OCTET STRING */
octetstring_init(&octet_string,
&bdt_entry->dest_address.address[0], IP_ADDRESS_MAX);
len = encode_context_octet_string(&apdu[apdu_len], 1,
&octet_string);
octetstring_init(&octet_string, &bdt_entry->dest_address.address[0],
IP_ADDRESS_MAX);
len =
encode_context_octet_string(&apdu[apdu_len], 1, &octet_string);
apdu_len += len;
/* host [0] BACnetHostAddress - closing */
len = encode_closing_tag(&apdu[apdu_len], 0);
@@ -581,8 +581,8 @@ int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
/* broadcast-mask [1] OCTET STRING */
octetstring_init(&octet_string,
&bdt_entry->broadcast_mask.address[0], IP_ADDRESS_MAX);
len = encode_context_octet_string(&apdu[apdu_len], 1,
&octet_string);
len =
encode_context_octet_string(&apdu[apdu_len], 1, &octet_string);
apdu_len += len;
}
if (!entry_size) {
@@ -657,13 +657,12 @@ int bvlc_broadcast_distribution_table_decode(uint8_t *apdu,
}
return BACNET_STATUS_REJECT;
}
len += decode_octet_string(&apdu[len], len_value_type,
&octet_string);
len += decode_octet_string(&apdu[len], len_value_type, &octet_string);
if (len > apdu_len) {
return BACNET_STATUS_REJECT;
}
(void)octetstring_copy_value(&bdt_entry->dest_address.address[0],
IP_ADDRESS_MAX, &octet_string);
(void)octetstring_copy_value(
&bdt_entry->dest_address.address[0], IP_ADDRESS_MAX, &octet_string);
/* host [0] BACnetHostAddress - closing */
if (!decode_is_closing_tag_number(&apdu[len++], 0)) {
if (error_code) {
@@ -717,8 +716,7 @@ int bvlc_broadcast_distribution_table_decode(uint8_t *apdu,
if (len > apdu_len) {
return BACNET_STATUS_REJECT;
}
len += decode_octet_string(&apdu[len], len_value_type,
&octet_string);
len += decode_octet_string(&apdu[len], len_value_type, &octet_string);
if (len > apdu_len) {
return BACNET_STATUS_REJECT;
}
@@ -1148,13 +1146,11 @@ int bvlc_foreign_device_table_encode(uint8_t *apdu,
while (fdt_entry) {
if (fdt_entry->valid) {
/* bacnetip-address [0] OCTET STRING */
len = bvlc_encode_address(
octetstring_value(&octet_string),
octetstring_capacity(&octet_string),
&fdt_entry->dest_address);
len = bvlc_encode_address(octetstring_value(&octet_string),
octetstring_capacity(&octet_string), &fdt_entry->dest_address);
octetstring_truncate(&octet_string, len);
len = encode_context_octet_string(
&apdu[apdu_len], 0, &octet_string);
len =
encode_context_octet_string(&apdu[apdu_len], 0, &octet_string);
apdu_len += len;
/* time-to-live [1] Unsigned16 */
len = encode_context_unsigned(
@@ -1179,8 +1175,6 @@ int bvlc_foreign_device_table_encode(uint8_t *apdu,
return apdu_len;
}
/**
* @brief J.2.7 Read-Foreign-Device-Table: encode
*
@@ -2162,13 +2156,13 @@ bool bvlc_address_from_ascii(BACNET_IP_ADDRESS *addr, const char *addrstr)
return false;
}
if ((c == '.') || (c == 0) || (c == ' ')) {
addr->address[i] = (uint8_t) tmp;
addr->address[i] = (uint8_t)tmp;
tmp = 0;
} else if ((c >= '0') && (c <= '9')) {
tmp = (tmp * 10) + (c - '0');
if (tmp > UINT8_MAX) {
if (tmp > UINT8_MAX) {
return false;
}
}
} else {
return false;
}
@@ -2598,7 +2592,7 @@ const char *bvlc_result_code_name(uint16_t result_code)
name = "Successful Completion";
break;
case BVLC_RESULT_WRITE_BROADCAST_DISTRIBUTION_TABLE_NAK:
name= "Write-Broadcast-Distribution-Table NAK";
name = "Write-Broadcast-Distribution-Table NAK";
break;
case BVLC_RESULT_READ_BROADCAST_DISTRIBUTION_TABLE_NAK:
name = "Read-Broadcast-Distribution-Table NAK";
@@ -2629,17 +2623,16 @@ const char *bvlc_result_code_name(uint16_t result_code)
* @param ip_address - IP address and port number
* @return length of the APDU buffer
*/
int bvlc_foreign_device_bbmd_host_address_encode(uint8_t *apdu,
uint16_t apdu_size,
BACNET_IP_ADDRESS *ip_address)
int bvlc_foreign_device_bbmd_host_address_encode(
uint8_t *apdu, uint16_t apdu_size, BACNET_IP_ADDRESS *ip_address)
{
BACNET_HOST_N_PORT address = { 0 };
int apdu_len = 0;
address.host_ip_address = true;
address.host_name = false;
octetstring_init(&address.host.ip_address, &ip_address->address[0],
IP_ADDRESS_MAX);
octetstring_init(
&address.host.ip_address, &ip_address->address[0], IP_ADDRESS_MAX);
address.port = ip_address->port;
apdu_len = host_n_port_encode(NULL, &address);
if (apdu_len <= apdu_size) {
@@ -2668,10 +2661,8 @@ int bvlc_foreign_device_bbmd_host_address_decode(uint8_t *apdu,
if (len > 0) {
if (address.host_ip_address) {
ip_address->port = address.port;
(void)octetstring_copy_value(
&ip_address->address[0],
IP_ADDRESS_MAX,
&address.host.ip_address);
(void)octetstring_copy_value(&ip_address->address[0],
IP_ADDRESS_MAX, &address.host.ip_address);
} else {
len = BACNET_STATUS_REJECT;
if (error_code) {
+2 -3
View File
@@ -670,8 +670,7 @@ bool bvlc6_address_get(BACNET_IP6_ADDRESS *addr,
* input, excluding the trailing null.
* @note buf and buf_size may be null and zero to return only the size
*/
int bvlc6_address_to_ascii(BACNET_IP6_ADDRESS *addr, char *buf,
size_t buf_size)
int bvlc6_address_to_ascii(BACNET_IP6_ADDRESS *addr, char *buf, size_t buf_size)
{
uint16_t a;
unsigned int i;
@@ -685,7 +684,7 @@ int bvlc6_address_to_ascii(BACNET_IP6_ADDRESS *addr, char *buf,
if (!buf) {
return n;
}
for(i = 0; i < IP6_ADDRESS_MAX; i += 2) {
for (i = 0; i < IP6_ADDRESS_MAX; i += 2) {
a = (addr->address[i] << 8) + addr->address[i + 1];
if ((a == 0) && (f >= 0)) {
if (f++ == 0) {
+9 -18
View File
@@ -86,8 +86,7 @@ uint32_t cobs_crc32k(uint8_t dataValue, uint32_t crc32kValue)
* @return the length of the encoded data, or 0 if error
* @note This function is copied mostly from the BACnet standard.
*/
size_t cobs_encode(
uint8_t *buffer,
size_t cobs_encode(uint8_t *buffer,
size_t buffer_size,
const uint8_t *from,
size_t length,
@@ -163,10 +162,7 @@ size_t cobs_encode(
* @note This function is copied mostly from the BACnet standard.
*/
size_t cobs_frame_encode(
uint8_t *buffer,
size_t buffer_size,
const uint8_t *from,
size_t length)
uint8_t *buffer, size_t buffer_size, const uint8_t *from, size_t length)
{
size_t cobs_data_len, cobs_crc_len;
uint32_t crc32K;
@@ -176,8 +172,8 @@ size_t cobs_frame_encode(
/*
* Prepare the Encoded Data field for transmission.
*/
cobs_data_len = cobs_encode(buffer, buffer_size, from, length,
MSTP_PREAMBLE_X55);
cobs_data_len =
cobs_encode(buffer, buffer_size, from, length, MSTP_PREAMBLE_X55);
if (cobs_data_len == 0) {
return 0;
}
@@ -218,8 +214,7 @@ size_t cobs_frame_encode(
* @return the length of the decoded buffer, or 0 if error
* @note This function is copied directly from the BACnet standard.
*/
size_t cobs_decode(
uint8_t *buffer,
size_t cobs_decode(uint8_t *buffer,
size_t buffer_size,
const uint8_t *from,
size_t length,
@@ -282,10 +277,7 @@ size_t cobs_decode(
* @note This function is copied directly from the BACnet standard.
*/
size_t cobs_frame_decode(
uint8_t *buffer,
size_t buffer_size,
const uint8_t *from,
size_t length)
uint8_t *buffer, size_t buffer_size, const uint8_t *from, size_t length)
{
size_t data_len, crc_len;
uint32_t crc32K;
@@ -306,8 +298,8 @@ size_t cobs_frame_decode(
/* See Clause G.3.1 */
crc32K = cobs_crc32k(from[i], crc32K);
}
data_len = cobs_decode(buffer, buffer_size, from, data_len,
MSTP_PREAMBLE_X55);
data_len =
cobs_decode(buffer, buffer_size, from, data_len, MSTP_PREAMBLE_X55);
if (data_len == 0) {
/* error during decode */
return 0;
@@ -315,8 +307,7 @@ size_t cobs_frame_decode(
/*
* Decode the Encoded CRC-32K field
*/
crc_len = cobs_decode(crc_buffer,
sizeof(crc_buffer),
crc_len = cobs_decode(crc_buffer, sizeof(crc_buffer),
(uint8_t *)(from + length - COBS_ENCODED_CRC_SIZE),
COBS_ENCODED_CRC_SIZE, MSTP_PREAMBLE_X55);
/*
+11 -21
View File
@@ -44,7 +44,7 @@
#include "bacnet/basic/bbmd6/h_bbmd6.h"
#include "bacnet/datalink/arcnet.h"
#include "bacnet/datalink/dlmstp.h"
#include <strings.h> /* for strcasecmp() */
#include <strings.h> /* for strcasecmp() */
static enum {
DATALINK_NONE = 0,
@@ -114,24 +114,19 @@ int datalink_send_pdu(BACNET_ADDRESS *dest,
bytes = pdu_len;
break;
case DATALINK_ARCNET:
bytes = arcnet_send_pdu(
dest, npdu_data, pdu, pdu_len);
bytes = arcnet_send_pdu(dest, npdu_data, pdu, pdu_len);
break;
case DATALINK_ETHERNET:
bytes = ethernet_send_pdu(
dest, npdu_data, pdu, pdu_len);
bytes = ethernet_send_pdu(dest, npdu_data, pdu, pdu_len);
break;
case DATALINK_BIP:
bytes = bip_send_pdu(
dest, npdu_data, pdu, pdu_len);
bytes = bip_send_pdu(dest, npdu_data, pdu, pdu_len);
break;
case DATALINK_BIP6:
bytes = bip6_send_pdu(
dest, npdu_data, pdu, pdu_len);
bytes = bip6_send_pdu(dest, npdu_data, pdu, pdu_len);
break;
case DATALINK_MSTP:
bytes = dlmstp_send_pdu(
dest, npdu_data, pdu, pdu_len);
bytes = dlmstp_send_pdu(dest, npdu_data, pdu, pdu_len);
break;
default:
break;
@@ -149,24 +144,19 @@ uint16_t datalink_receive(
case DATALINK_NONE:
break;
case DATALINK_ARCNET:
bytes = arcnet_receive(
src, pdu, max_pdu, timeout);
bytes = arcnet_receive(src, pdu, max_pdu, timeout);
break;
case DATALINK_ETHERNET:
bytes = ethernet_receive(
src, pdu, max_pdu, timeout);
bytes = ethernet_receive(src, pdu, max_pdu, timeout);
break;
case DATALINK_BIP:
bytes = bip_receive(
src, pdu, max_pdu, timeout);
bytes = bip_receive(src, pdu, max_pdu, timeout);
break;
case DATALINK_BIP6:
bytes = bip6_receive(
src, pdu, max_pdu, timeout);
bytes = bip6_receive(src, pdu, max_pdu, timeout);
break;
case DATALINK_MSTP:
bytes = dlmstp_receive(
src, pdu, max_pdu, timeout);
bytes = dlmstp_receive(src, pdu, max_pdu, timeout);
break;
default:
break;
+2 -2
View File
@@ -287,8 +287,8 @@ void dlenv_network_port_init(void)
Network_Port_BBMD_FD_Table_Set(instance, bvlc_fdt_list());
/* foreign device registration */
bvlc_address_get(&BBMD_Address, &addr0, &addr1, &addr2, &addr3);
Network_Port_Remote_BBMD_IP_Address_Set(instance,
addr0, addr1, addr2, addr3);
Network_Port_Remote_BBMD_IP_Address_Set(
instance, addr0, addr1, addr2, addr3);
Network_Port_Remote_BBMD_BIP_Port_Set(instance, BBMD_Address.port);
Network_Port_Remote_BBMD_BIP_Lifetime_Set(instance, BBMD_TTL_Seconds);
#endif
+2 -2
View File
@@ -658,9 +658,9 @@ bool MSTP_Master_Node_FSM(volatile struct mstp_port_struct_t *mstp_port)
break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
if ((mstp_port->DestinationAddress ==
MSTP_BROADCAST_ADDRESS) &&
MSTP_BROADCAST_ADDRESS) &&
(npdu_confirmed_service(mstp_port->InputBuffer,
mstp_port->DataLength))) {
mstp_port->DataLength))) {
/* BTL test: verifies that the IUT will quietly
discard any Confirmed-Request-PDU, whose
destination address is a multicast or