Run clang-format and enable CI check for it (#755)
* pre-commit: Update and enable clang-format check There is newer version from clang-format so use that. We do not yet want 18 as that is little bit too new. * Format some thing by hand which clang-format "breaks" Clang-format will format some things little bit off in some cases. Format some things by hand so we get cleaner end result. * Run clang-format with ``` pre-commit run --all-files clang-format ``` We have already in previously checked places where clang-format does not make good format and ignored those (hopefully most of the things). --------- Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
@@ -19,47 +19,43 @@
|
||||
#include "bacnet/npdu.h"
|
||||
|
||||
/* specific defines for ARCNET */
|
||||
#define ARCNET_HEADER_MAX (1+1+2+2+1+1+1+1)
|
||||
#define ARCNET_MPDU_MAX (ARCNET_HEADER_MAX+MAX_PDU)
|
||||
#define ARCNET_HEADER_MAX (1 + 1 + 2 + 2 + 1 + 1 + 1 + 1)
|
||||
#define ARCNET_MPDU_MAX (ARCNET_HEADER_MAX + MAX_PDU)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool arcnet_valid(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void arcnet_cleanup(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool arcnet_init(
|
||||
char *interface_name);
|
||||
BACNET_STACK_EXPORT
|
||||
bool arcnet_valid(void);
|
||||
BACNET_STACK_EXPORT
|
||||
void arcnet_cleanup(void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool arcnet_init(char *interface_name);
|
||||
|
||||
/* function to send a packet out the 802.2 socket */
|
||||
/* returns zero on success, non-zero on failure */
|
||||
BACNET_STACK_EXPORT
|
||||
int arcnet_send_pdu(
|
||||
BACNET_ADDRESS * dest, /* destination address */
|
||||
BACNET_NPDU_DATA * npdu_data, /* network information */
|
||||
uint8_t * pdu, /* any data to be sent - may be null */
|
||||
unsigned pdu_len); /* number of bytes of data */
|
||||
BACNET_STACK_EXPORT
|
||||
int arcnet_send_pdu(
|
||||
BACNET_ADDRESS *dest, /* destination address */
|
||||
BACNET_NPDU_DATA *npdu_data, /* network information */
|
||||
uint8_t *pdu, /* any data to be sent - may be null */
|
||||
unsigned pdu_len); /* number of bytes of data */
|
||||
|
||||
/* receives an framed packet */
|
||||
/* returns the number of octets in the PDU, or zero on failure */
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t arcnet_receive(
|
||||
BACNET_ADDRESS * src, /* source address */
|
||||
uint8_t * pdu, /* PDU data */
|
||||
uint16_t max_pdu, /* amount of space available in the PDU */
|
||||
unsigned timeout); /* milliseconds to wait for a packet */
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t arcnet_receive(
|
||||
BACNET_ADDRESS *src, /* source address */
|
||||
uint8_t *pdu, /* PDU data */
|
||||
uint16_t max_pdu, /* amount of space available in the PDU */
|
||||
unsigned timeout); /* milliseconds to wait for a packet */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void arcnet_get_my_address(
|
||||
BACNET_ADDRESS * my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void arcnet_get_broadcast_address(
|
||||
BACNET_ADDRESS * dest); /* destination address */
|
||||
BACNET_STACK_EXPORT
|
||||
void arcnet_get_my_address(BACNET_ADDRESS *my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void arcnet_get_broadcast_address(
|
||||
BACNET_ADDRESS *dest); /* destination address */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -26,39 +26,23 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void automac_init(
|
||||
void);
|
||||
void automac_init(void);
|
||||
|
||||
bool automac_free_address_valid(
|
||||
uint8_t mac);
|
||||
uint8_t automac_free_address_count(
|
||||
void);
|
||||
uint8_t automac_free_address_mac(
|
||||
uint8_t count);
|
||||
uint8_t automac_free_address_random(
|
||||
void);
|
||||
void automac_pfm_set(
|
||||
uint8_t mac);
|
||||
void automac_token_set(
|
||||
uint8_t mac);
|
||||
void automac_emitter_set(
|
||||
uint8_t mac);
|
||||
uint8_t automac_next_station(
|
||||
uint8_t mac);
|
||||
uint8_t automac_address(
|
||||
void);
|
||||
void automac_address_set(
|
||||
uint8_t mac);
|
||||
void automac_address_init(
|
||||
void);
|
||||
uint16_t automac_time_slot(
|
||||
void);
|
||||
bool automac_pfm_cycle_complete(
|
||||
void);
|
||||
bool automac_enabled(
|
||||
void);
|
||||
void automac_enabled_set(
|
||||
bool status);
|
||||
bool automac_free_address_valid(uint8_t mac);
|
||||
uint8_t automac_free_address_count(void);
|
||||
uint8_t automac_free_address_mac(uint8_t count);
|
||||
uint8_t automac_free_address_random(void);
|
||||
void automac_pfm_set(uint8_t mac);
|
||||
void automac_token_set(uint8_t mac);
|
||||
void automac_emitter_set(uint8_t mac);
|
||||
uint8_t automac_next_station(uint8_t mac);
|
||||
uint8_t automac_address(void);
|
||||
void automac_address_set(uint8_t mac);
|
||||
void automac_address_init(void);
|
||||
uint16_t automac_time_slot(void);
|
||||
bool automac_pfm_cycle_complete(void);
|
||||
bool automac_enabled(void);
|
||||
void automac_enabled_set(bool status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -162,7 +162,8 @@ int encode_security_payload(
|
||||
return (int)(2 + payload->payload_length);
|
||||
}
|
||||
|
||||
int encode_security_response(uint8_t *apdu, const BACNET_SECURITY_RESPONSE *resp)
|
||||
int encode_security_response(
|
||||
uint8_t *apdu, const BACNET_SECURITY_RESPONSE *resp)
|
||||
{
|
||||
int curr = 0;
|
||||
int i;
|
||||
@@ -190,7 +191,8 @@ int encode_security_response(uint8_t *apdu, const BACNET_SECURITY_RESPONSE *resp
|
||||
case SEC_RESP_UNKNOWN_AUTHENTICATION_TYPE:
|
||||
apdu[curr++] = resp->response.unknown_authentication_type
|
||||
.original_authentication_type;
|
||||
curr += encode_unsigned16(&apdu[curr],
|
||||
curr += encode_unsigned16(
|
||||
&apdu[curr],
|
||||
resp->response.unknown_authentication_type.vendor_id);
|
||||
break;
|
||||
case SEC_RESP_UNKNOWN_KEY:
|
||||
@@ -234,7 +236,8 @@ int encode_security_response(uint8_t *apdu, const BACNET_SECURITY_RESPONSE *resp
|
||||
return curr;
|
||||
}
|
||||
|
||||
int encode_request_key_update(uint8_t *apdu, const BACNET_REQUEST_KEY_UPDATE *req)
|
||||
int encode_request_key_update(
|
||||
uint8_t *apdu, const BACNET_REQUEST_KEY_UPDATE *req)
|
||||
{
|
||||
int curr = 0;
|
||||
|
||||
@@ -352,13 +355,15 @@ int encode_request_master_key(
|
||||
int curr = 0;
|
||||
|
||||
apdu[curr++] = req_master_key->no_supported_algorithms;
|
||||
memcpy(&apdu[curr], req_master_key->es_algorithms,
|
||||
memcpy(
|
||||
&apdu[curr], req_master_key->es_algorithms,
|
||||
req_master_key->no_supported_algorithms);
|
||||
|
||||
return (int)(curr + req_master_key->no_supported_algorithms);
|
||||
}
|
||||
|
||||
int encode_set_master_key(uint8_t *apdu, const BACNET_SET_MASTER_KEY *set_master_key)
|
||||
int encode_set_master_key(
|
||||
uint8_t *apdu, const BACNET_SET_MASTER_KEY *set_master_key)
|
||||
{
|
||||
return encode_key_entry(apdu, &set_master_key->key);
|
||||
}
|
||||
@@ -475,7 +480,8 @@ int decode_security_wrapper_safe(int bytes_before,
|
||||
}
|
||||
#endif
|
||||
|
||||
int decode_challenge_request_safe(const uint8_t *apdu,
|
||||
int decode_challenge_request_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_CHALLENGE_REQUEST *bc_req)
|
||||
{
|
||||
@@ -491,7 +497,8 @@ int decode_challenge_request_safe(const uint8_t *apdu,
|
||||
return curr; /* always 9! */
|
||||
}
|
||||
|
||||
int decode_security_payload_safe(const uint8_t *apdu,
|
||||
int decode_security_payload_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_SECURITY_PAYLOAD *payload)
|
||||
{
|
||||
@@ -556,7 +563,8 @@ int decode_security_response_safe(
|
||||
}
|
||||
resp->response.unknown_authentication_type
|
||||
.original_authentication_type = apdu[curr++];
|
||||
curr += decode_unsigned16(&apdu[curr],
|
||||
curr += decode_unsigned16(
|
||||
&apdu[curr],
|
||||
&resp->response.unknown_authentication_type.vendor_id);
|
||||
if (resp->response.unknown_authentication_type
|
||||
.original_authentication_type < 200 &&
|
||||
@@ -712,7 +720,8 @@ int decode_update_key_set_safe(
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < (int)key_set->set_key_count[0]; i++) {
|
||||
res = decode_key_entry_safe(apdu + curr, apdu_len_remaining - curr,
|
||||
res = decode_key_entry_safe(
|
||||
apdu + curr, apdu_len_remaining - curr,
|
||||
&key_set->set_keys[0][i]);
|
||||
if (res < 0) {
|
||||
return -1;
|
||||
@@ -739,7 +748,8 @@ int decode_update_key_set_safe(
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < (int)key_set->set_key_count[1]; i++) {
|
||||
res = decode_key_entry_safe(apdu + curr, apdu_len_remaining - curr,
|
||||
res = decode_key_entry_safe(
|
||||
apdu + curr, apdu_len_remaining - curr,
|
||||
&key_set->set_keys[1][i]);
|
||||
if (res < 0) {
|
||||
return -1;
|
||||
@@ -751,7 +761,8 @@ int decode_update_key_set_safe(
|
||||
return curr;
|
||||
}
|
||||
|
||||
int decode_update_distribution_key_safe(const uint8_t *apdu,
|
||||
int decode_update_distribution_key_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_UPDATE_DISTRIBUTION_KEY *dist_key)
|
||||
{
|
||||
@@ -770,7 +781,8 @@ int decode_update_distribution_key_safe(const uint8_t *apdu,
|
||||
return curr + res;
|
||||
}
|
||||
|
||||
int decode_request_master_key_safe(const uint8_t *apdu,
|
||||
int decode_request_master_key_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_REQUEST_MASTER_KEY *req_master_key)
|
||||
{
|
||||
@@ -783,13 +795,15 @@ int decode_request_master_key_safe(const uint8_t *apdu,
|
||||
if (apdu_len_remaining < curr + req_master_key->no_supported_algorithms) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(req_master_key->es_algorithms, &apdu[curr],
|
||||
memcpy(
|
||||
req_master_key->es_algorithms, &apdu[curr],
|
||||
req_master_key->no_supported_algorithms);
|
||||
|
||||
return (int)(curr + req_master_key->no_supported_algorithms);
|
||||
}
|
||||
|
||||
int decode_set_master_key_safe(const uint8_t *apdu,
|
||||
int decode_set_master_key_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_SET_MASTER_KEY *set_master_key)
|
||||
{
|
||||
|
||||
+137
-136
@@ -25,17 +25,17 @@
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
typedef struct BACnet_Security_Wrapper {
|
||||
bool payload_net_or_bvll_flag; /* true if NPDU or BVLL */
|
||||
bool payload_net_or_bvll_flag; /* true if NPDU or BVLL */
|
||||
bool encrypted_flag;
|
||||
bool authentication_flag; /* always false for responses */
|
||||
bool do_not_unwrap_flag; /* always true if do-not-encrypt is true */
|
||||
bool do_not_decrypt_flag; /* when encrypted flag is false, it also false */
|
||||
bool authentication_flag; /* always false for responses */
|
||||
bool do_not_unwrap_flag; /* always true if do-not-encrypt is true */
|
||||
bool do_not_decrypt_flag; /* when encrypted flag is false, it also false */
|
||||
bool non_trusted_source_flag;
|
||||
bool secured_by_router_flag;
|
||||
uint8_t key_revision; /* 0 for Device-Master key */
|
||||
uint8_t key_revision; /* 0 for Device-Master key */
|
||||
uint16_t key_identifier;
|
||||
uint32_t source_device_instance;
|
||||
uint32_t message_id; /* monotonically increased value */
|
||||
uint32_t message_id; /* monotonically increased value */
|
||||
uint32_t timestamp; /* seconds from UTC 1970-1-1 00:00:00 */
|
||||
uint32_t destination_device_instance;
|
||||
uint16_t dnet;
|
||||
@@ -44,32 +44,34 @@ typedef struct BACnet_Security_Wrapper {
|
||||
uint16_t snet;
|
||||
uint8_t slen;
|
||||
uint8_t sadr[MAX_MAC_LEN];
|
||||
uint8_t authentication_mechanism; /* present when User-Authenticated or
|
||||
* Application-Specific keys are used with: */
|
||||
uint8_t
|
||||
authentication_mechanism; /* present when User-Authenticated or
|
||||
* Application-Specific keys are used with: */
|
||||
/* APDU: Confrmed-Request, Unconfirmed-Request */
|
||||
/* NPDU: Initialize-Routing-Table, Establish-Connection-To-Network,
|
||||
* Disconnect-Connection-To-Network */
|
||||
/* BVLL: Write-Broadcast-Distribution-Table, Read-Broadcast-Distribution-Table,
|
||||
* Register-Foreign-Device, Read-Foreign-Device-Table,
|
||||
* Delete-Foreign-Device-Table-Entry */
|
||||
/* BVLL: Write-Broadcast-Distribution-Table,
|
||||
* Read-Broadcast-Distribution-Table, Register-Foreign-Device,
|
||||
* Read-Foreign-Device-Table, Delete-Foreign-Device-Table-Entry */
|
||||
/* 0 is only legitimate value for now. 200-255 are vendor-specific */
|
||||
uint16_t user_id; /* 0 for unknown */
|
||||
uint8_t user_role; /* 0 and 1 are "system users": 0 for device-to-device non-human,
|
||||
* 1 for device-to-device by unknown human */
|
||||
uint16_t authentication_data_length; /* authentication mechanism 1-255 */
|
||||
uint16_t user_id; /* 0 for unknown */
|
||||
uint8_t user_role; /* 0 and 1 are "system users": 0 for device-to-device
|
||||
* non-human, 1 for device-to-device by unknown human */
|
||||
uint16_t authentication_data_length; /* authentication mechanism 1-255 */
|
||||
uint16_t vendor_id; /* authentication mechanism 200-255 */
|
||||
uint8_t authentication_data[MAX_AUTH_DATA_LEN]; /* other than id, role, length and
|
||||
* vendor-id */
|
||||
uint16_t service_data_len; /* case-to-case */
|
||||
uint8_t authentication_data[MAX_AUTH_DATA_LEN]; /* other than id, role,
|
||||
* length and vendor-id */
|
||||
uint16_t service_data_len; /* case-to-case */
|
||||
uint8_t *service_data;
|
||||
uint8_t service_type; /* first octet of service_data */
|
||||
uint16_t padding_len; /* included in padding */
|
||||
uint8_t service_type; /* first octet of service_data */
|
||||
uint16_t padding_len; /* included in padding */
|
||||
uint8_t padding[MAX_PAD_LEN];
|
||||
uint8_t signature[SIGNATURE_LEN]; /* hmac-md5 or hmac-sha256, first 16 bytes */
|
||||
uint8_t
|
||||
signature[SIGNATURE_LEN]; /* hmac-md5 or hmac-sha256, first 16 bytes */
|
||||
} BACNET_SECURITY_WRAPPER;
|
||||
|
||||
typedef struct Challenge_Request {
|
||||
uint8_t message_challenge; /* 1 as a response, everything else for other */
|
||||
uint8_t message_challenge; /* 1 as a response, everything else for other */
|
||||
uint32_t orig_message_id;
|
||||
uint32_t orig_timestamp;
|
||||
} BACNET_CHALLENGE_REQUEST;
|
||||
@@ -148,7 +150,7 @@ typedef struct Key_Entry {
|
||||
typedef struct Update_Key_Set {
|
||||
bool set_rae[2], set_ck[2], set_clr[2];
|
||||
bool more;
|
||||
bool remove; /* false for add, true for remove */
|
||||
bool remove; /* false for add, true for remove */
|
||||
uint8_t set_key_revision[2];
|
||||
uint32_t set_activation_time[2];
|
||||
uint32_t set_expiration_time[2];
|
||||
@@ -175,127 +177,126 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* helper functions */
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_KEY_IDENTIFIER_ALGORITHM key_algorithm(uint16_t id);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_KEY_IDENTIFIER_KEY_NUMBER key_number(uint16_t id);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_KEY_IDENTIFIER_ALGORITHM key_algorithm(uint16_t id);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_KEY_IDENTIFIER_KEY_NUMBER key_number(uint16_t id);
|
||||
|
||||
/* key manipulation functions - port specific! */
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_SECURITY_RESPONSE_CODE bacnet_master_key_set(BACNET_SET_MASTER_KEY *
|
||||
key);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_SECURITY_RESPONSE_CODE
|
||||
bacnet_distribution_key_update(BACNET_UPDATE_DISTRIBUTION_KEY * key);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_SECURITY_RESPONSE_CODE bacnet_key_set_update(BACNET_UPDATE_KEY_SET *
|
||||
update_key_sets);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_SECURITY_RESPONSE_CODE bacnet_find_key(uint8_t revision,
|
||||
BACNET_KEY_ENTRY * key);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_SECURITY_RESPONSE_CODE bacnet_master_key_set(BACNET_SET_MASTER_KEY *key);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_SECURITY_RESPONSE_CODE
|
||||
bacnet_distribution_key_update(BACNET_UPDATE_DISTRIBUTION_KEY *key);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_SECURITY_RESPONSE_CODE
|
||||
bacnet_key_set_update(BACNET_UPDATE_KEY_SET *update_key_sets);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_SECURITY_RESPONSE_CODE
|
||||
bacnet_find_key(uint8_t revision, BACNET_KEY_ENTRY *key);
|
||||
|
||||
/* signing/verification and encryption/decryption - port specific */
|
||||
BACNET_STACK_EXPORT
|
||||
int key_sign_msg(BACNET_KEY_ENTRY * key,
|
||||
uint8_t * msg,
|
||||
uint32_t msg_len,
|
||||
uint8_t * signature);
|
||||
/* BACNET_STACK_EXPORT */
|
||||
/* bool key_verify_sign_msg(BACNET_KEY_ENTRY * key, */
|
||||
/* uint8_t * msg, */
|
||||
/* uint32_t msg_len, */
|
||||
/* uint8_t * signature); */
|
||||
BACNET_STACK_EXPORT
|
||||
int key_encrypt_msg(BACNET_KEY_ENTRY * key,
|
||||
uint8_t * msg,
|
||||
uint32_t msg_len,
|
||||
uint8_t * signature);
|
||||
BACNET_STACK_EXPORT
|
||||
bool key_decrypt_msg(BACNET_KEY_ENTRY * key,
|
||||
uint8_t * msg,
|
||||
uint32_t msg_len,
|
||||
uint8_t * signature);
|
||||
BACNET_STACK_EXPORT
|
||||
void key_set_padding(BACNET_KEY_ENTRY * key,
|
||||
int enc_len,
|
||||
uint16_t * padding_len,
|
||||
uint8_t * padding);
|
||||
BACNET_STACK_EXPORT
|
||||
int key_sign_msg(
|
||||
BACNET_KEY_ENTRY *key, uint8_t *msg, uint32_t msg_len, uint8_t *signature);
|
||||
/* BACNET_STACK_EXPORT */
|
||||
/* bool key_verify_sign_msg(BACNET_KEY_ENTRY * key, */
|
||||
/* uint8_t * msg, */
|
||||
/* uint32_t msg_len, */
|
||||
/* uint8_t * signature); */
|
||||
BACNET_STACK_EXPORT
|
||||
int key_encrypt_msg(
|
||||
BACNET_KEY_ENTRY *key, uint8_t *msg, uint32_t msg_len, uint8_t *signature);
|
||||
BACNET_STACK_EXPORT
|
||||
bool key_decrypt_msg(
|
||||
BACNET_KEY_ENTRY *key, uint8_t *msg, uint32_t msg_len, uint8_t *signature);
|
||||
BACNET_STACK_EXPORT
|
||||
void key_set_padding(
|
||||
BACNET_KEY_ENTRY *key,
|
||||
int enc_len,
|
||||
uint16_t *padding_len,
|
||||
uint8_t *padding);
|
||||
|
||||
/* encoders */
|
||||
/* BACNET_STACK_EXPORT */
|
||||
/* int encode_security_wrapper(int bytes_before, */
|
||||
/* uint8_t * apdu, */
|
||||
/* BACNET_SECURITY_WRAPPER * wrapper); */
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_challenge_request(uint8_t * apdu,
|
||||
const BACNET_CHALLENGE_REQUEST * bc_req);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_security_payload(uint8_t * apdu,
|
||||
const BACNET_SECURITY_PAYLOAD * payload);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_security_response(uint8_t * apdu,
|
||||
const BACNET_SECURITY_RESPONSE * resp);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_request_key_update(uint8_t * apdu,
|
||||
const BACNET_REQUEST_KEY_UPDATE * req);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_key_entry(uint8_t * apdu,
|
||||
const BACNET_KEY_ENTRY * entry);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_update_key_set(uint8_t * apdu,
|
||||
const BACNET_UPDATE_KEY_SET * key_set);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_update_distribution_key(uint8_t * apdu,
|
||||
const BACNET_UPDATE_DISTRIBUTION_KEY * dist_key);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_request_master_key(uint8_t * apdu,
|
||||
const BACNET_REQUEST_MASTER_KEY * req_master_key);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_set_master_key(uint8_t * apdu,
|
||||
const BACNET_SET_MASTER_KEY * set_master_key);
|
||||
/* BACNET_STACK_EXPORT */
|
||||
/* int encode_security_wrapper(int bytes_before, */
|
||||
/* uint8_t * apdu, */
|
||||
/* BACNET_SECURITY_WRAPPER * wrapper); */
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_challenge_request(
|
||||
uint8_t *apdu, const BACNET_CHALLENGE_REQUEST *bc_req);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_security_payload(
|
||||
uint8_t *apdu, const BACNET_SECURITY_PAYLOAD *payload);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_security_response(
|
||||
uint8_t *apdu, const BACNET_SECURITY_RESPONSE *resp);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_request_key_update(
|
||||
uint8_t *apdu, const BACNET_REQUEST_KEY_UPDATE *req);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_key_entry(uint8_t *apdu, const BACNET_KEY_ENTRY *entry);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_update_key_set(uint8_t *apdu, const BACNET_UPDATE_KEY_SET *key_set);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_update_distribution_key(
|
||||
uint8_t *apdu, const BACNET_UPDATE_DISTRIBUTION_KEY *dist_key);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_request_master_key(
|
||||
uint8_t *apdu, const BACNET_REQUEST_MASTER_KEY *req_master_key);
|
||||
BACNET_STACK_EXPORT
|
||||
int encode_set_master_key(
|
||||
uint8_t *apdu, const BACNET_SET_MASTER_KEY *set_master_key);
|
||||
|
||||
/* safe decoders */
|
||||
/* BACNET_STACK_EXPORT */
|
||||
/* int decode_security_wrapper_safe(int bytes_before, */
|
||||
/* uint8_t * apdu, */
|
||||
/* uint32_t apdu_len_remaining, */
|
||||
/* BACNET_SECURITY_WRAPPER * wrapper); */
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_challenge_request_safe(const uint8_t * apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_CHALLENGE_REQUEST * bc_req);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_security_payload_safe(const uint8_t * apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_SECURITY_PAYLOAD * payload);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_security_response_safe(const uint8_t * apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_SECURITY_RESPONSE * resp);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_request_key_update_safe(const uint8_t * apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_REQUEST_KEY_UPDATE * req);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_key_entry_safe(const uint8_t * apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_KEY_ENTRY * entry);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_update_key_set_safe(const uint8_t * apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_UPDATE_KEY_SET * key_set);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_update_distribution_key_safe(const uint8_t * apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_UPDATE_DISTRIBUTION_KEY * dist_key);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_request_master_key_safe(const uint8_t * apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_REQUEST_MASTER_KEY * req_master_key);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_set_master_key_safe(const uint8_t * apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_SET_MASTER_KEY * set_master_key);
|
||||
/* BACNET_STACK_EXPORT */
|
||||
/* int decode_security_wrapper_safe(int bytes_before, */
|
||||
/* uint8_t * apdu, */
|
||||
/* uint32_t apdu_len_remaining, */
|
||||
/* BACNET_SECURITY_WRAPPER * wrapper); */
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_challenge_request_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_CHALLENGE_REQUEST *bc_req);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_security_payload_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_SECURITY_PAYLOAD *payload);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_security_response_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_SECURITY_RESPONSE *resp);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_request_key_update_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_REQUEST_KEY_UPDATE *req);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_key_entry_safe(
|
||||
const uint8_t *apdu, uint32_t apdu_len_remaining, BACNET_KEY_ENTRY *entry);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_update_key_set_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_UPDATE_KEY_SET *key_set);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_update_distribution_key_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_UPDATE_DISTRIBUTION_KEY *dist_key);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_request_master_key_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_REQUEST_MASTER_KEY *req_master_key);
|
||||
BACNET_STACK_EXPORT
|
||||
int decode_set_master_key_safe(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_len_remaining,
|
||||
BACNET_SET_MASTER_KEY *set_master_key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+61
-63
@@ -26,92 +26,90 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* note: define init, set_interface, and cleanup in your port */
|
||||
/* on Linux, ifname is eth0, ath0, arc0, and others.
|
||||
on Windows, ifname is the dotted ip address of the interface */
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_init(char *ifname);
|
||||
/* note: define init, set_interface, and cleanup in your port */
|
||||
/* on Linux, ifname is eth0, ath0, arc0, and others.
|
||||
on Windows, ifname is the dotted ip address of the interface */
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_init(char *ifname);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_set_interface(const char *ifname);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_set_interface(const char *ifname);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_cleanup(void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_cleanup(void);
|
||||
|
||||
/* common BACnet/IP functions */
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_valid(void);
|
||||
/* common BACnet/IP functions */
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_valid(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_get_broadcast_address(BACNET_ADDRESS *dest);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_get_broadcast_address(BACNET_ADDRESS *dest);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_get_my_address(BACNET_ADDRESS *my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_get_my_address(BACNET_ADDRESS *my_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bip_send_pdu(BACNET_ADDRESS *dest,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *pdu,
|
||||
unsigned pdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bip_send_pdu(
|
||||
BACNET_ADDRESS *dest,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *pdu,
|
||||
unsigned pdu_len);
|
||||
|
||||
/* implement in ports module */
|
||||
BACNET_STACK_EXPORT
|
||||
int bip_send_mpdu(
|
||||
const BACNET_IP_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len);
|
||||
/* implement in ports module */
|
||||
BACNET_STACK_EXPORT
|
||||
int bip_send_mpdu(
|
||||
const BACNET_IP_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bip_receive(BACNET_ADDRESS *src,
|
||||
uint8_t *pdu,
|
||||
uint16_t max_pdu,
|
||||
unsigned timeout);
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bip_receive(
|
||||
BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, unsigned timeout);
|
||||
|
||||
/* use host byte order for setting UDP port */
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_set_port(uint16_t port);
|
||||
/* use host byte order for setting UDP port */
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_set_port(uint16_t port);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_port_changed(void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_port_changed(void);
|
||||
|
||||
/* returns host byte order of UDP port */
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bip_get_port(void);
|
||||
/* returns host byte order of UDP port */
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bip_get_port(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_set_addr(const BACNET_IP_ADDRESS *addr);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_set_addr(const BACNET_IP_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_get_addr(BACNET_IP_ADDRESS *addr);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_get_addr(BACNET_IP_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_get_addr_by_name(const char *host_name, BACNET_IP_ADDRESS *addr);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_get_addr_by_name(const char *host_name, BACNET_IP_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_set_broadcast_addr(const BACNET_IP_ADDRESS *addr);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_set_broadcast_addr(const BACNET_IP_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_get_broadcast_addr(BACNET_IP_ADDRESS *addr);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_get_broadcast_addr(BACNET_IP_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_set_subnet_prefix(uint8_t prefix);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip_set_subnet_prefix(uint8_t prefix);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t bip_get_subnet_prefix(void);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t bip_get_subnet_prefix(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_debug_enable(void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_debug_enable(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_debug_disable(void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_debug_disable(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bip_get_socket(void);
|
||||
BACNET_STACK_EXPORT
|
||||
int bip_get_socket(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bip_get_broadcast_socket(void);
|
||||
BACNET_STACK_EXPORT
|
||||
int bip_get_broadcast_socket(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bip_set_broadcast_binding(
|
||||
const char *ip4_broadcast);
|
||||
BACNET_STACK_EXPORT
|
||||
int bip_set_broadcast_binding(const char *ip4_broadcast);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+60
-80
@@ -1,16 +1,16 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief BACnet/IPv6 datalink API and defines
|
||||
* @author Steve Karg
|
||||
* @date 2015
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
* @details Implementation of the Network Layer using BACnet/IPv6 as the transport,
|
||||
* as described in ASHRAE 135 Annex J.
|
||||
* The functions described here fulfill the roles defined generically at the
|
||||
* DataLink level by serving as the implementation of the function templates.
|
||||
* @defgroup DLBIP6 BACnet/IPv6 DataLink Network Layer
|
||||
* @ingroup DataLink
|
||||
*/
|
||||
* @file
|
||||
* @brief BACnet/IPv6 datalink API and defines
|
||||
* @author Steve Karg
|
||||
* @date 2015
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
* @details Implementation of the Network Layer using BACnet/IPv6 as the
|
||||
* transport, as described in ASHRAE 135 Annex J. The functions described here
|
||||
* fulfill the roles defined generically at the DataLink level by serving as the
|
||||
* implementation of the function templates.
|
||||
* @defgroup DLBIP6 BACnet/IPv6 DataLink Network Layer
|
||||
* @ingroup DataLink
|
||||
*/
|
||||
#ifndef BACNET_BIP6_H
|
||||
#define BACNET_BIP6_H
|
||||
|
||||
@@ -25,86 +25,66 @@
|
||||
|
||||
/* specific defines for BACnet/IP over Ethernet */
|
||||
#define BIP6_HEADER_MAX (1 + 1 + 2)
|
||||
#define BIP6_MPDU_MAX (BIP6_HEADER_MAX+MAX_PDU)
|
||||
#define BIP6_MPDU_MAX (BIP6_HEADER_MAX + MAX_PDU)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* 6 datalink functions used by demo handlers and applications:
|
||||
init, send, receive, cleanup, unicast/broadcast address.
|
||||
Note: the addresses used here are VMAC addresses. */
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_init(
|
||||
char *ifname);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_cleanup(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_get_broadcast_address(
|
||||
BACNET_ADDRESS * my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_get_my_address(
|
||||
BACNET_ADDRESS * my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bip6_send_pdu(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data,
|
||||
uint8_t * pdu,
|
||||
unsigned pdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bip6_receive(
|
||||
BACNET_ADDRESS * src,
|
||||
uint8_t * pdu,
|
||||
uint16_t max_pdu,
|
||||
unsigned timeout);
|
||||
/* 6 datalink functions used by demo handlers and applications:
|
||||
init, send, receive, cleanup, unicast/broadcast address.
|
||||
Note: the addresses used here are VMAC addresses. */
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_init(char *ifname);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_cleanup(void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_get_broadcast_address(BACNET_ADDRESS *my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_get_my_address(BACNET_ADDRESS *my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bip6_send_pdu(
|
||||
BACNET_ADDRESS *dest,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *pdu,
|
||||
unsigned pdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bip6_receive(
|
||||
BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, unsigned timeout);
|
||||
|
||||
/* functions that are custom per port */
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_set_interface(
|
||||
char *ifname);
|
||||
/* functions that are custom per port */
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_set_interface(char *ifname);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_address_match_self(
|
||||
const BACNET_IP6_ADDRESS *addr);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_address_match_self(const BACNET_IP6_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_set_addr(
|
||||
const BACNET_IP6_ADDRESS *addr);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_get_addr(
|
||||
BACNET_IP6_ADDRESS *addr);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_set_addr(const BACNET_IP6_ADDRESS *addr);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_get_addr(BACNET_IP6_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_set_port(
|
||||
uint16_t port);
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bip6_get_port(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_set_port(uint16_t port);
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bip6_get_port(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_set_broadcast_addr(
|
||||
const BACNET_IP6_ADDRESS *addr);
|
||||
/* returns network byte order */
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_get_broadcast_addr(
|
||||
BACNET_IP6_ADDRESS *addr);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_set_broadcast_addr(const BACNET_IP6_ADDRESS *addr);
|
||||
/* returns network byte order */
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_get_broadcast_addr(BACNET_IP6_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bip6_send_mpdu(
|
||||
const BACNET_IP6_ADDRESS *addr,
|
||||
const uint8_t * mtu,
|
||||
uint16_t mtu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_send_pdu_queue_empty(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_receive_callback(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
int bip6_send_mpdu(
|
||||
const BACNET_IP6_ADDRESS *addr, const uint8_t *mtu, uint16_t mtu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bip6_send_pdu_queue_empty(void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_receive_callback(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_debug_enable(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip6_debug_enable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+71
-40
@@ -56,7 +56,8 @@ int bvlc_encode_header(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_header(const uint8_t *pdu,
|
||||
int bvlc_decode_header(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *message_type,
|
||||
uint16_t *message_length)
|
||||
@@ -406,8 +407,7 @@ bool bvlc_broadcast_distribution_mask_from_host(
|
||||
* @return true if the broadcast distribution was retrieved
|
||||
*/
|
||||
bool bvlc_broadcast_distribution_mask_to_host(
|
||||
uint32_t *broadcast_mask,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask)
|
||||
uint32_t *broadcast_mask, const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
@@ -521,7 +521,8 @@ bool bvlc_broadcast_distribution_table_entry_forward_address(
|
||||
* @param bdt_head - head of the BDT linked list
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
int bvlc_broadcast_distribution_table_encode(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head)
|
||||
{
|
||||
@@ -541,7 +542,8 @@ 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],
|
||||
octetstring_init(
|
||||
&octet_string, &bdt_entry->dest_address.address[0],
|
||||
IP_ADDRESS_MAX);
|
||||
len =
|
||||
encode_context_octet_string(&apdu[apdu_len], 1, &octet_string);
|
||||
@@ -557,8 +559,9 @@ int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
len = encode_closing_tag(&apdu[apdu_len], 0);
|
||||
apdu_len += len;
|
||||
/* broadcast-mask [1] OCTET STRING */
|
||||
octetstring_init(&octet_string,
|
||||
&bdt_entry->broadcast_mask.address[0], IP_ADDRESS_MAX);
|
||||
octetstring_init(
|
||||
&octet_string, &bdt_entry->broadcast_mask.address[0],
|
||||
IP_ADDRESS_MAX);
|
||||
len =
|
||||
encode_context_octet_string(&apdu[apdu_len], 1, &octet_string);
|
||||
apdu_len += len;
|
||||
@@ -584,7 +587,8 @@ int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
* @param bdt_head - head of a BDT linked list
|
||||
* @return length of the APDU buffer decoded, or ERROR, REJECT, or ABORT
|
||||
*/
|
||||
int bvlc_broadcast_distribution_table_decode(const uint8_t *apdu,
|
||||
int bvlc_broadcast_distribution_table_decode(
|
||||
const uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_ERROR_CODE *error_code,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head)
|
||||
@@ -698,8 +702,9 @@ int bvlc_broadcast_distribution_table_decode(const uint8_t *apdu,
|
||||
if (len > apdu_len) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
(void)octetstring_copy_value(&bdt_entry->broadcast_mask.address[0],
|
||||
IP_ADDRESS_MAX, &octet_string);
|
||||
(void)octetstring_copy_value(
|
||||
&bdt_entry->broadcast_mask.address[0], IP_ADDRESS_MAX,
|
||||
&octet_string);
|
||||
bdt_entry->valid = true;
|
||||
/* next entry */
|
||||
bdt_entry = bdt_entry->next;
|
||||
@@ -726,7 +731,8 @@ int bvlc_broadcast_distribution_table_decode(const uint8_t *apdu,
|
||||
* BVLC Length: 2-octets L Length L, in octets, of the BVLL message
|
||||
* List of BDT Entries: N*10-octets
|
||||
*/
|
||||
int bvlc_encode_write_broadcast_distribution_table(uint8_t *pdu,
|
||||
int bvlc_encode_write_broadcast_distribution_table(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list)
|
||||
{
|
||||
@@ -771,7 +777,8 @@ int bvlc_encode_write_broadcast_distribution_table(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_write_broadcast_distribution_table(const uint8_t *pdu,
|
||||
int bvlc_decode_write_broadcast_distribution_table(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list)
|
||||
{
|
||||
@@ -856,7 +863,8 @@ int bvlc_encode_read_broadcast_distribution_table(
|
||||
* BVLC Length: 2-octets L length, in octets, of the BVLL message
|
||||
* List of BDT Entries: N*10-octets
|
||||
*/
|
||||
int bvlc_encode_read_broadcast_distribution_table_ack(uint8_t *pdu,
|
||||
int bvlc_encode_read_broadcast_distribution_table_ack(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list)
|
||||
{
|
||||
@@ -901,7 +909,8 @@ int bvlc_encode_read_broadcast_distribution_table_ack(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_read_broadcast_distribution_table_ack(const uint8_t *pdu,
|
||||
int bvlc_decode_read_broadcast_distribution_table_ack(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list)
|
||||
{
|
||||
@@ -956,7 +965,8 @@ int bvlc_decode_read_broadcast_distribution_table_ack(const uint8_t *pdu,
|
||||
* B/IP Address of Originating Device: 6-octets
|
||||
* BACnet NPDU from Originating Device: N-octets (N=L-10)
|
||||
*/
|
||||
int bvlc_encode_forwarded_npdu(uint8_t *pdu,
|
||||
int bvlc_encode_forwarded_npdu(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_ADDRESS *bip_address,
|
||||
const uint8_t *npdu,
|
||||
@@ -999,7 +1009,8 @@ int bvlc_encode_forwarded_npdu(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_forwarded_npdu(const uint8_t *pdu,
|
||||
int bvlc_decode_forwarded_npdu(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_ADDRESS *bip_address,
|
||||
uint8_t *npdu,
|
||||
@@ -1110,7 +1121,8 @@ int bvlc_decode_register_foreign_device(
|
||||
* @param fdt_head - head of the BDT linked list
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bvlc_foreign_device_table_encode(uint8_t *apdu,
|
||||
int bvlc_foreign_device_table_encode(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head)
|
||||
{
|
||||
@@ -1124,7 +1136,8 @@ 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),
|
||||
len = bvlc_encode_address(
|
||||
octetstring_value(&octet_string),
|
||||
octetstring_capacity(&octet_string), &fdt_entry->dest_address);
|
||||
octetstring_truncate(&octet_string, len);
|
||||
len =
|
||||
@@ -1369,8 +1382,8 @@ uint16_t bvlc_foreign_device_table_valid_count(
|
||||
* @param bdt_list - first element in array BDT entries
|
||||
* @return number of elements of BDT entries
|
||||
*/
|
||||
uint16_t bvlc_foreign_device_table_count(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list)
|
||||
uint16_t
|
||||
bvlc_foreign_device_table_count(BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list)
|
||||
{
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry = NULL;
|
||||
uint16_t entry_count = 0;
|
||||
@@ -1429,7 +1442,8 @@ void bvlc_foreign_device_table_link_array(
|
||||
* re-registration occurs. The time remaining includes the 30-second grace
|
||||
* period as defined in Clause J.5.2.3.
|
||||
*/
|
||||
int bvlc_encode_read_foreign_device_table_ack(uint8_t *pdu,
|
||||
int bvlc_encode_read_foreign_device_table_ack(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list)
|
||||
{
|
||||
@@ -1474,7 +1488,8 @@ int bvlc_encode_read_foreign_device_table_ack(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_read_foreign_device_table_ack(const uint8_t *pdu,
|
||||
int bvlc_decode_read_foreign_device_table_ack(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list)
|
||||
{
|
||||
@@ -1623,7 +1638,8 @@ int bvlc_encode_distribute_broadcast_to_network(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_distribute_broadcast_to_network(const uint8_t *pdu,
|
||||
int bvlc_decode_distribute_broadcast_to_network(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
@@ -1698,7 +1714,8 @@ int bvlc_encode_original_unicast(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_original_unicast(const uint8_t *pdu,
|
||||
int bvlc_decode_original_unicast(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
@@ -1773,7 +1790,8 @@ int bvlc_encode_original_broadcast(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_original_broadcast(const uint8_t *pdu,
|
||||
int bvlc_decode_original_broadcast(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
@@ -1848,7 +1866,8 @@ int bvlc_encode_secure_bvll(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_secure_bvll(const uint8_t *pdu,
|
||||
int bvlc_decode_secure_bvll(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *sbuf,
|
||||
uint16_t sbuf_size,
|
||||
@@ -2003,7 +2022,8 @@ bool bvlc_address_different(
|
||||
* @param mask - B/IPv4 broadcast distribution mask
|
||||
* @return true if the addresses are different
|
||||
*/
|
||||
bool bvlc_address_mask(BACNET_IP_ADDRESS *dst,
|
||||
bool bvlc_address_mask(
|
||||
BACNET_IP_ADDRESS *dst,
|
||||
const BACNET_IP_ADDRESS *src,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask)
|
||||
{
|
||||
@@ -2036,7 +2056,8 @@ bool bvlc_address_mask(BACNET_IP_ADDRESS *dst,
|
||||
*
|
||||
* @return true if the address is set
|
||||
*/
|
||||
bool bvlc_address_set(BACNET_IP_ADDRESS *addr,
|
||||
bool bvlc_address_set(
|
||||
BACNET_IP_ADDRESS *addr,
|
||||
uint8_t addr0,
|
||||
uint8_t addr1,
|
||||
uint8_t addr2,
|
||||
@@ -2071,7 +2092,8 @@ bool bvlc_address_set(BACNET_IP_ADDRESS *addr,
|
||||
*
|
||||
* @return true if the address is set
|
||||
*/
|
||||
bool bvlc_address_get(const BACNET_IP_ADDRESS *addr,
|
||||
bool bvlc_address_get(
|
||||
const BACNET_IP_ADDRESS *addr,
|
||||
uint8_t *addr0,
|
||||
uint8_t *addr1,
|
||||
uint8_t *addr2,
|
||||
@@ -2336,7 +2358,8 @@ bool bvlc_ip_address_from_bacnet_remote(
|
||||
*
|
||||
* @return number of bytes encoded
|
||||
*/
|
||||
int bvlc_encode_broadcast_distribution_mask(uint8_t *pdu,
|
||||
int bvlc_encode_broadcast_distribution_mask(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *bd_mask)
|
||||
{
|
||||
@@ -2366,7 +2389,8 @@ int bvlc_encode_broadcast_distribution_mask(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_broadcast_distribution_mask(const uint8_t *pdu,
|
||||
int bvlc_decode_broadcast_distribution_mask(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_MASK *bd_mask)
|
||||
{
|
||||
@@ -2399,7 +2423,8 @@ int bvlc_decode_broadcast_distribution_mask(const uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes encoded
|
||||
*/
|
||||
int bvlc_encode_broadcast_distribution_table_entry(uint8_t *pdu,
|
||||
int bvlc_encode_broadcast_distribution_table_entry(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry)
|
||||
{
|
||||
@@ -2413,8 +2438,9 @@ int bvlc_encode_broadcast_distribution_table_entry(uint8_t *pdu,
|
||||
&pdu[offset], pdu_size - offset, &bdt_entry->dest_address);
|
||||
if (len > 0) {
|
||||
offset += len;
|
||||
len = bvlc_encode_broadcast_distribution_mask(&pdu[offset],
|
||||
pdu_size - offset, &bdt_entry->broadcast_mask);
|
||||
len = bvlc_encode_broadcast_distribution_mask(
|
||||
&pdu[offset], pdu_size - offset,
|
||||
&bdt_entry->broadcast_mask);
|
||||
}
|
||||
if (len > 0) {
|
||||
offset += len;
|
||||
@@ -2440,7 +2466,8 @@ int bvlc_encode_broadcast_distribution_table_entry(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_broadcast_distribution_table_entry(const uint8_t *pdu,
|
||||
int bvlc_decode_broadcast_distribution_table_entry(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry)
|
||||
{
|
||||
@@ -2480,7 +2507,8 @@ int bvlc_decode_broadcast_distribution_table_entry(const uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes encoded
|
||||
*/
|
||||
int bvlc_encode_foreign_device_table_entry(uint8_t *pdu,
|
||||
int bvlc_encode_foreign_device_table_entry(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry)
|
||||
{
|
||||
@@ -2524,7 +2552,8 @@ int bvlc_encode_foreign_device_table_entry(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_foreign_device_table_entry(const uint8_t *pdu,
|
||||
int bvlc_decode_foreign_device_table_entry(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry)
|
||||
{
|
||||
@@ -2626,7 +2655,8 @@ int bvlc_foreign_device_bbmd_host_address_encode(
|
||||
* @param ip_address - IP address and port number
|
||||
* @return length of the APDU buffer decoded, or ERROR, REJECT, or ABORT
|
||||
*/
|
||||
int bvlc_foreign_device_bbmd_host_address_decode(const uint8_t *apdu,
|
||||
int bvlc_foreign_device_bbmd_host_address_decode(
|
||||
const uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_ERROR_CODE *error_code,
|
||||
BACNET_IP_ADDRESS *ip_address)
|
||||
@@ -2638,8 +2668,9 @@ int bvlc_foreign_device_bbmd_host_address_decode(const 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) {
|
||||
|
||||
+388
-365
@@ -149,371 +149,394 @@ typedef struct BACnet_IP_Foreign_Device_Table_Entry {
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_address(
|
||||
uint8_t *pdu, uint16_t pdu_size, const BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_address(
|
||||
const uint8_t *pdu, uint16_t pdu_len, BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_copy(BACNET_IP_ADDRESS *dst, const BACNET_IP_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_different(
|
||||
const BACNET_IP_ADDRESS *dst, const BACNET_IP_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_from_ascii(BACNET_IP_ADDRESS *dst, const char *addrstr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_port_from_ascii(
|
||||
BACNET_IP_ADDRESS *dst, const char *addrstr, const char *portstr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_address_from_network(BACNET_IP_ADDRESS *dst, uint32_t addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_set(BACNET_IP_ADDRESS *addr,
|
||||
uint8_t addr0,
|
||||
uint8_t addr1,
|
||||
uint8_t addr2,
|
||||
uint8_t addr3);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_get(const BACNET_IP_ADDRESS *addr,
|
||||
uint8_t *addr0,
|
||||
uint8_t *addr1,
|
||||
uint8_t *addr2,
|
||||
uint8_t *addr3);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_ip_address_to_bacnet_local(
|
||||
BACNET_ADDRESS *addr, const BACNET_IP_ADDRESS *ipaddr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_ip_address_from_bacnet_local(
|
||||
BACNET_IP_ADDRESS *ipaddr, const BACNET_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_ip_address_to_bacnet_remote(
|
||||
BACNET_ADDRESS *addr, uint16_t dnet, const BACNET_IP_ADDRESS *ipaddr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_ip_address_from_bacnet_remote(
|
||||
BACNET_IP_ADDRESS *ipaddr, uint16_t *dnet, const BACNET_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_broadcast_distribution_mask(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *bd_mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_broadcast_distribution_mask(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_MASK *bd_mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_broadcast_distribution_table_entry(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_broadcast_distribution_table_entry(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_broadcast_distribution_table_link_array(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list,
|
||||
const size_t bdt_array_size);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bvlc_broadcast_distribution_table_count(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bvlc_broadcast_distribution_table_valid_count(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_broadcast_distribution_table_valid_clear(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_table_entry_different(
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *dst,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_table_entry_copy(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *dst,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_mask_different(
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *dst,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_mask_copy(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_MASK *dst,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_table_entry_append(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_table_entry_set(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry,
|
||||
const BACNET_IP_ADDRESS *addr,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_table_entry_forward_address(
|
||||
BACNET_IP_ADDRESS *addr,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_mask(
|
||||
BACNET_IP_ADDRESS *dst, const BACNET_IP_ADDRESS *src,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_mask_from_host(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask, uint32_t broadcast_mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_mask_to_host(
|
||||
uint32_t *broadcast_mask,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_broadcast_distribution_mask_set(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask,
|
||||
uint8_t addr0,
|
||||
uint8_t addr1,
|
||||
uint8_t addr2,
|
||||
uint8_t addr3);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_broadcast_distribution_mask_get(
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask,
|
||||
uint8_t *addr0,
|
||||
uint8_t *addr1,
|
||||
uint8_t *addr2,
|
||||
uint8_t *addr3);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_broadcast_distribution_table_decode(const uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_ERROR_CODE *error_code,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_write_broadcast_distribution_table(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_write_broadcast_distribution_table(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_read_broadcast_distribution_table(
|
||||
uint8_t *pdu, uint16_t pdu_size);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_read_broadcast_distribution_table_ack(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_read_broadcast_distribution_table_ack(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_header(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint8_t message_type, uint16_t length);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_header(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *message_type,
|
||||
uint16_t *length);
|
||||
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_foreign_device_table_maintenance_timer(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list, uint16_t seconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bvlc_foreign_device_table_valid_count(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bvlc_foreign_device_table_count(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_foreign_device_table_link_array(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list, const size_t array_size);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_foreign_device_table_entry_different(
|
||||
const BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *dst,
|
||||
const BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_foreign_device_table_entry_copy(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *dst,
|
||||
const BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_foreign_device_table_entry_delete(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list,
|
||||
const BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_foreign_device_table_entry_add(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list,
|
||||
const BACNET_IP_ADDRESS *ip_address,
|
||||
uint16_t ttl_seconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_foreign_device_table_entry(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_foreign_device_table_entry(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_foreign_device_table_encode(uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_read_foreign_device_table(uint8_t *pdu, uint16_t pdu_size);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_read_foreign_device_table_ack(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_read_foreign_device_table_ack(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_result(uint8_t *pdu, uint16_t pdu_size, uint16_t result_code);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_result(
|
||||
const uint8_t *pdu, uint16_t pdu_len, uint16_t *result_code);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_original_unicast(
|
||||
uint8_t *pdu, uint16_t pdu_size, const uint8_t *npdu, uint16_t npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_original_unicast(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_original_broadcast(
|
||||
uint8_t *pdu, uint16_t pdu_size, const uint8_t *npdu, uint16_t npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_original_broadcast(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_forwarded_npdu(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_ADDRESS *address,
|
||||
const uint8_t *npdu,
|
||||
uint16_t npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_forwarded_npdu(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_ADDRESS *address,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_register_foreign_device(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint16_t ttl_seconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_register_foreign_device(
|
||||
const uint8_t *pdu, uint16_t pdu_len, uint16_t *ttl_seconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_delete_foreign_device(
|
||||
uint8_t *pdu, uint16_t pdu_size, const BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_delete_foreign_device(
|
||||
const uint8_t *pdu, uint16_t pdu_len, BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_secure_bvll(
|
||||
uint8_t *pdu, uint16_t pdu_size, const uint8_t *sbuf, uint16_t sbuf_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_secure_bvll(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *sbuf,
|
||||
uint16_t sbuf_size,
|
||||
uint16_t *sbuf_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_distribute_broadcast_to_network(
|
||||
uint8_t *pdu, uint16_t pdu_size, const uint8_t *npdu, uint16_t npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_distribute_broadcast_to_network(const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
const char *bvlc_result_code_name(uint16_t result_code);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_foreign_device_bbmd_host_address_encode(uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
const BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_foreign_device_bbmd_host_address_decode(const uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_ERROR_CODE *error_code,
|
||||
BACNET_IP_ADDRESS *ip_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_address(
|
||||
uint8_t *pdu, uint16_t pdu_size, const BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_address(
|
||||
const uint8_t *pdu, uint16_t pdu_len, BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_copy(BACNET_IP_ADDRESS *dst, const BACNET_IP_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_different(
|
||||
const BACNET_IP_ADDRESS *dst, const BACNET_IP_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_from_ascii(BACNET_IP_ADDRESS *dst, const char *addrstr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_port_from_ascii(
|
||||
BACNET_IP_ADDRESS *dst, const char *addrstr, const char *portstr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_address_from_network(BACNET_IP_ADDRESS *dst, uint32_t addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_set(
|
||||
BACNET_IP_ADDRESS *addr,
|
||||
uint8_t addr0,
|
||||
uint8_t addr1,
|
||||
uint8_t addr2,
|
||||
uint8_t addr3);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_get(
|
||||
const BACNET_IP_ADDRESS *addr,
|
||||
uint8_t *addr0,
|
||||
uint8_t *addr1,
|
||||
uint8_t *addr2,
|
||||
uint8_t *addr3);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_ip_address_to_bacnet_local(
|
||||
BACNET_ADDRESS *addr, const BACNET_IP_ADDRESS *ipaddr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_ip_address_from_bacnet_local(
|
||||
BACNET_IP_ADDRESS *ipaddr, const BACNET_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_ip_address_to_bacnet_remote(
|
||||
BACNET_ADDRESS *addr, uint16_t dnet, const BACNET_IP_ADDRESS *ipaddr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_ip_address_from_bacnet_remote(
|
||||
BACNET_IP_ADDRESS *ipaddr, uint16_t *dnet, const BACNET_ADDRESS *addr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_broadcast_distribution_mask(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *bd_mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_broadcast_distribution_mask(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_MASK *bd_mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_broadcast_distribution_table_entry(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_broadcast_distribution_table_entry(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_broadcast_distribution_table_link_array(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list,
|
||||
const size_t bdt_array_size);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bvlc_broadcast_distribution_table_count(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bvlc_broadcast_distribution_table_valid_count(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_broadcast_distribution_table_valid_clear(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_table_entry_different(
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *dst,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_table_entry_copy(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *dst,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_mask_different(
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *dst,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_mask_copy(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_MASK *dst,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_table_entry_append(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_table_entry_set(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry,
|
||||
const BACNET_IP_ADDRESS *addr,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_table_entry_forward_address(
|
||||
BACNET_IP_ADDRESS *addr,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_address_mask(
|
||||
BACNET_IP_ADDRESS *dst,
|
||||
const BACNET_IP_ADDRESS *src,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_mask_from_host(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask, uint32_t broadcast_mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_broadcast_distribution_mask_to_host(
|
||||
uint32_t *broadcast_mask,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_broadcast_distribution_mask_set(
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask,
|
||||
uint8_t addr0,
|
||||
uint8_t addr1,
|
||||
uint8_t addr2,
|
||||
uint8_t addr3);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_broadcast_distribution_mask_get(
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask,
|
||||
uint8_t *addr0,
|
||||
uint8_t *addr1,
|
||||
uint8_t *addr2,
|
||||
uint8_t *addr3);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_broadcast_distribution_table_decode(
|
||||
const uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_ERROR_CODE *error_code,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_broadcast_distribution_table_encode(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_write_broadcast_distribution_table(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_write_broadcast_distribution_table(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_read_broadcast_distribution_table(
|
||||
uint8_t *pdu, uint16_t pdu_size);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_read_broadcast_distribution_table_ack(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_read_broadcast_distribution_table_ack(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_header(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint8_t message_type, uint16_t length);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_header(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *message_type,
|
||||
uint16_t *length);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_foreign_device_table_maintenance_timer(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list, uint16_t seconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t bvlc_foreign_device_table_valid_count(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t
|
||||
bvlc_foreign_device_table_count(BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bvlc_foreign_device_table_link_array(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list, const size_t array_size);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_foreign_device_table_entry_different(
|
||||
const BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *dst,
|
||||
const BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_foreign_device_table_entry_copy(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *dst,
|
||||
const BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_foreign_device_table_entry_delete(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list,
|
||||
const BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc_foreign_device_table_entry_add(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list,
|
||||
const BACNET_IP_ADDRESS *ip_address,
|
||||
uint16_t ttl_seconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_foreign_device_table_entry(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_foreign_device_table_entry(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_foreign_device_table_encode(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_read_foreign_device_table(uint8_t *pdu, uint16_t pdu_size);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_read_foreign_device_table_ack(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_read_foreign_device_table_ack(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_result(uint8_t *pdu, uint16_t pdu_size, uint16_t result_code);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_result(
|
||||
const uint8_t *pdu, uint16_t pdu_len, uint16_t *result_code);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_original_unicast(
|
||||
uint8_t *pdu, uint16_t pdu_size, const uint8_t *npdu, uint16_t npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_original_unicast(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_original_broadcast(
|
||||
uint8_t *pdu, uint16_t pdu_size, const uint8_t *npdu, uint16_t npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_original_broadcast(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_forwarded_npdu(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_ADDRESS *address,
|
||||
const uint8_t *npdu,
|
||||
uint16_t npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_forwarded_npdu(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_ADDRESS *address,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_register_foreign_device(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint16_t ttl_seconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_register_foreign_device(
|
||||
const uint8_t *pdu, uint16_t pdu_len, uint16_t *ttl_seconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_delete_foreign_device(
|
||||
uint8_t *pdu, uint16_t pdu_size, const BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_delete_foreign_device(
|
||||
const uint8_t *pdu, uint16_t pdu_len, BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_secure_bvll(
|
||||
uint8_t *pdu, uint16_t pdu_size, const uint8_t *sbuf, uint16_t sbuf_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_secure_bvll(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *sbuf,
|
||||
uint16_t sbuf_size,
|
||||
uint16_t *sbuf_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_encode_distribute_broadcast_to_network(
|
||||
uint8_t *pdu, uint16_t pdu_size, const uint8_t *npdu, uint16_t npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_decode_distribute_broadcast_to_network(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
const char *bvlc_result_code_name(uint16_t result_code);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_foreign_device_bbmd_host_address_encode(
|
||||
uint8_t *apdu, uint16_t apdu_size, const BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc_foreign_device_bbmd_host_address_decode(
|
||||
const uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_ERROR_CODE *error_code,
|
||||
BACNET_IP_ADDRESS *ip_address);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+81
-60
@@ -127,10 +127,7 @@ int bvlc6_encode_result(
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_result(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac,
|
||||
uint16_t *result_code)
|
||||
const uint8_t *pdu, uint16_t pdu_len, uint32_t *vmac, uint16_t *result_code)
|
||||
{
|
||||
int bytes_consumed = 0;
|
||||
|
||||
@@ -168,7 +165,8 @@ int bvlc6_decode_result(
|
||||
* Destination-Virtual-Address: 3-octets
|
||||
* BACnet NPDU: Variable length
|
||||
*/
|
||||
int bvlc6_encode_original_unicast(uint8_t *pdu,
|
||||
int bvlc6_encode_original_unicast(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_dst,
|
||||
@@ -211,7 +209,8 @@ int bvlc6_encode_original_unicast(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_original_unicast(const uint8_t *pdu,
|
||||
int bvlc6_decode_original_unicast(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint32_t *vmac_dst,
|
||||
@@ -264,7 +263,8 @@ int bvlc6_decode_original_unicast(const uint8_t *pdu,
|
||||
* Source-Virtual-Address: 3-octets
|
||||
* BACnet NPDU: Variable length
|
||||
*/
|
||||
int bvlc6_encode_original_broadcast(uint8_t *pdu,
|
||||
int bvlc6_encode_original_broadcast(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac,
|
||||
const uint8_t *npdu,
|
||||
@@ -303,7 +303,8 @@ int bvlc6_encode_original_broadcast(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_original_broadcast(const uint8_t *pdu,
|
||||
int bvlc6_decode_original_broadcast(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac,
|
||||
uint8_t *npdu,
|
||||
@@ -382,7 +383,10 @@ int bvlc6_encode_address_resolution(
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_address_resolution(
|
||||
const uint8_t *pdu, uint16_t pdu_len, uint32_t *vmac_src, uint32_t *vmac_target)
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint32_t *vmac_target)
|
||||
{
|
||||
int bytes_consumed = 0;
|
||||
|
||||
@@ -535,7 +539,8 @@ bool bvlc6_address_different(
|
||||
*
|
||||
* @return true if the address is set
|
||||
*/
|
||||
bool bvlc6_address_set(BACNET_IP6_ADDRESS *addr,
|
||||
bool bvlc6_address_set(
|
||||
BACNET_IP6_ADDRESS *addr,
|
||||
uint16_t addr0,
|
||||
uint16_t addr1,
|
||||
uint16_t addr2,
|
||||
@@ -581,7 +586,8 @@ bool bvlc6_address_set(BACNET_IP6_ADDRESS *addr,
|
||||
*
|
||||
* @return true if the address is set
|
||||
*/
|
||||
bool bvlc6_address_get(const BACNET_IP6_ADDRESS *addr,
|
||||
bool bvlc6_address_get(
|
||||
const BACNET_IP6_ADDRESS *addr,
|
||||
uint16_t *addr0,
|
||||
uint16_t *addr1,
|
||||
uint16_t *addr2,
|
||||
@@ -649,7 +655,6 @@ static int snprintf_shift(int len, char **buf, size_t *buf_size)
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/** Convert IPv6 Address from ASCII
|
||||
*
|
||||
* IPv6 addresses are represented as eight groups, separated by colons,
|
||||
@@ -679,7 +684,8 @@ static int snprintf_shift(int len, char **buf, size_t *buf_size)
|
||||
* 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(const BACNET_IP6_ADDRESS *addr, char *buf, size_t buf_size)
|
||||
int bvlc6_address_to_ascii(
|
||||
const BACNET_IP6_ADDRESS *addr, char *buf, size_t buf_size)
|
||||
{
|
||||
uint16_t a;
|
||||
unsigned int i;
|
||||
@@ -878,7 +884,8 @@ bool bvlc6_vmac_address_get(const BACNET_ADDRESS *addr, uint32_t *device_id)
|
||||
* Target-Virtual-Address: 3-octets
|
||||
* Original-Source-B/IPv6-Address 18-octets
|
||||
*/
|
||||
int bvlc6_encode_forwarded_address_resolution(uint8_t *pdu,
|
||||
int bvlc6_encode_forwarded_address_resolution(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_target,
|
||||
@@ -916,7 +923,8 @@ int bvlc6_encode_forwarded_address_resolution(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_forwarded_address_resolution(const uint8_t *pdu,
|
||||
int bvlc6_decode_forwarded_address_resolution(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint32_t *vmac_target,
|
||||
@@ -953,7 +961,8 @@ int bvlc6_decode_forwarded_address_resolution(const uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes encoded
|
||||
*/
|
||||
static int bvlc6_encode_address_ack(uint8_t message_type,
|
||||
static int bvlc6_encode_address_ack(
|
||||
uint8_t message_type,
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
@@ -1114,8 +1123,9 @@ int bvlc6_decode_virtual_address_resolution(
|
||||
int bvlc6_encode_virtual_address_resolution_ack(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint32_t vmac_src, uint32_t vmac_dst)
|
||||
{
|
||||
return bvlc6_encode_address_ack(BVLC6_VIRTUAL_ADDRESS_RESOLUTION_ACK, pdu,
|
||||
pdu_size, vmac_src, vmac_dst);
|
||||
return bvlc6_encode_address_ack(
|
||||
BVLC6_VIRTUAL_ADDRESS_RESOLUTION_ACK, pdu, pdu_size, vmac_src,
|
||||
vmac_dst);
|
||||
}
|
||||
|
||||
/** Decode the BVLC Virtual-Address-Resolution-Ack message
|
||||
@@ -1128,7 +1138,10 @@ int bvlc6_encode_virtual_address_resolution_ack(
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_virtual_address_resolution_ack(
|
||||
const uint8_t *pdu, uint16_t pdu_len, uint32_t *vmac_src, uint32_t *vmac_dst)
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint32_t *vmac_dst)
|
||||
{
|
||||
return bvlc6_decode_address_resolution_ack(
|
||||
pdu, pdu_len, vmac_src, vmac_dst);
|
||||
@@ -1157,7 +1170,8 @@ int bvlc6_decode_virtual_address_resolution_ack(
|
||||
* Original-Source-B-IPv6-Address: 18-octets
|
||||
* BACnet NPDU from Originating Device: N-octets (N=L-25)
|
||||
*/
|
||||
int bvlc6_encode_forwarded_npdu(uint8_t *pdu,
|
||||
int bvlc6_encode_forwarded_npdu(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
const BACNET_IP6_ADDRESS *bip6_address,
|
||||
@@ -1203,7 +1217,8 @@ int bvlc6_encode_forwarded_npdu(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_forwarded_npdu(const uint8_t *pdu,
|
||||
int bvlc6_decode_forwarded_npdu(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
BACNET_IP6_ADDRESS *bip6_address,
|
||||
@@ -1292,7 +1307,10 @@ int bvlc6_encode_register_foreign_device(
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_register_foreign_device(
|
||||
const uint8_t *pdu, uint16_t pdu_len, uint32_t *vmac_src, uint16_t *ttl_seconds)
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint16_t *ttl_seconds)
|
||||
{
|
||||
int bytes_consumed = 0;
|
||||
const uint16_t length = 5;
|
||||
@@ -1332,7 +1350,8 @@ int bvlc6_decode_register_foreign_device(
|
||||
* FDT Entry: 18-octets The FDT entry is the B/IPv6 address
|
||||
* of the foreign device to be deleted.
|
||||
*/
|
||||
int bvlc6_encode_delete_foreign_device(uint8_t *pdu,
|
||||
int bvlc6_encode_delete_foreign_device(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
const BACNET_IP6_ADDRESS *bip6_address)
|
||||
@@ -1369,7 +1388,8 @@ int bvlc6_encode_delete_foreign_device(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_delete_foreign_device(const uint8_t *pdu,
|
||||
int bvlc6_decode_delete_foreign_device(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
BACNET_IP6_ADDRESS *bip6_address)
|
||||
@@ -1445,7 +1465,8 @@ int bvlc6_encode_secure_bvll(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_secure_bvll(const uint8_t *pdu,
|
||||
int bvlc6_decode_secure_bvll(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *sbuf,
|
||||
uint16_t sbuf_size,
|
||||
@@ -1493,7 +1514,8 @@ int bvlc6_decode_secure_bvll(const uint8_t *pdu,
|
||||
* Original-Source-Virtual-Address: 3-octets
|
||||
* BACnet NPDU from Originating Device: Variable length
|
||||
*/
|
||||
int bvlc6_encode_distribute_broadcast_to_network(uint8_t *pdu,
|
||||
int bvlc6_encode_distribute_broadcast_to_network(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac,
|
||||
const uint8_t *npdu,
|
||||
@@ -1532,7 +1554,8 @@ int bvlc6_encode_distribute_broadcast_to_network(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc6_decode_distribute_broadcast_to_network(const uint8_t *pdu,
|
||||
int bvlc6_decode_distribute_broadcast_to_network(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac,
|
||||
uint8_t *npdu,
|
||||
@@ -1600,14 +1623,16 @@ int bvlc6_foreign_device_bbmd_host_address_encode(
|
||||
* }
|
||||
* port [1] Unsigned16
|
||||
* }
|
||||
* broadcast-mask [1] OCTET STRING -- shall be present if BACnet/IP, and absent for BACnet/IPv6
|
||||
* broadcast-mask [1] OCTET STRING -- shall be present if BACnet/IP, and
|
||||
* absent for BACnet/IPv6
|
||||
* }
|
||||
*
|
||||
* @param apdu - the APDU buffer, or NULL for length
|
||||
* @param bdt_head - one BACnetBDTEntry
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bvlc6_broadcast_distribution_table_entry_encode(uint8_t *apdu,
|
||||
int bvlc6_broadcast_distribution_table_entry_encode(
|
||||
uint8_t *apdu,
|
||||
const BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry)
|
||||
{
|
||||
int len = 0;
|
||||
@@ -1628,10 +1653,10 @@ int bvlc6_broadcast_distribution_table_entry_encode(uint8_t *apdu,
|
||||
apdu += len;
|
||||
}
|
||||
/* CHOICE - ip-address [1] OCTET STRING */
|
||||
octetstring_init(&octet_string, &bdt_entry->bip6_address.address[0],
|
||||
octetstring_init(
|
||||
&octet_string, &bdt_entry->bip6_address.address[0],
|
||||
IP6_ADDRESS_MAX);
|
||||
len =
|
||||
encode_context_octet_string(apdu, 1, &octet_string);
|
||||
len = encode_context_octet_string(apdu, 1, &octet_string);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
@@ -1643,8 +1668,7 @@ int bvlc6_broadcast_distribution_table_entry_encode(uint8_t *apdu,
|
||||
apdu += len;
|
||||
}
|
||||
/* port [1] Unsigned16 */
|
||||
len = encode_context_unsigned(
|
||||
apdu, 1, bdt_entry->bip6_address.port);
|
||||
len = encode_context_unsigned(apdu, 1, bdt_entry->bip6_address.port);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
@@ -1667,8 +1691,8 @@ int bvlc6_broadcast_distribution_table_entry_encode(uint8_t *apdu,
|
||||
* @param bdt_head - head of the BDT linked list
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bvlc6_broadcast_distribution_table_list_encode(uint8_t *apdu,
|
||||
BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head)
|
||||
int bvlc6_broadcast_distribution_table_list_encode(
|
||||
uint8_t *apdu, BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
@@ -1700,17 +1724,16 @@ int bvlc6_broadcast_distribution_table_list_encode(uint8_t *apdu,
|
||||
* @param bdt_head - head of the BDT linked list
|
||||
* @return length of the APDU buffer, or BACNET_STATUS_ERROR on error
|
||||
*/
|
||||
int bvlc6_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
int bvlc6_broadcast_distribution_table_encode(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
len = bvlc6_broadcast_distribution_table_list_encode(NULL,
|
||||
bdt_head);
|
||||
len = bvlc6_broadcast_distribution_table_list_encode(NULL, bdt_head);
|
||||
if (len <= apdu_size) {
|
||||
len = bvlc6_broadcast_distribution_table_list_encode(apdu,
|
||||
bdt_head);
|
||||
len = bvlc6_broadcast_distribution_table_list_encode(apdu, bdt_head);
|
||||
} else {
|
||||
len = BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -1722,17 +1745,17 @@ int bvlc6_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
* @brief Encode the Foreign_Device-Table for Network Port object
|
||||
*
|
||||
* BACnetFDTEntry ::= SEQUENCE {
|
||||
* bacnetip-address [0] OCTET STRING, -- the 6-octet B/IP or 18-octet B/IPv6 address of the registrant
|
||||
* time-to-live [1] Unsigned16, -- time to live in seconds
|
||||
* remaining-time-to-live [2] Unsigned16 -- remaining time in seconds
|
||||
* bacnetip-address [0] OCTET STRING, -- the 6-octet B/IP or 18-octet
|
||||
* B/IPv6 address of the registrant time-to-live [1] Unsigned16, -- time to live
|
||||
* in seconds remaining-time-to-live [2] Unsigned16 -- remaining time in seconds
|
||||
* }
|
||||
*
|
||||
* @param apdu - the APDU buffer, or NULL for length
|
||||
* @param fdt_head - head of the BDT linked list
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bvlc6_foreign_device_table_entry_encode(uint8_t *apdu,
|
||||
const BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry)
|
||||
int bvlc6_foreign_device_table_entry_encode(
|
||||
uint8_t *apdu, const BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
@@ -1740,25 +1763,24 @@ int bvlc6_foreign_device_table_entry_encode(uint8_t *apdu,
|
||||
|
||||
if (fdt_entry) {
|
||||
/* bacnetip-address [0] OCTET STRING */
|
||||
len = bvlc6_encode_address(octetstring_value(&octet_string),
|
||||
len = bvlc6_encode_address(
|
||||
octetstring_value(&octet_string),
|
||||
octetstring_capacity(&octet_string), &fdt_entry->bip6_address);
|
||||
octetstring_truncate(&octet_string, len);
|
||||
len =
|
||||
encode_context_octet_string(apdu, 0, &octet_string);
|
||||
len = encode_context_octet_string(apdu, 0, &octet_string);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
/* time-to-live [1] Unsigned16 */
|
||||
len = encode_context_unsigned(
|
||||
apdu, 1, fdt_entry->ttl_seconds);
|
||||
len = encode_context_unsigned(apdu, 1, fdt_entry->ttl_seconds);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
/* remaining-time-to-live [2] Unsigned16 */
|
||||
len = encode_context_unsigned(
|
||||
apdu, 2, fdt_entry->ttl_seconds_remaining);
|
||||
len =
|
||||
encode_context_unsigned(apdu, 2, fdt_entry->ttl_seconds_remaining);
|
||||
apdu_len += len;
|
||||
}
|
||||
|
||||
@@ -1774,8 +1796,8 @@ int bvlc6_foreign_device_table_entry_encode(uint8_t *apdu,
|
||||
* @param fdt_head - head of the BDT linked list
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bvlc6_foreign_device_table_list_encode(uint8_t *apdu,
|
||||
BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head)
|
||||
int bvlc6_foreign_device_table_list_encode(
|
||||
uint8_t *apdu, BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
@@ -1804,17 +1826,16 @@ int bvlc6_foreign_device_table_list_encode(uint8_t *apdu,
|
||||
* @param fdt_head - head of the BDT linked list
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bvlc6_foreign_device_table_encode(uint8_t *apdu,
|
||||
int bvlc6_foreign_device_table_encode(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
len = bvlc6_foreign_device_table_list_encode(NULL,
|
||||
fdt_head);
|
||||
len = bvlc6_foreign_device_table_list_encode(NULL, fdt_head);
|
||||
if (len <= apdu_size) {
|
||||
len = bvlc6_foreign_device_table_list_encode(apdu,
|
||||
fdt_head);
|
||||
len = bvlc6_foreign_device_table_list_encode(apdu, fdt_head);
|
||||
} else {
|
||||
len = BACNET_STATUS_ERROR;
|
||||
}
|
||||
|
||||
+295
-332
@@ -18,16 +18,16 @@
|
||||
#include "bacnet/npdu.h"
|
||||
|
||||
/**
|
||||
* BVLL for BACnet/IPv6
|
||||
* @{
|
||||
*/
|
||||
* BVLL for BACnet/IPv6
|
||||
* @{
|
||||
*/
|
||||
#define BVLL_TYPE_BACNET_IP6 (0x82)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* B/IPv6 BVLL Messages
|
||||
* @{
|
||||
*/
|
||||
* B/IPv6 BVLL Messages
|
||||
* @{
|
||||
*/
|
||||
#define BVLC6_RESULT 0x00
|
||||
#define BVLC6_ORIGINAL_UNICAST_NPDU 0x01
|
||||
#define BVLC6_ORIGINAL_BROADCAST_NPDU 0x02
|
||||
@@ -44,9 +44,9 @@
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* BVLC Result Code
|
||||
* @{
|
||||
*/
|
||||
* BVLC Result Code
|
||||
* @{
|
||||
*/
|
||||
#define BVLC6_RESULT_SUCCESSFUL_COMPLETION 0x0000U
|
||||
#define BVLC6_RESULT_ADDRESS_RESOLUTION_NAK 0x0030U
|
||||
#define BVLC6_RESULT_VIRTUAL_ADDRESS_RESOLUTION_NAK 0x0060U
|
||||
@@ -57,36 +57,36 @@
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* BACnet IPv6 Multicast Group ID
|
||||
* BACnet broadcast messages shall be delivered by IPv6 multicasts
|
||||
* as opposed to using IP broadcasting. Broadcasting in
|
||||
* IPv6 is subsumed by multicasting to the all-nodes link
|
||||
* group FF02::1; however, the use of the all-nodes group is not
|
||||
* recommended, and BACnet/IPv6 uses an IANA permanently assigned
|
||||
* multicast group identifier to avoid disturbing
|
||||
* every interface in the network.
|
||||
*
|
||||
* The IANA assigned BACnet/IPv6 variable scope multicast address
|
||||
* is FF0X:0:0:0:0:0:0:BAC0 (FF0X::BAC0) which indicates the multicast
|
||||
* group identifier X'BAC0'. The following multicast scopes are
|
||||
* defined for B/IPv6.
|
||||
* @{
|
||||
*/
|
||||
#define BIP6_MULTICAST_GROUP_ID 0xBAC0U
|
||||
* BACnet IPv6 Multicast Group ID
|
||||
* BACnet broadcast messages shall be delivered by IPv6 multicasts
|
||||
* as opposed to using IP broadcasting. Broadcasting in
|
||||
* IPv6 is subsumed by multicasting to the all-nodes link
|
||||
* group FF02::1; however, the use of the all-nodes group is not
|
||||
* recommended, and BACnet/IPv6 uses an IANA permanently assigned
|
||||
* multicast group identifier to avoid disturbing
|
||||
* every interface in the network.
|
||||
*
|
||||
* The IANA assigned BACnet/IPv6 variable scope multicast address
|
||||
* is FF0X:0:0:0:0:0:0:BAC0 (FF0X::BAC0) which indicates the multicast
|
||||
* group identifier X'BAC0'. The following multicast scopes are
|
||||
* defined for B/IPv6.
|
||||
* @{
|
||||
*/
|
||||
#define BIP6_MULTICAST_GROUP_ID 0xBAC0U
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* IANA prefixes
|
||||
* @{
|
||||
*/
|
||||
#define BIP6_MULTICAST_reserved_0 0xFF00U
|
||||
#define BIP6_MULTICAST_NODE_LOCAL 0xFF01U
|
||||
#define BIP6_MULTICAST_LINK_LOCAL 0xFF02U
|
||||
#define BIP6_MULTICAST_reserved_3 0xFF03U
|
||||
* IANA prefixes
|
||||
* @{
|
||||
*/
|
||||
#define BIP6_MULTICAST_reserved_0 0xFF00U
|
||||
#define BIP6_MULTICAST_NODE_LOCAL 0xFF01U
|
||||
#define BIP6_MULTICAST_LINK_LOCAL 0xFF02U
|
||||
#define BIP6_MULTICAST_reserved_3 0xFF03U
|
||||
#define BIP6_MULTICAST_ADMIN_LOCAL 0xFF04U
|
||||
#define BIP6_MULTICAST_SITE_LOCAL 0xFF05U
|
||||
#define BIP6_MULTICAST_ORG_LOCAL 0xFF08U
|
||||
#define BIP6_MULTICAST_GLOBAL 0xFF0EU
|
||||
#define BIP6_MULTICAST_SITE_LOCAL 0xFF05U
|
||||
#define BIP6_MULTICAST_ORG_LOCAL 0xFF08U
|
||||
#define BIP6_MULTICAST_GLOBAL 0xFF0EU
|
||||
/** @} */
|
||||
|
||||
/* number of bytes in the IPv6 address */
|
||||
@@ -95,14 +95,14 @@
|
||||
#define BIP6_ADDRESS_MAX 18
|
||||
|
||||
/**
|
||||
* BACnet IPv6 Address
|
||||
*
|
||||
* Data link layer addressing between B/IPv6 nodes consists of a 128-bit
|
||||
* IPv6 address followed by a two-octet UDP port number (both of which
|
||||
* shall be transmitted with the most significant octet first).
|
||||
* This address shall be referred to as a B/IPv6 address.
|
||||
* @{
|
||||
*/
|
||||
* BACnet IPv6 Address
|
||||
*
|
||||
* Data link layer addressing between B/IPv6 nodes consists of a 128-bit
|
||||
* IPv6 address followed by a two-octet UDP port number (both of which
|
||||
* shall be transmitted with the most significant octet first).
|
||||
* This address shall be referred to as a B/IPv6 address.
|
||||
* @{
|
||||
*/
|
||||
typedef struct BACnet_IP6_Address {
|
||||
uint8_t address[IP6_ADDRESS_MAX];
|
||||
uint16_t port;
|
||||
@@ -110,16 +110,16 @@ typedef struct BACnet_IP6_Address {
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* BACnet /IPv6 Broadcast Distribution Table Format
|
||||
*
|
||||
* The BDT shall consist of either the eighteen-octet B/IPv6 address
|
||||
* of the peer BBMD or the combination of the fully qualified
|
||||
* domain name service (DNS) entry and UDP port that resolves to
|
||||
* the B/IPv6 address of the peer BBMD. The Broadcast
|
||||
* Distribution Table shall not contain an entry for the BBMD in
|
||||
* which the BDT resides.
|
||||
* @{
|
||||
*/
|
||||
* BACnet /IPv6 Broadcast Distribution Table Format
|
||||
*
|
||||
* The BDT shall consist of either the eighteen-octet B/IPv6 address
|
||||
* of the peer BBMD or the combination of the fully qualified
|
||||
* domain name service (DNS) entry and UDP port that resolves to
|
||||
* the B/IPv6 address of the peer BBMD. The Broadcast
|
||||
* Distribution Table shall not contain an entry for the BBMD in
|
||||
* which the BDT resides.
|
||||
* @{
|
||||
*/
|
||||
struct BACnet_IP6_Broadcast_Distribution_Table_Entry;
|
||||
typedef struct BACnet_IP6_Broadcast_Distribution_Table_Entry {
|
||||
/* true if valid entry - false if not */
|
||||
@@ -131,20 +131,20 @@ typedef struct BACnet_IP6_Broadcast_Distribution_Table_Entry {
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Foreign Device Table (FDT)
|
||||
*
|
||||
* Each entry shall contain the B/IPv6 address and the TTL of the
|
||||
* registered foreign device.
|
||||
*
|
||||
* Each entry shall consist of the eighteen-octet B/IPv6 address of the
|
||||
* registrant; the 2-octet Time-to-Live value supplied at the time of
|
||||
* registration; and a 2-octet value representing the number of seconds
|
||||
* remaining before the BBMD will purge the registrant's FDT entry if no
|
||||
* re-registration occurs. The number of seconds remaining shall be
|
||||
* initialized to the 2-octet Time-to-Live value supplied at the time
|
||||
* of registration plus 30 seconds (see U.4.5.2), with a maximum of 65535.
|
||||
* @{
|
||||
*/
|
||||
* Foreign Device Table (FDT)
|
||||
*
|
||||
* Each entry shall contain the B/IPv6 address and the TTL of the
|
||||
* registered foreign device.
|
||||
*
|
||||
* Each entry shall consist of the eighteen-octet B/IPv6 address of the
|
||||
* registrant; the 2-octet Time-to-Live value supplied at the time of
|
||||
* registration; and a 2-octet value representing the number of seconds
|
||||
* remaining before the BBMD will purge the registrant's FDT entry if no
|
||||
* re-registration occurs. The number of seconds remaining shall be
|
||||
* initialized to the 2-octet Time-to-Live value supplied at the time
|
||||
* of registration plus 30 seconds (see U.4.5.2), with a maximum of 65535.
|
||||
* @{
|
||||
*/
|
||||
struct BACnet_IP6_Foreign_Device_Table_Entry;
|
||||
typedef struct BACnet_IP6_Foreign_Device_Table_Entry {
|
||||
/* true if valid entry - false if not */
|
||||
@@ -163,291 +163,254 @@ typedef struct BACnet_IP6_Foreign_Device_Table_Entry {
|
||||
extern "C" {
|
||||
|
||||
#endif /* __cplusplus */
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_address(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP6_ADDRESS * ip6_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_address(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP6_ADDRESS * ip6_address);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_address_copy(
|
||||
BACNET_IP6_ADDRESS * dst,
|
||||
const BACNET_IP6_ADDRESS * src);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_address_different(
|
||||
const BACNET_IP6_ADDRESS * dst,
|
||||
const BACNET_IP6_ADDRESS * src);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_address(
|
||||
uint8_t *pdu, uint16_t pdu_size, const BACNET_IP6_ADDRESS *ip6_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_address(
|
||||
const uint8_t *pdu, uint16_t pdu_len, BACNET_IP6_ADDRESS *ip6_address);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_address_copy(BACNET_IP6_ADDRESS *dst, const BACNET_IP6_ADDRESS *src);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_address_different(
|
||||
const BACNET_IP6_ADDRESS *dst, const BACNET_IP6_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_address_to_ascii(const BACNET_IP6_ADDRESS *addr, char *buf,
|
||||
size_t buf_size);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_address_from_ascii(
|
||||
BACNET_IP6_ADDRESS *addr,
|
||||
const char *addrstr);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_address_to_ascii(
|
||||
const BACNET_IP6_ADDRESS *addr, char *buf, size_t buf_size);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_address_from_ascii(BACNET_IP6_ADDRESS *addr, const char *addrstr);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_address_set(
|
||||
BACNET_IP6_ADDRESS * addr,
|
||||
uint16_t addr0,
|
||||
uint16_t addr1,
|
||||
uint16_t addr2,
|
||||
uint16_t addr3,
|
||||
uint16_t addr4,
|
||||
uint16_t addr5,
|
||||
uint16_t addr6,
|
||||
uint16_t addr7);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_address_get(
|
||||
const BACNET_IP6_ADDRESS * addr,
|
||||
uint16_t *addr0,
|
||||
uint16_t *addr1,
|
||||
uint16_t *addr2,
|
||||
uint16_t *addr3,
|
||||
uint16_t *addr4,
|
||||
uint16_t *addr5,
|
||||
uint16_t *addr6,
|
||||
uint16_t *addr7);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_address_set(
|
||||
BACNET_IP6_ADDRESS *addr,
|
||||
uint16_t addr0,
|
||||
uint16_t addr1,
|
||||
uint16_t addr2,
|
||||
uint16_t addr3,
|
||||
uint16_t addr4,
|
||||
uint16_t addr5,
|
||||
uint16_t addr6,
|
||||
uint16_t addr7);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_address_get(
|
||||
const BACNET_IP6_ADDRESS *addr,
|
||||
uint16_t *addr0,
|
||||
uint16_t *addr1,
|
||||
uint16_t *addr2,
|
||||
uint16_t *addr3,
|
||||
uint16_t *addr4,
|
||||
uint16_t *addr5,
|
||||
uint16_t *addr6,
|
||||
uint16_t *addr7);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_vmac_address_set(
|
||||
BACNET_ADDRESS * addr,
|
||||
uint32_t device_id);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_vmac_address_get(
|
||||
const BACNET_ADDRESS * addr,
|
||||
uint32_t *device_id);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_vmac_address_set(BACNET_ADDRESS *addr, uint32_t device_id);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bvlc6_vmac_address_get(const BACNET_ADDRESS *addr, uint32_t *device_id);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_header(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint8_t message_type,
|
||||
uint16_t length);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_header(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t * message_type,
|
||||
uint16_t * length);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_header(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint8_t message_type, uint16_t length);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_header(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *message_type,
|
||||
uint16_t *length);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_result(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac,
|
||||
uint16_t result_code);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_result(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac,
|
||||
uint16_t * result_code);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_result(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint32_t vmac, uint16_t result_code);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_result(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac,
|
||||
uint16_t *result_code);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_original_unicast(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_dst,
|
||||
const uint8_t * npdu,
|
||||
uint16_t npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_original_unicast(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac_src,
|
||||
uint32_t * vmac_dst,
|
||||
uint8_t * npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t * npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_original_unicast(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_dst,
|
||||
const uint8_t *npdu,
|
||||
uint16_t npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_original_unicast(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint32_t *vmac_dst,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_original_broadcast(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac,
|
||||
const uint8_t * npdu,
|
||||
uint16_t npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_original_broadcast(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac,
|
||||
uint8_t * npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t * npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_original_broadcast(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac,
|
||||
const uint8_t *npdu,
|
||||
uint16_t npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_original_broadcast(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_address_resolution(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_target);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_address_resolution(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac_src,
|
||||
uint32_t * vmac_target);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_address_resolution(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint32_t vmac_src, uint32_t vmac_target);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_address_resolution(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint32_t *vmac_target);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_forwarded_address_resolution(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_target,
|
||||
const BACNET_IP6_ADDRESS * bip6_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_forwarded_address_resolution(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac_src,
|
||||
uint32_t * vmac_target,
|
||||
BACNET_IP6_ADDRESS * bip6_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_forwarded_address_resolution(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_target,
|
||||
const BACNET_IP6_ADDRESS *bip6_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_forwarded_address_resolution(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint32_t *vmac_target,
|
||||
BACNET_IP6_ADDRESS *bip6_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_address_resolution_ack(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_dst);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_address_resolution_ack(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac_src,
|
||||
uint32_t * vmac_dst);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_address_resolution_ack(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint32_t vmac_src, uint32_t vmac_dst);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_address_resolution_ack(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint32_t *vmac_dst);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_virtual_address_resolution(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_virtual_address_resolution(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac_src);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_virtual_address_resolution(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint32_t vmac_src);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_virtual_address_resolution(
|
||||
const uint8_t *pdu, uint16_t pdu_len, uint32_t *vmac_src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_virtual_address_resolution_ack(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_dst);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_virtual_address_resolution_ack(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac_src,
|
||||
uint32_t * vmac_dst);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_virtual_address_resolution_ack(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint32_t vmac_src, uint32_t vmac_dst);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_virtual_address_resolution_ack(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint32_t *vmac_dst);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_forwarded_npdu(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
const BACNET_IP6_ADDRESS * address,
|
||||
const uint8_t * npdu,
|
||||
uint16_t npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_forwarded_npdu(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac_src,
|
||||
BACNET_IP6_ADDRESS * address,
|
||||
uint8_t * npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t * npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_forwarded_npdu(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
const BACNET_IP6_ADDRESS *address,
|
||||
const uint8_t *npdu,
|
||||
uint16_t npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_forwarded_npdu(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
BACNET_IP6_ADDRESS *address,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_register_foreign_device(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint16_t ttl_seconds);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_register_foreign_device(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac_src,
|
||||
uint16_t * ttl_seconds);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_register_foreign_device(
|
||||
uint8_t *pdu, uint16_t pdu_size, uint32_t vmac_src, uint16_t ttl_seconds);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_register_foreign_device(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
uint16_t *ttl_seconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_delete_foreign_device(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
const BACNET_IP6_ADDRESS *bip6_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_delete_foreign_device(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
const BACNET_IP6_ADDRESS *bip6_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_delete_foreign_device(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac_src,
|
||||
BACNET_IP6_ADDRESS *bip6_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_delete_foreign_device(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac_src,
|
||||
BACNET_IP6_ADDRESS *bip6_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_secure_bvll(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
const uint8_t * sbuf,
|
||||
uint16_t sbuf_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_secure_bvll(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t * sbuf,
|
||||
uint16_t sbuf_size,
|
||||
uint16_t * sbuf_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_secure_bvll(
|
||||
uint8_t *pdu, uint16_t pdu_size, const uint8_t *sbuf, uint16_t sbuf_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_secure_bvll(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *sbuf,
|
||||
uint16_t sbuf_size,
|
||||
uint16_t *sbuf_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_distribute_broadcast_to_network(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac,
|
||||
const uint8_t * npdu,
|
||||
uint16_t npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_distribute_broadcast_to_network(
|
||||
const uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t * vmac,
|
||||
uint8_t * npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t * npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_foreign_device_bbmd_host_address_encode(uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
const BACNET_IP6_ADDRESS *ip6_address);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_encode_distribute_broadcast_to_network(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac,
|
||||
const uint8_t *npdu,
|
||||
uint16_t npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_decode_distribute_broadcast_to_network(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint32_t *vmac,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
uint16_t *npdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_foreign_device_bbmd_host_address_encode(
|
||||
uint8_t *apdu, uint16_t apdu_size, const BACNET_IP6_ADDRESS *ip6_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_broadcast_distribution_table_entry_encode(uint8_t *apdu,
|
||||
const BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_broadcast_distribution_table_list_encode(uint8_t *apdu,
|
||||
BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_foreign_device_table_entry_encode(uint8_t *apdu,
|
||||
const BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_foreign_device_table_list_encode(uint8_t *apdu,
|
||||
BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_foreign_device_table_encode(uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_broadcast_distribution_table_entry_encode(
|
||||
uint8_t *apdu,
|
||||
const BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_broadcast_distribution_table_list_encode(
|
||||
uint8_t *apdu, BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_broadcast_distribution_table_encode(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP6_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_foreign_device_table_entry_encode(
|
||||
uint8_t *apdu, const BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_foreign_device_table_list_encode(
|
||||
uint8_t *apdu, BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head);
|
||||
BACNET_STACK_EXPORT
|
||||
int bvlc6_foreign_device_table_encode(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -72,7 +72,8 @@ 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,
|
||||
@@ -177,9 +178,9 @@ size_t cobs_frame_encode(
|
||||
*/
|
||||
crc32K = ~crc32K;
|
||||
(void)cobs_crc32k_encode(crc_buffer, sizeof(crc_buffer), crc32K);
|
||||
cobs_crc_len = cobs_encode((uint8_t *)(buffer + cobs_data_len),
|
||||
buffer_size - cobs_data_len, crc_buffer, sizeof(crc_buffer),
|
||||
MSTP_PREAMBLE_X55);
|
||||
cobs_crc_len = cobs_encode(
|
||||
(uint8_t *)(buffer + cobs_data_len), buffer_size - cobs_data_len,
|
||||
crc_buffer, sizeof(crc_buffer), MSTP_PREAMBLE_X55);
|
||||
if (cobs_crc_len == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -201,7 +202,8 @@ 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,
|
||||
@@ -294,8 +296,8 @@ size_t cobs_frame_decode(
|
||||
/*
|
||||
* Decode the Encoded CRC-32K field
|
||||
*/
|
||||
crc_len = cobs_decode(crc_buffer, sizeof(crc_buffer),
|
||||
from + length - COBS_ENCODED_CRC_SIZE,
|
||||
crc_len = cobs_decode(
|
||||
crc_buffer, sizeof(crc_buffer), from + length - COBS_ENCODED_CRC_SIZE,
|
||||
COBS_ENCODED_CRC_SIZE, MSTP_PREAMBLE_X55);
|
||||
/*
|
||||
* Sanity check length of decoded CRC32K.
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
/* number of bytes needed for COBS encoded CRC */
|
||||
#define COBS_ENCODED_CRC_SIZE 5
|
||||
/* inclusive extra bytes needed for APDU */
|
||||
#define COBS_ENCODED_SIZE(a) ((a)+((a)/254)+1)
|
||||
|
||||
#define COBS_ENCODED_SIZE(a) ((a) + ((a) / 254) + 1)
|
||||
|
||||
/* The first COBS-encoded Frame Type value: 32. */
|
||||
#define Nmin_COBS_type 32
|
||||
@@ -66,10 +65,7 @@ size_t cobs_encode(
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
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);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
size_t cobs_decode(
|
||||
@@ -81,21 +77,13 @@ size_t cobs_decode(
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
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);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint32_t cobs_crc32k(
|
||||
uint8_t dataValue,
|
||||
uint32_t crc);
|
||||
uint32_t cobs_crc32k(uint8_t dataValue, uint32_t crc);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
size_t cobs_crc32k_encode(
|
||||
uint8_t *buffer,
|
||||
size_t buffer_size,
|
||||
uint32_t crc);
|
||||
size_t cobs_crc32k_encode(uint8_t *buffer, size_t buffer_size, uint32_t crc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+55
-51
@@ -14,28 +14,30 @@
|
||||
|
||||
#if defined(CRC_USE_TABLE)
|
||||
/* note: table is created using unit test below */
|
||||
static const uint8_t HeaderCRC[256] = { 0x00, 0xfe, 0xff, 0x01, 0xfd, 0x03,
|
||||
0x02, 0xfc, 0xf9, 0x07, 0x06, 0xf8, 0x04, 0xfa, 0xfb, 0x05, 0xf1, 0x0f,
|
||||
0x0e, 0xf0, 0x0c, 0xf2, 0xf3, 0x0d, 0x08, 0xf6, 0xf7, 0x09, 0xf5, 0x0b,
|
||||
0x0a, 0xf4, 0xe1, 0x1f, 0x1e, 0xe0, 0x1c, 0xe2, 0xe3, 0x1d, 0x18, 0xe6,
|
||||
0xe7, 0x19, 0xe5, 0x1b, 0x1a, 0xe4, 0x10, 0xee, 0xef, 0x11, 0xed, 0x13,
|
||||
0x12, 0xec, 0xe9, 0x17, 0x16, 0xe8, 0x14, 0xea, 0xeb, 0x15, 0xc1, 0x3f,
|
||||
0x3e, 0xc0, 0x3c, 0xc2, 0xc3, 0x3d, 0x38, 0xc6, 0xc7, 0x39, 0xc5, 0x3b,
|
||||
0x3a, 0xc4, 0x30, 0xce, 0xcf, 0x31, 0xcd, 0x33, 0x32, 0xcc, 0xc9, 0x37,
|
||||
0x36, 0xc8, 0x34, 0xca, 0xcb, 0x35, 0x20, 0xde, 0xdf, 0x21, 0xdd, 0x23,
|
||||
0x22, 0xdc, 0xd9, 0x27, 0x26, 0xd8, 0x24, 0xda, 0xdb, 0x25, 0xd1, 0x2f,
|
||||
0x2e, 0xd0, 0x2c, 0xd2, 0xd3, 0x2d, 0x28, 0xd6, 0xd7, 0x29, 0xd5, 0x2b,
|
||||
0x2a, 0xd4, 0x81, 0x7f, 0x7e, 0x80, 0x7c, 0x82, 0x83, 0x7d, 0x78, 0x86,
|
||||
0x87, 0x79, 0x85, 0x7b, 0x7a, 0x84, 0x70, 0x8e, 0x8f, 0x71, 0x8d, 0x73,
|
||||
0x72, 0x8c, 0x89, 0x77, 0x76, 0x88, 0x74, 0x8a, 0x8b, 0x75, 0x60, 0x9e,
|
||||
0x9f, 0x61, 0x9d, 0x63, 0x62, 0x9c, 0x99, 0x67, 0x66, 0x98, 0x64, 0x9a,
|
||||
0x9b, 0x65, 0x91, 0x6f, 0x6e, 0x90, 0x6c, 0x92, 0x93, 0x6d, 0x68, 0x96,
|
||||
0x97, 0x69, 0x95, 0x6b, 0x6a, 0x94, 0x40, 0xbe, 0xbf, 0x41, 0xbd, 0x43,
|
||||
0x42, 0xbc, 0xb9, 0x47, 0x46, 0xb8, 0x44, 0xba, 0xbb, 0x45, 0xb1, 0x4f,
|
||||
0x4e, 0xb0, 0x4c, 0xb2, 0xb3, 0x4d, 0x48, 0xb6, 0xb7, 0x49, 0xb5, 0x4b,
|
||||
0x4a, 0xb4, 0xa1, 0x5f, 0x5e, 0xa0, 0x5c, 0xa2, 0xa3, 0x5d, 0x58, 0xa6,
|
||||
0xa7, 0x59, 0xa5, 0x5b, 0x5a, 0xa4, 0x50, 0xae, 0xaf, 0x51, 0xad, 0x53,
|
||||
0x52, 0xac, 0xa9, 0x57, 0x56, 0xa8, 0x54, 0xaa, 0xab, 0x55 };
|
||||
static const uint8_t HeaderCRC[256] = {
|
||||
0x00, 0xfe, 0xff, 0x01, 0xfd, 0x03, 0x02, 0xfc, 0xf9, 0x07, 0x06, 0xf8,
|
||||
0x04, 0xfa, 0xfb, 0x05, 0xf1, 0x0f, 0x0e, 0xf0, 0x0c, 0xf2, 0xf3, 0x0d,
|
||||
0x08, 0xf6, 0xf7, 0x09, 0xf5, 0x0b, 0x0a, 0xf4, 0xe1, 0x1f, 0x1e, 0xe0,
|
||||
0x1c, 0xe2, 0xe3, 0x1d, 0x18, 0xe6, 0xe7, 0x19, 0xe5, 0x1b, 0x1a, 0xe4,
|
||||
0x10, 0xee, 0xef, 0x11, 0xed, 0x13, 0x12, 0xec, 0xe9, 0x17, 0x16, 0xe8,
|
||||
0x14, 0xea, 0xeb, 0x15, 0xc1, 0x3f, 0x3e, 0xc0, 0x3c, 0xc2, 0xc3, 0x3d,
|
||||
0x38, 0xc6, 0xc7, 0x39, 0xc5, 0x3b, 0x3a, 0xc4, 0x30, 0xce, 0xcf, 0x31,
|
||||
0xcd, 0x33, 0x32, 0xcc, 0xc9, 0x37, 0x36, 0xc8, 0x34, 0xca, 0xcb, 0x35,
|
||||
0x20, 0xde, 0xdf, 0x21, 0xdd, 0x23, 0x22, 0xdc, 0xd9, 0x27, 0x26, 0xd8,
|
||||
0x24, 0xda, 0xdb, 0x25, 0xd1, 0x2f, 0x2e, 0xd0, 0x2c, 0xd2, 0xd3, 0x2d,
|
||||
0x28, 0xd6, 0xd7, 0x29, 0xd5, 0x2b, 0x2a, 0xd4, 0x81, 0x7f, 0x7e, 0x80,
|
||||
0x7c, 0x82, 0x83, 0x7d, 0x78, 0x86, 0x87, 0x79, 0x85, 0x7b, 0x7a, 0x84,
|
||||
0x70, 0x8e, 0x8f, 0x71, 0x8d, 0x73, 0x72, 0x8c, 0x89, 0x77, 0x76, 0x88,
|
||||
0x74, 0x8a, 0x8b, 0x75, 0x60, 0x9e, 0x9f, 0x61, 0x9d, 0x63, 0x62, 0x9c,
|
||||
0x99, 0x67, 0x66, 0x98, 0x64, 0x9a, 0x9b, 0x65, 0x91, 0x6f, 0x6e, 0x90,
|
||||
0x6c, 0x92, 0x93, 0x6d, 0x68, 0x96, 0x97, 0x69, 0x95, 0x6b, 0x6a, 0x94,
|
||||
0x40, 0xbe, 0xbf, 0x41, 0xbd, 0x43, 0x42, 0xbc, 0xb9, 0x47, 0x46, 0xb8,
|
||||
0x44, 0xba, 0xbb, 0x45, 0xb1, 0x4f, 0x4e, 0xb0, 0x4c, 0xb2, 0xb3, 0x4d,
|
||||
0x48, 0xb6, 0xb7, 0x49, 0xb5, 0x4b, 0x4a, 0xb4, 0xa1, 0x5f, 0x5e, 0xa0,
|
||||
0x5c, 0xa2, 0xa3, 0x5d, 0x58, 0xa6, 0xa7, 0x59, 0xa5, 0x5b, 0x5a, 0xa4,
|
||||
0x50, 0xae, 0xaf, 0x51, 0xad, 0x53, 0x52, 0xac, 0xa9, 0x57, 0x56, 0xa8,
|
||||
0x54, 0xaa, 0xab, 0x55
|
||||
};
|
||||
|
||||
uint8_t CRC_Calc_Header(uint8_t dataValue, uint8_t crcValue)
|
||||
{
|
||||
@@ -43,35 +45,37 @@ uint8_t CRC_Calc_Header(uint8_t dataValue, uint8_t crcValue)
|
||||
}
|
||||
|
||||
/* note: table is created using unit test below */
|
||||
static const uint16_t DataCRC[256] = { 0x0000, 0x1189, 0x2312, 0x329b, 0x4624,
|
||||
0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5,
|
||||
0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7,
|
||||
0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a,
|
||||
0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a,
|
||||
0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9,
|
||||
0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f,
|
||||
0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868,
|
||||
0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528,
|
||||
0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb,
|
||||
0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387,
|
||||
0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46,
|
||||
0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a,
|
||||
0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb,
|
||||
0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad,
|
||||
0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c,
|
||||
0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c,
|
||||
0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3,
|
||||
0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785,
|
||||
0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956,
|
||||
0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416,
|
||||
0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1,
|
||||
0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3,
|
||||
0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70,
|
||||
0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 };
|
||||
static const uint16_t DataCRC[256] = {
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48,
|
||||
0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108,
|
||||
0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb,
|
||||
0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399,
|
||||
0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e,
|
||||
0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e,
|
||||
0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd,
|
||||
0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285,
|
||||
0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44,
|
||||
0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014,
|
||||
0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5,
|
||||
0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3,
|
||||
0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862,
|
||||
0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e,
|
||||
0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1,
|
||||
0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483,
|
||||
0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50,
|
||||
0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710,
|
||||
0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7,
|
||||
0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1,
|
||||
0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72,
|
||||
0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e,
|
||||
0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf,
|
||||
0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d,
|
||||
0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c,
|
||||
0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||
};
|
||||
|
||||
uint16_t CRC_Calc_Data(uint8_t dataValue, uint16_t crcValue)
|
||||
{
|
||||
|
||||
@@ -19,14 +19,10 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t CRC_Calc_Header(
|
||||
uint8_t dataValue,
|
||||
uint8_t crcValue);
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t CRC_Calc_Data(
|
||||
uint8_t dataValue,
|
||||
uint16_t crcValue);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t CRC_Calc_Header(uint8_t dataValue, uint8_t crcValue);
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t CRC_Calc_Data(uint8_t dataValue, uint16_t crcValue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -77,7 +77,8 @@ bool datalink_init(char *ifname)
|
||||
return status;
|
||||
}
|
||||
|
||||
int datalink_send_pdu(BACNET_ADDRESS *dest,
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS *dest,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *pdu,
|
||||
unsigned pdu_len)
|
||||
@@ -272,7 +273,8 @@ bool datalink_init(char *ifname)
|
||||
return true;
|
||||
}
|
||||
|
||||
int datalink_send_pdu(BACNET_ADDRESS *dest,
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS *dest,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *pdu,
|
||||
unsigned pdu_len)
|
||||
|
||||
@@ -64,8 +64,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
BACNET_STACK_EXPORT
|
||||
void routed_get_my_address(
|
||||
BACNET_ADDRESS * my_address);
|
||||
void routed_get_my_address(BACNET_ADDRESS *my_address);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -93,51 +92,43 @@ void routed_get_my_address(
|
||||
#include "bacnet/npdu.h"
|
||||
|
||||
#define MAX_HEADER (8)
|
||||
#define MAX_MPDU (MAX_HEADER+MAX_PDU)
|
||||
#define MAX_MPDU (MAX_HEADER + MAX_PDU)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool datalink_init(char *ifname);
|
||||
BACNET_STACK_EXPORT
|
||||
bool datalink_init(char *ifname);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data,
|
||||
uint8_t * pdu,
|
||||
unsigned pdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS *dest,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *pdu,
|
||||
unsigned pdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t datalink_receive(
|
||||
BACNET_ADDRESS * src,
|
||||
uint8_t * pdu,
|
||||
uint16_t max_pdu,
|
||||
unsigned timeout);
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t datalink_receive(
|
||||
BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, unsigned timeout);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_cleanup(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_cleanup(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_get_broadcast_address(
|
||||
BACNET_ADDRESS * dest);
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_get_broadcast_address(BACNET_ADDRESS *dest);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_get_my_address(
|
||||
BACNET_ADDRESS * my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_get_my_address(BACNET_ADDRESS *my_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_set_interface(
|
||||
char *ifname);
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_set_interface(char *ifname);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_set(
|
||||
char *datalink_string);
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_set(char *datalink_string);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_maintenance_timer(uint16_t seconds);
|
||||
BACNET_STACK_EXPORT
|
||||
void datalink_maintenance_timer(uint16_t seconds);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@@ -167,7 +158,8 @@ extern "C" {
|
||||
* - BACDL_CUSTOM -- For externally linked datalink_xxx functions
|
||||
* - Clause 10 POINT-TO-POINT (PTP) and Clause 11 EIA/CEA-709.1 ("LonTalk") LAN
|
||||
* are not currently supported by this project.
|
||||
*//** @defgroup DLTemplates DataLink Template Functions
|
||||
*/
|
||||
/** @defgroup DLTemplates DataLink Template Functions
|
||||
* @ingroup DataLink
|
||||
* Most of the functions in this group are function templates which are assigned
|
||||
* to a specific DataLink network layer implementation either at compile time or
|
||||
|
||||
+29
-24
@@ -162,7 +162,8 @@ static int bbmd_register_as_foreign_device(void)
|
||||
}
|
||||
if (BBMD_Address_Valid) {
|
||||
if (BIP_DL_Debug) {
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"Registering with BBMD at %u.%u.%u.%u:%u for %u seconds\n",
|
||||
(unsigned)BBMD_Address.address[0],
|
||||
(unsigned)BBMD_Address.address[1],
|
||||
@@ -172,7 +173,8 @@ static int bbmd_register_as_foreign_device(void)
|
||||
}
|
||||
retval = bvlc_register_with_bbmd(&BBMD_Address, BBMD_TTL_Seconds);
|
||||
if (retval < 0) {
|
||||
fprintf(stderr, "FAILED to Register with BBMD at %u.%u.%u.%u:%u\n",
|
||||
fprintf(
|
||||
stderr, "FAILED to Register with BBMD at %u.%u.%u.%u:%u\n",
|
||||
(unsigned)BBMD_Address.address[0],
|
||||
(unsigned)BBMD_Address.address[1],
|
||||
(unsigned)BBMD_Address.address[2],
|
||||
@@ -190,7 +192,8 @@ static int bbmd_register_as_foreign_device(void)
|
||||
bip_get_addr_by_name(pEnv, &BBMD_Table_Entry.dest_address);
|
||||
if (entry_number == 1) {
|
||||
if (BIP_DL_Debug) {
|
||||
fprintf(stderr, "BBMD 1 address overridden %s=%s!\n",
|
||||
fprintf(
|
||||
stderr, "BBMD 1 address overridden %s=%s!\n",
|
||||
bbmd_env, pEnv);
|
||||
}
|
||||
}
|
||||
@@ -208,7 +211,8 @@ static int bbmd_register_as_foreign_device(void)
|
||||
bdt_entry_port = strtol(pEnv, NULL, 0);
|
||||
if (entry_number == 1) {
|
||||
if (BIP_DL_Debug) {
|
||||
fprintf(stderr, "BBMD 1 port overridden %s=%s!\n",
|
||||
fprintf(
|
||||
stderr, "BBMD 1 port overridden %s=%s!\n",
|
||||
bbmd_env, pEnv);
|
||||
}
|
||||
}
|
||||
@@ -236,7 +240,8 @@ static int bbmd_register_as_foreign_device(void)
|
||||
bvlc_broadcast_distribution_table_entry_append(
|
||||
bvlc_bdt_list(), &BBMD_Table_Entry);
|
||||
if (BIP_DL_Debug) {
|
||||
fprintf(stderr, "BBMD %4u: %u.%u.%u.%u:%u %u.%u.%u.%u\n",
|
||||
fprintf(
|
||||
stderr, "BBMD %4u: %u.%u.%u.%u:%u %u.%u.%u.%u\n",
|
||||
entry_number,
|
||||
(unsigned)BBMD_Table_Entry.dest_address.address[0],
|
||||
(unsigned)BBMD_Table_Entry.dest_address.address[1],
|
||||
@@ -303,14 +308,15 @@ static int bbmd6_register_as_foreign_device(void)
|
||||
pEnv = getenv("BACNET_BBMD6_ADDRESS");
|
||||
if (bvlc6_address_from_ascii(pEnv, &bip6_addr)) {
|
||||
if (BIP_DL_Debug) {
|
||||
fprintf(stderr,
|
||||
"Registering with BBMD6 at %s for %u seconds\n",
|
||||
pEnv, (unsigned)bip6_port, (unsigned)BBMD_TTL_Seconds);
|
||||
fprintf(
|
||||
stderr, "Registering with BBMD6 at %s for %u seconds\n", pEnv,
|
||||
(unsigned)bip6_port, (unsigned)BBMD_TTL_Seconds);
|
||||
}
|
||||
retval = bvlc6_register_with_bbmd(&bip6_addr, BBMD_TTL_Seconds);
|
||||
if (retval < 0) {
|
||||
fprintf(stderr, "FAILED to Register with BBMD6 at %s:%u\n",
|
||||
pEnv, (unsigned)BBMD_Address.port);
|
||||
fprintf(
|
||||
stderr, "FAILED to Register with BBMD6 at %s:%u\n", pEnv,
|
||||
(unsigned)BBMD_Address.port);
|
||||
}
|
||||
BBMD_Timer_Seconds = BBMD_TTL_Seconds;
|
||||
}
|
||||
@@ -361,19 +367,16 @@ void dlenv_network_port_init(void)
|
||||
bip_get_addr(&addr);
|
||||
prefix = bip_get_subnet_prefix();
|
||||
if (BIP_DL_Debug) {
|
||||
fprintf(stderr,
|
||||
"BIP: Setting Network Port %lu address %u.%u.%u.%u:%u/%u\n",
|
||||
(unsigned long)instance,
|
||||
(unsigned)addr.address[0],
|
||||
(unsigned)addr.address[1],
|
||||
(unsigned)addr.address[2],
|
||||
(unsigned)addr.address[3],
|
||||
(unsigned)addr.port,
|
||||
(unsigned)prefix);
|
||||
fprintf(
|
||||
stderr, "BIP: Setting Network Port %lu address %u.%u.%u.%u:%u/%u\n",
|
||||
(unsigned long)instance, (unsigned)addr.address[0],
|
||||
(unsigned)addr.address[1], (unsigned)addr.address[2],
|
||||
(unsigned)addr.address[3], (unsigned)addr.port, (unsigned)prefix);
|
||||
}
|
||||
Network_Port_BIP_Port_Set(instance, addr.port);
|
||||
Network_Port_IP_Address_Set(instance, addr.address[0], addr.address[1],
|
||||
addr.address[2], addr.address[3]);
|
||||
Network_Port_IP_Address_Set(
|
||||
instance, addr.address[0], addr.address[1], addr.address[2],
|
||||
addr.address[3]);
|
||||
Network_Port_IP_Subnet_Prefix_Set(instance, prefix);
|
||||
Network_Port_Link_Speed_Set(instance, 0.0);
|
||||
#if BBMD_ENABLED
|
||||
@@ -567,11 +570,13 @@ void dlenv_init(void)
|
||||
}
|
||||
pEnv = getenv("BACNET_BIP6_BROADCAST");
|
||||
if (pEnv) {
|
||||
bvlc6_address_set(&addr, (uint16_t)strtol(pEnv, NULL, 0), 0, 0, 0, 0, 0,
|
||||
0, BIP6_MULTICAST_GROUP_ID);
|
||||
bvlc6_address_set(
|
||||
&addr, (uint16_t)strtol(pEnv, NULL, 0), 0, 0, 0, 0, 0, 0,
|
||||
BIP6_MULTICAST_GROUP_ID);
|
||||
bip6_set_broadcast_addr(&addr);
|
||||
} else {
|
||||
bvlc6_address_set(&addr, BIP6_MULTICAST_SITE_LOCAL, 0, 0, 0, 0, 0, 0,
|
||||
bvlc6_address_set(
|
||||
&addr, BIP6_MULTICAST_SITE_LOCAL, 0, 0, 0, 0, 0, 0,
|
||||
BIP6_MULTICAST_GROUP_ID);
|
||||
bip6_set_broadcast_addr(&addr);
|
||||
}
|
||||
|
||||
+18
-27
@@ -20,41 +20,32 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void dlenv_init(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlenv_init(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_dl_debug_enable(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_dl_debug_enable(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_dl_debug_disable(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bip_dl_debug_disable(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int dlenv_register_as_foreign_device(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
int dlenv_register_as_foreign_device(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void dlenv_network_port_init(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlenv_network_port_init(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void dlenv_maintenance_timer(
|
||||
uint16_t elapsed_seconds);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlenv_maintenance_timer(uint16_t elapsed_seconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void dlenv_bbmd_address_set(
|
||||
const BACNET_IP_ADDRESS *address);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlenv_bbmd_address_set(const BACNET_IP_ADDRESS *address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void dlenv_bbmd_ttl_set(
|
||||
uint16_t ttl_secs);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlenv_bbmd_ttl_set(uint16_t ttl_secs);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int dlenv_bbmd_result(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
int dlenv_bbmd_result(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ static struct mstp_port_struct_t *MSTP_Port;
|
||||
* @param pdu_len - number of bytes of PDU data to send
|
||||
* @return number of bytes sent on success, zero on failure
|
||||
*/
|
||||
int dlmstp_send_pdu(BACNET_ADDRESS *dest,
|
||||
int dlmstp_send_pdu(
|
||||
BACNET_ADDRESS *dest,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *pdu,
|
||||
unsigned pdu_len)
|
||||
@@ -85,8 +86,7 @@ int dlmstp_send_pdu(BACNET_ADDRESS *dest,
|
||||
* @param timeout - number of milliseconds to wait for the data
|
||||
* @return amount of PDU data
|
||||
*/
|
||||
uint16_t MSTP_Get_Send(
|
||||
struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
||||
uint16_t MSTP_Get_Send(struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
||||
{
|
||||
uint16_t pdu_len = 0;
|
||||
struct dlmstp_packet *pkt;
|
||||
@@ -105,9 +105,10 @@ uint16_t MSTP_Get_Send(
|
||||
/* look at next PDU in queue without removing it */
|
||||
pkt = (struct dlmstp_packet *)(void *)Ringbuf_Peek(&user->PDU_Queue);
|
||||
/* convert the PDU into the MSTP Frame */
|
||||
pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0],
|
||||
mstp_port->OutputBufferSize, pkt->frame_type, pkt->address.mac[0],
|
||||
mstp_port->This_Station, &pkt->pdu[0], pkt->pdu_len);
|
||||
pdu_len = MSTP_Create_Frame(
|
||||
&mstp_port->OutputBuffer[0], mstp_port->OutputBufferSize,
|
||||
pkt->frame_type, pkt->address.mac[0], mstp_port->This_Station,
|
||||
&pkt->pdu[0], pkt->pdu_len);
|
||||
user->Statistics.transmit_pdu_counter++;
|
||||
(void)Ringbuf_Pop(&user->PDU_Queue, NULL);
|
||||
|
||||
@@ -163,15 +164,15 @@ static bool MSTP_Compare_Data_Expecting_Reply(
|
||||
}
|
||||
request.invoke_id = request_pdu[offset + 2];
|
||||
/* segmented message? */
|
||||
if (request_pdu[offset] & BIT(3))
|
||||
if (request_pdu[offset] & BIT(3)) {
|
||||
request.service_choice = request_pdu[offset + 5];
|
||||
else
|
||||
} else {
|
||||
request.service_choice = request_pdu[offset + 3];
|
||||
}
|
||||
/* decode the reply data */
|
||||
bacnet_address_copy(&reply.address, dest_address);
|
||||
offset = bacnet_npdu_decode(
|
||||
&reply_pdu[0], reply_pdu_len, &reply.address, NULL,
|
||||
&reply.npdu_data);
|
||||
&reply_pdu[0], reply_pdu_len, &reply.address, NULL, &reply.npdu_data);
|
||||
if (reply.npdu_data.network_layer_message) {
|
||||
return false;
|
||||
}
|
||||
@@ -186,10 +187,11 @@ static bool MSTP_Compare_Data_Expecting_Reply(
|
||||
case PDU_TYPE_COMPLEX_ACK:
|
||||
reply.invoke_id = reply_pdu[offset + 1];
|
||||
/* segmented message? */
|
||||
if (reply_pdu[offset] & BIT(3))
|
||||
if (reply_pdu[offset] & BIT(3)) {
|
||||
reply.service_choice = reply_pdu[offset + 4];
|
||||
else
|
||||
} else {
|
||||
reply.service_choice = reply_pdu[offset + 2];
|
||||
}
|
||||
break;
|
||||
case PDU_TYPE_ERROR:
|
||||
reply.invoke_id = reply_pdu[offset + 1];
|
||||
@@ -241,8 +243,7 @@ static bool MSTP_Compare_Data_Expecting_Reply(
|
||||
* @param timeout number of milliseconds to wait for a packet
|
||||
* @return number of bytes, or 0 if no reply is available
|
||||
*/
|
||||
uint16_t MSTP_Get_Reply(
|
||||
struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
||||
uint16_t MSTP_Get_Reply(struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
||||
{
|
||||
uint16_t pdu_len = 0;
|
||||
bool matched = false;
|
||||
@@ -268,9 +269,10 @@ uint16_t MSTP_Get_Reply(
|
||||
return 0;
|
||||
}
|
||||
/* convert the PDU into the MSTP Frame */
|
||||
pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0],
|
||||
mstp_port->OutputBufferSize, pkt->frame_type, pkt->address.mac[0],
|
||||
mstp_port->This_Station, &pkt->pdu[0], pkt->pdu_len);
|
||||
pdu_len = MSTP_Create_Frame(
|
||||
&mstp_port->OutputBuffer[0], mstp_port->OutputBufferSize,
|
||||
pkt->frame_type, pkt->address.mac[0], mstp_port->This_Station,
|
||||
&pkt->pdu[0], pkt->pdu_len);
|
||||
user->Statistics.transmit_pdu_counter++;
|
||||
(void)Ringbuf_Pop(&user->PDU_Queue, NULL);
|
||||
|
||||
@@ -283,7 +285,8 @@ uint16_t MSTP_Get_Reply(
|
||||
* @param buffer - buffer to send
|
||||
* @param nbytes - number of bytes of data to send
|
||||
*/
|
||||
void MSTP_Send_Frame(struct mstp_port_struct_t *mstp_port,
|
||||
void MSTP_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port,
|
||||
const uint8_t *buffer,
|
||||
uint16_t nbytes)
|
||||
{
|
||||
@@ -366,7 +369,7 @@ uint16_t dlmstp_receive(
|
||||
}
|
||||
/* only do receive state machine while we don't have a frame */
|
||||
while ((MSTP_Port->ReceivedValidFrame == false) &&
|
||||
(MSTP_Port->ReceivedInvalidFrame == false)) {
|
||||
(MSTP_Port->ReceivedInvalidFrame == false)) {
|
||||
MSTP_Port->DataAvailable = driver->read(&data_register);
|
||||
if (MSTP_Port->DataAvailable) {
|
||||
MSTP_Port->DataRegister = data_register;
|
||||
@@ -395,7 +398,8 @@ uint16_t dlmstp_receive(
|
||||
/* only node state machines while rx is idle */
|
||||
if (MSTP_Port->SlaveNodeEnabled) {
|
||||
MSTP_Slave_Node_FSM(MSTP_Port);
|
||||
} else if ((MSTP_Port->This_Station <= DEFAULT_MAX_MASTER) ||
|
||||
} else if (
|
||||
(MSTP_Port->This_Station <= DEFAULT_MAX_MASTER) ||
|
||||
MSTP_Port->ZeroConfigEnabled) {
|
||||
while (MSTP_Master_Node_FSM(MSTP_Port)) {
|
||||
/* do nothing while some states fast transition */
|
||||
@@ -670,7 +674,7 @@ void dlmstp_set_baud_rate(uint32_t baud)
|
||||
/* Tframe_abort=60 bit times, not to exceed 100 milliseconds.*/
|
||||
if (MSTP_Port->Tframe_abort <= 7) {
|
||||
/* within baud range, so auto-calculate range based on baud */
|
||||
MSTP_Port->Tframe_abort = 1+((60*1000UL)/baud);
|
||||
MSTP_Port->Tframe_abort = 1 + ((60 * 1000UL) / baud);
|
||||
}
|
||||
/* Tturnaround=40 bit times */
|
||||
MSTP_Port->Tturnaround_timeout = 1 + ((Tturnaround * 1000) / baud);
|
||||
@@ -802,8 +806,8 @@ bool dlmstp_init(char *ifname)
|
||||
MSTP_Port->SilenceTimerReset = dlmstp_silence_reset;
|
||||
user = (struct dlmstp_user_data_t *)MSTP_Port->UserData;
|
||||
if (user && !user->Initialized) {
|
||||
Ringbuf_Init(&user->PDU_Queue,
|
||||
(volatile uint8_t *)user->PDU_Buffer,
|
||||
Ringbuf_Init(
|
||||
&user->PDU_Queue, (volatile uint8_t *)user->PDU_Buffer,
|
||||
sizeof(user->PDU_Buffer), DLMSTP_MAX_INFO_FRAMES);
|
||||
MSTP_Init(MSTP_Port);
|
||||
user->Initialized = true;
|
||||
|
||||
+102
-120
@@ -22,15 +22,15 @@
|
||||
|
||||
/* defines specific to MS/TP */
|
||||
/* preamble+type+dest+src+len+crc8+crc16 */
|
||||
#define DLMSTP_HEADER_MAX (2+1+1+1+2+1+2)
|
||||
#define DLMSTP_MPDU_MAX (DLMSTP_HEADER_MAX+MAX_PDU)
|
||||
#define DLMSTP_HEADER_MAX (2 + 1 + 1 + 1 + 2 + 1 + 2)
|
||||
#define DLMSTP_MPDU_MAX (DLMSTP_HEADER_MAX + MAX_PDU)
|
||||
|
||||
typedef struct dlmstp_packet {
|
||||
bool ready; /* true if ready to be sent or received */
|
||||
BACNET_ADDRESS address; /* source address */
|
||||
BACNET_ADDRESS address; /* source address */
|
||||
uint8_t frame_type; /* type of message */
|
||||
uint16_t pdu_len; /* packet length */
|
||||
uint8_t pdu[DLMSTP_MPDU_MAX]; /* packet */
|
||||
uint16_t pdu_len; /* packet length */
|
||||
uint8_t pdu[DLMSTP_MPDU_MAX]; /* packet */
|
||||
} DLMSTP_PACKET;
|
||||
|
||||
/* container for packet and token statistics */
|
||||
@@ -104,142 +104,124 @@ typedef void (*dlmstp_hook_frame_rx_complete_cb)(
|
||||
uint8_t src,
|
||||
uint8_t dest,
|
||||
uint8_t mstp_msg_type,
|
||||
uint8_t * pdu,
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool dlmstp_init(
|
||||
char *ifname);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_reset(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_cleanup(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool dlmstp_init(char *ifname);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_reset(void);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_cleanup(void);
|
||||
|
||||
/* returns number of bytes sent on success, negative on failure */
|
||||
BACNET_STACK_EXPORT
|
||||
int dlmstp_send_pdu(
|
||||
BACNET_ADDRESS * dest, /* destination address */
|
||||
BACNET_NPDU_DATA * npdu_data, /* network information */
|
||||
uint8_t * pdu, /* any data to be sent - may be null */
|
||||
unsigned pdu_len); /* number of bytes of data */
|
||||
/* returns number of bytes sent on success, negative on failure */
|
||||
BACNET_STACK_EXPORT
|
||||
int dlmstp_send_pdu(
|
||||
BACNET_ADDRESS *dest, /* destination address */
|
||||
BACNET_NPDU_DATA *npdu_data, /* network information */
|
||||
uint8_t *pdu, /* any data to be sent - may be null */
|
||||
unsigned pdu_len); /* number of bytes of data */
|
||||
|
||||
/* returns the number of octets in the PDU, or zero on failure */
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t dlmstp_receive(
|
||||
BACNET_ADDRESS * src, /* source address */
|
||||
uint8_t * pdu, /* PDU data */
|
||||
uint16_t max_pdu, /* amount of space available in the PDU */
|
||||
unsigned timeout); /* milliseconds to wait for a packet */
|
||||
/* returns the number of octets in the PDU, or zero on failure */
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t dlmstp_receive(
|
||||
BACNET_ADDRESS *src, /* source address */
|
||||
uint8_t *pdu, /* PDU data */
|
||||
uint16_t max_pdu, /* amount of space available in the PDU */
|
||||
unsigned timeout); /* milliseconds to wait for a packet */
|
||||
|
||||
/* This parameter represents the value of the Max_Info_Frames property of */
|
||||
/* the node's Device object. The value of Max_Info_Frames specifies the */
|
||||
/* maximum number of information frames the node may send before it must */
|
||||
/* pass the token. Max_Info_Frames may have different values on different */
|
||||
/* nodes. This may be used to allocate more or less of the available link */
|
||||
/* bandwidth to particular nodes. If Max_Info_Frames is not writable in a */
|
||||
/* node, its value shall be 1. */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_max_info_frames(
|
||||
uint8_t max_info_frames);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t dlmstp_max_info_frames(
|
||||
void);
|
||||
/* This parameter represents the value of the Max_Info_Frames property of */
|
||||
/* the node's Device object. The value of Max_Info_Frames specifies the */
|
||||
/* maximum number of information frames the node may send before it must */
|
||||
/* pass the token. Max_Info_Frames may have different values on different */
|
||||
/* nodes. This may be used to allocate more or less of the available link */
|
||||
/* bandwidth to particular nodes. If Max_Info_Frames is not writable in a */
|
||||
/* node, its value shall be 1. */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_max_info_frames(uint8_t max_info_frames);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t dlmstp_max_info_frames(void);
|
||||
|
||||
/* This parameter represents the value of the Max_Master property of the */
|
||||
/* node's Device object. The value of Max_Master specifies the highest */
|
||||
/* allowable address for master nodes. The value of Max_Master shall be */
|
||||
/* less than or equal to 127. If Max_Master is not writable in a node, */
|
||||
/* its value shall be 127. */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_max_master(
|
||||
uint8_t max_master);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t dlmstp_max_master(
|
||||
void);
|
||||
/* This parameter represents the value of the Max_Master property of the */
|
||||
/* node's Device object. The value of Max_Master specifies the highest */
|
||||
/* allowable address for master nodes. The value of Max_Master shall be */
|
||||
/* less than or equal to 127. If Max_Master is not writable in a node, */
|
||||
/* its value shall be 127. */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_max_master(uint8_t max_master);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t dlmstp_max_master(void);
|
||||
|
||||
/* MAC address 0-127 */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_mac_address(
|
||||
uint8_t my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t dlmstp_mac_address(
|
||||
void);
|
||||
/* MAC address 0-127 */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_mac_address(uint8_t my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t dlmstp_mac_address(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_get_my_address(
|
||||
BACNET_ADDRESS * my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_get_broadcast_address(
|
||||
BACNET_ADDRESS * dest); /* destination address */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_get_my_address(BACNET_ADDRESS *my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_get_broadcast_address(
|
||||
BACNET_ADDRESS *dest); /* destination address */
|
||||
|
||||
/* RS485 Baud Rate 9600, 19200, 38400, 57600, 115200 */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_baud_rate(
|
||||
uint32_t baud);
|
||||
BACNET_STACK_EXPORT
|
||||
uint32_t dlmstp_baud_rate(
|
||||
void);
|
||||
/* RS485 Baud Rate 9600, 19200, 38400, 57600, 115200 */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_baud_rate(uint32_t baud);
|
||||
BACNET_STACK_EXPORT
|
||||
uint32_t dlmstp_baud_rate(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_fill_bacnet_address(
|
||||
BACNET_ADDRESS * src,
|
||||
uint8_t mstp_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_fill_bacnet_address(BACNET_ADDRESS *src, uint8_t mstp_address);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool dlmstp_sole_master(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool dlmstp_send_pdu_queue_empty(void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool dlmstp_send_pdu_queue_full(void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool dlmstp_sole_master(void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool dlmstp_send_pdu_queue_empty(void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool dlmstp_send_pdu_queue_full(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t dlmstp_max_info_frames_limit(void);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t dlmstp_max_master_limit(void);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t dlmstp_max_info_frames_limit(void);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t dlmstp_max_master_limit(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint32_t dlmstp_silence_milliseconds(
|
||||
void *arg);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_silence_reset(
|
||||
void *arg);
|
||||
BACNET_STACK_EXPORT
|
||||
uint32_t dlmstp_silence_milliseconds(void *arg);
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_silence_reset(void *arg);
|
||||
|
||||
/* Set the callback function to be called on every valid received frame */
|
||||
/* This is not necessary for normal usage, but is helpful if the caller */
|
||||
/* needs to monitor traffic on the MS/TP bus */
|
||||
/* The specified callback function should execute quickly so as to avoid */
|
||||
/* interfering with bus timing */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_frame_rx_complete_callback(
|
||||
dlmstp_hook_frame_rx_complete_cb cb_func);
|
||||
/* Set the callback function to be called on every valid received frame */
|
||||
/* This is not necessary for normal usage, but is helpful if the caller */
|
||||
/* needs to monitor traffic on the MS/TP bus */
|
||||
/* The specified callback function should execute quickly so as to avoid */
|
||||
/* interfering with bus timing */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_frame_rx_complete_callback(
|
||||
dlmstp_hook_frame_rx_complete_cb cb_func);
|
||||
|
||||
/* Set the callback function to be called every time the start of a */
|
||||
/* frame is detected. This is not necessary for normal usage, but is */
|
||||
/* helpful if the caller needs to know when a frame begins for timing */
|
||||
/* (timing is heavily dependent upon baud rate and the period with */
|
||||
/* which dlmstp_receive is called) */
|
||||
/* The specified callback function should execute quickly so as to avoid */
|
||||
/* interfering with bus timing */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_frame_rx_start_callback(
|
||||
dlmstp_hook_frame_rx_start_cb cb_func);
|
||||
/* Set the callback function to be called every time the start of a */
|
||||
/* frame is detected. This is not necessary for normal usage, but is */
|
||||
/* helpful if the caller needs to know when a frame begins for timing */
|
||||
/* (timing is heavily dependent upon baud rate and the period with */
|
||||
/* which dlmstp_receive is called) */
|
||||
/* The specified callback function should execute quickly so as to avoid */
|
||||
/* interfering with bus timing */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_set_frame_rx_start_callback(dlmstp_hook_frame_rx_start_cb cb_func);
|
||||
|
||||
/* Reset the statistics counters on the MS/TP datalink */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_reset_statistics(void);
|
||||
/* Reset the statistics counters on the MS/TP datalink */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_reset_statistics(void);
|
||||
|
||||
/* Retrieve statistics counters from the MS/TP datalink */
|
||||
/* Values for the current counters at the time this function is called */
|
||||
/* will be copied into *statistics */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_fill_statistics(struct dlmstp_statistics * statistics);
|
||||
/* Retrieve statistics counters from the MS/TP datalink */
|
||||
/* Values for the current counters at the time this function is called */
|
||||
/* will be copied into *statistics */
|
||||
BACNET_STACK_EXPORT
|
||||
void dlmstp_fill_statistics(struct dlmstp_statistics *statistics);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -19,60 +19,51 @@
|
||||
#include "bacnet/npdu.h"
|
||||
|
||||
/* specific defines for Ethernet */
|
||||
#define ETHERNET_HEADER_MAX (6+6+2+1+1+1)
|
||||
#define ETHERNET_MPDU_MAX (ETHERNET_HEADER_MAX+MAX_PDU)
|
||||
#define ETHERNET_HEADER_MAX (6 + 6 + 2 + 1 + 1 + 1)
|
||||
#define ETHERNET_MPDU_MAX (ETHERNET_HEADER_MAX + MAX_PDU)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool ethernet_valid(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void ethernet_cleanup(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool ethernet_init(
|
||||
char *interface_name);
|
||||
BACNET_STACK_EXPORT
|
||||
bool ethernet_valid(void);
|
||||
BACNET_STACK_EXPORT
|
||||
void ethernet_cleanup(void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool ethernet_init(char *interface_name);
|
||||
|
||||
/* function to send a packet out the 802.2 socket */
|
||||
/* returns number of bytes sent on success, negative on failure */
|
||||
BACNET_STACK_EXPORT
|
||||
int ethernet_send_pdu(
|
||||
BACNET_ADDRESS * dest, /* destination address */
|
||||
BACNET_NPDU_DATA * npdu_data, /* network information */
|
||||
uint8_t * pdu, /* any data to be sent - may be null */
|
||||
unsigned pdu_len); /* number of bytes of data */
|
||||
BACNET_STACK_EXPORT
|
||||
int ethernet_send_pdu(
|
||||
BACNET_ADDRESS *dest, /* destination address */
|
||||
BACNET_NPDU_DATA *npdu_data, /* network information */
|
||||
uint8_t *pdu, /* any data to be sent - may be null */
|
||||
unsigned pdu_len); /* number of bytes of data */
|
||||
|
||||
/* receives an 802.2 framed packet */
|
||||
/* returns the number of octets in the PDU, or zero on failure */
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t ethernet_receive(
|
||||
BACNET_ADDRESS * src, /* source address */
|
||||
uint8_t * pdu, /* PDU data */
|
||||
uint16_t max_pdu, /* amount of space available in the PDU */
|
||||
unsigned timeout); /* milliseconds to wait for a packet */
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t ethernet_receive(
|
||||
BACNET_ADDRESS *src, /* source address */
|
||||
uint8_t *pdu, /* PDU data */
|
||||
uint16_t max_pdu, /* amount of space available in the PDU */
|
||||
unsigned timeout); /* milliseconds to wait for a packet */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void ethernet_set_my_address(
|
||||
const BACNET_ADDRESS * my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void ethernet_get_my_address(
|
||||
BACNET_ADDRESS * my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void ethernet_get_broadcast_address(
|
||||
BACNET_ADDRESS * dest); /* destination address */
|
||||
BACNET_STACK_EXPORT
|
||||
void ethernet_set_my_address(const BACNET_ADDRESS *my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void ethernet_get_my_address(BACNET_ADDRESS *my_address);
|
||||
BACNET_STACK_EXPORT
|
||||
void ethernet_get_broadcast_address(
|
||||
BACNET_ADDRESS *dest); /* destination address */
|
||||
|
||||
/* some functions from Linux driver */
|
||||
BACNET_STACK_EXPORT
|
||||
void ethernet_debug_address(
|
||||
const char *info,
|
||||
const BACNET_ADDRESS * dest);
|
||||
BACNET_STACK_EXPORT
|
||||
int ethernet_send(
|
||||
uint8_t * mtu,
|
||||
int mtu_len);
|
||||
/* some functions from Linux driver */
|
||||
BACNET_STACK_EXPORT
|
||||
void ethernet_debug_address(const char *info, const BACNET_ADDRESS *dest);
|
||||
BACNET_STACK_EXPORT
|
||||
int ethernet_send(uint8_t *mtu, int mtu_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+129
-107
@@ -157,7 +157,8 @@ void MSTP_Fill_BACnet_Address(BACNET_ADDRESS *src, uint8_t mstp_address)
|
||||
* @param data_len - number of bytes of data
|
||||
* @return number of bytes encoded, or 0 on error
|
||||
*/
|
||||
uint16_t MSTP_Create_Frame(uint8_t *buffer,
|
||||
uint16_t MSTP_Create_Frame(
|
||||
uint8_t *buffer,
|
||||
uint16_t buffer_size,
|
||||
uint8_t frame_type,
|
||||
uint8_t destination,
|
||||
@@ -184,13 +185,13 @@ uint16_t MSTP_Create_Frame(uint8_t *buffer,
|
||||
} else if (frame_type == FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY) {
|
||||
frame_type = FRAME_TYPE_BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY;
|
||||
cobs_bacnet_frame = true;
|
||||
} else if ((frame_type < Nmin_COBS_type) ||
|
||||
(frame_type > Nmax_COBS_type)) {
|
||||
} else if (
|
||||
(frame_type < Nmin_COBS_type) || (frame_type > Nmax_COBS_type)) {
|
||||
/* I'm sorry, Dave, I'm afraid I can't do that. */
|
||||
return 0;
|
||||
}
|
||||
cobs_len = cobs_frame_encode(&buffer[8], buffer_size-8, data,
|
||||
data_len);
|
||||
cobs_len =
|
||||
cobs_frame_encode(&buffer[8], buffer_size - 8, data, data_len);
|
||||
/* check the results of COBs encoding for validity */
|
||||
if (cobs_bacnet_frame) {
|
||||
if (cobs_len < Nmin_COBS_length_BACnet) {
|
||||
@@ -215,7 +216,7 @@ uint16_t MSTP_Create_Frame(uint8_t *buffer,
|
||||
return 0;
|
||||
}
|
||||
if ((8 + data_len + 2) > buffer_size) {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
for (index = 8; index < (data_len + 8); index++, data++) {
|
||||
buffer[index] = *data;
|
||||
@@ -223,7 +224,7 @@ uint16_t MSTP_Create_Frame(uint8_t *buffer,
|
||||
}
|
||||
crc16 = ~crc16;
|
||||
buffer[index] = crc16 & 0xFF; /* LSB first */
|
||||
buffer[index+1] = crc16 >> 8;
|
||||
buffer[index + 1] = crc16 >> 8;
|
||||
}
|
||||
buffer[0] = 0x55;
|
||||
buffer[1] = 0xFF;
|
||||
@@ -255,7 +256,8 @@ uint16_t MSTP_Create_Frame(uint8_t *buffer,
|
||||
* @param data - any data to be sent - may be null
|
||||
* @param data_len - number of bytes of data
|
||||
*/
|
||||
void MSTP_Create_And_Send_Frame(struct mstp_port_struct_t *mstp_port,
|
||||
void MSTP_Create_And_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port,
|
||||
uint8_t frame_type,
|
||||
uint8_t destination,
|
||||
uint8_t source,
|
||||
@@ -264,9 +266,9 @@ void MSTP_Create_And_Send_Frame(struct mstp_port_struct_t *mstp_port,
|
||||
{
|
||||
uint16_t len = 0; /* number of bytes to send */
|
||||
|
||||
len =
|
||||
MSTP_Create_Frame(mstp_port->OutputBuffer, mstp_port->OutputBufferSize,
|
||||
frame_type, destination, source, data, data_len);
|
||||
len = MSTP_Create_Frame(
|
||||
mstp_port->OutputBuffer, mstp_port->OutputBufferSize, frame_type,
|
||||
destination, source, data, data_len);
|
||||
|
||||
MSTP_Send_Frame(mstp_port, &mstp_port->OutputBuffer[0], len);
|
||||
/* FIXME: be sure to reset SilenceTimer() after each octet is sent! */
|
||||
@@ -361,7 +363,8 @@ void MSTP_Receive_Frame_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
/* wait for the start of a frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
printf_receive_error("MSTP: Rx Header: SilenceTimer %u > %d\n",
|
||||
printf_receive_error(
|
||||
"MSTP: Rx Header: SilenceTimer %u > %d\n",
|
||||
(unsigned)mstp_port->SilenceTimer((void *)mstp_port),
|
||||
mstp_port->Tframe_abort);
|
||||
} else if (mstp_port->ReceiveError == true) {
|
||||
@@ -418,7 +421,8 @@ void MSTP_Receive_Frame_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* indicate that an error has occurred during
|
||||
the reception of a frame */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
printf_receive_error("MSTP: Rx Header: BadCRC [%02X]\n",
|
||||
printf_receive_error(
|
||||
"MSTP: Rx Header: BadCRC [%02X]\n",
|
||||
mstp_port->DataRegister);
|
||||
/* wait for the start of the next frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
@@ -426,16 +430,17 @@ void MSTP_Receive_Frame_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
if (mstp_port->DataLength == 0) {
|
||||
/* NoData */
|
||||
if ((mstp_port->DestinationAddress ==
|
||||
mstp_port->This_Station) ||
|
||||
mstp_port->This_Station) ||
|
||||
(mstp_port->DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS) ||
|
||||
MSTP_BROADCAST_ADDRESS) ||
|
||||
(mstp_port->This_Station ==
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
printf_receive_data("%s",
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
printf_receive_data(
|
||||
"%s",
|
||||
mstptext_frame_type(
|
||||
(unsigned)mstp_port->FrameType));
|
||||
(unsigned)mstp_port->FrameType));
|
||||
/* indicate that a frame with no data has been
|
||||
* received */
|
||||
* received */
|
||||
mstp_port->ReceivedValidFrame = true;
|
||||
}
|
||||
/* wait for the start of the next frame. */
|
||||
@@ -443,11 +448,11 @@ void MSTP_Receive_Frame_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
} else {
|
||||
/* receive the data portion of the frame. */
|
||||
if ((mstp_port->DestinationAddress ==
|
||||
mstp_port->This_Station) ||
|
||||
mstp_port->This_Station) ||
|
||||
(mstp_port->DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS) ||
|
||||
MSTP_BROADCAST_ADDRESS) ||
|
||||
(mstp_port->This_Station ==
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
if (mstp_port->DataLength <=
|
||||
mstp_port->InputBufferSize) {
|
||||
/* Data */
|
||||
@@ -476,7 +481,8 @@ void MSTP_Receive_Frame_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* indicate that an error has occurred during */
|
||||
/* the reception of a frame */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
printf_receive_error("MSTP: Rx Data: BadIndex %u\n",
|
||||
printf_receive_error(
|
||||
"MSTP: Rx Data: BadIndex %u\n",
|
||||
(unsigned)mstp_port->Index);
|
||||
/* wait for the start of a frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
@@ -544,15 +550,16 @@ void MSTP_Receive_Frame_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
mstp_port->DataCRC = CRC_Calc_Data(
|
||||
mstp_port->DataRegister, mstp_port->DataCRC);
|
||||
mstp_port->DataCRCActualLSB = mstp_port->DataRegister;
|
||||
printf_receive_data("%s",
|
||||
printf_receive_data(
|
||||
"%s",
|
||||
mstptext_frame_type((unsigned)mstp_port->FrameType));
|
||||
if (((mstp_port->Index + 1) < mstp_port->InputBufferSize) &&
|
||||
(mstp_port->FrameType >= Nmin_COBS_type) &&
|
||||
(mstp_port->FrameType <= Nmax_COBS_type)) {
|
||||
mstp_port->DataLength = cobs_frame_decode(
|
||||
&mstp_port->InputBuffer[mstp_port->Index + 1],
|
||||
mstp_port->InputBufferSize,
|
||||
mstp_port->InputBuffer, mstp_port->Index + 1);
|
||||
mstp_port->InputBufferSize, mstp_port->InputBuffer,
|
||||
mstp_port->Index + 1);
|
||||
if (mstp_port->DataLength > 0) {
|
||||
mstp_port->ReceivedValidFrame = true;
|
||||
} else {
|
||||
@@ -631,9 +638,10 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
mstp_port->RetryCount = 0;
|
||||
mstp_port->EventCount = 0;
|
||||
mstp_port->SoleMaster = true;
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_POLL_FOR_MASTER,
|
||||
mstp_port->Poll_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_POLL_FOR_MASTER;
|
||||
transition_now = true;
|
||||
}
|
||||
@@ -658,9 +666,10 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* wait for the next frame - remain in IDLE */
|
||||
mstp_port->ReceivedInvalidFrame = false;
|
||||
} else if (mstp_port->ReceivedValidFrame == true) {
|
||||
printf_master("MSTP: ReceivedValidFrame "
|
||||
"Src=%02X Dest=%02X DataLen=%u "
|
||||
"FC=%u ST=%u Type=%s\n",
|
||||
printf_master(
|
||||
"MSTP: ReceivedValidFrame "
|
||||
"Src=%02X Dest=%02X DataLen=%u "
|
||||
"FC=%u ST=%u Type=%s\n",
|
||||
mstp_port->SourceAddress, mstp_port->DestinationAddress,
|
||||
mstp_port->DataLength, mstp_port->FrameCount,
|
||||
mstp_port->SilenceTimer((void *)mstp_port),
|
||||
@@ -696,7 +705,8 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* DestinationAddress is equal to TS */
|
||||
if (mstp_port->DestinationAddress ==
|
||||
mstp_port->This_Station) {
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port,
|
||||
FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER,
|
||||
mstp_port->SourceAddress,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
@@ -705,8 +715,9 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
|
||||
case FRAME_TYPE_BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY:
|
||||
if ((mstp_port->DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS) &&
|
||||
(npdu_confirmed_service(mstp_port->InputBuffer,
|
||||
MSTP_BROADCAST_ADDRESS) &&
|
||||
(npdu_confirmed_service(
|
||||
mstp_port->InputBuffer,
|
||||
mstp_port->DataLength))) {
|
||||
/* BTL test: verifies that the IUT will quietly
|
||||
discard any Confirmed-Request-PDU, whose
|
||||
@@ -733,8 +744,8 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
}
|
||||
break;
|
||||
case FRAME_TYPE_TEST_REQUEST:
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_TEST_RESPONSE,
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_TEST_RESPONSE,
|
||||
mstp_port->SourceAddress,
|
||||
mstp_port->This_Station, mstp_port->InputBuffer,
|
||||
mstp_port->DataLength);
|
||||
@@ -750,8 +761,8 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST) {
|
||||
mstp_port->ReceivedValidFrame = false;
|
||||
}
|
||||
} else if (mstp_port->SilenceTimer((void *)mstp_port) >=
|
||||
Tno_token) {
|
||||
} else if (
|
||||
mstp_port->SilenceTimer((void *)mstp_port) >= Tno_token) {
|
||||
/* LostToken */
|
||||
/* assume that the token has been lost */
|
||||
mstp_port->EventCount = 0; /* Addendum 135-2004d-8 */
|
||||
@@ -777,8 +788,8 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
} else {
|
||||
uint8_t frame_type = mstp_port->OutputBuffer[2];
|
||||
uint8_t destination = mstp_port->OutputBuffer[3];
|
||||
MSTP_Send_Frame(mstp_port,
|
||||
&mstp_port->OutputBuffer[0], (uint16_t)length);
|
||||
MSTP_Send_Frame(
|
||||
mstp_port, &mstp_port->OutputBuffer[0], (uint16_t)length);
|
||||
mstp_port->FrameCount++;
|
||||
switch (frame_type) {
|
||||
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
||||
@@ -882,15 +893,16 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* before passing the token. */
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_USE_TOKEN;
|
||||
transition_now = true;
|
||||
} else if ((mstp_port->SoleMaster == false) &&
|
||||
} else if (
|
||||
(mstp_port->SoleMaster == false) &&
|
||||
(mstp_port->Next_Station == mstp_port->This_Station)) {
|
||||
/* NextStationUnknown - added in Addendum 135-2008v-1 */
|
||||
/* then the next station to which the token
|
||||
should be sent is unknown - so PollForMaster */
|
||||
mstp_port->Poll_Station = next_this_station;
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_POLL_FOR_MASTER,
|
||||
mstp_port->Poll_Station, mstp_port->This_Station, NULL, 0);
|
||||
mstp_port->RetryCount = 0;
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_POLL_FOR_MASTER;
|
||||
} else if (mstp_port->TokenCount < (Npoll - 1)) {
|
||||
@@ -916,9 +928,9 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
* case. */
|
||||
mstp_port->TokenCount++;
|
||||
/* transmit a Token frame to NS */
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_TOKEN, mstp_port->Next_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
mstp_port->RetryCount = 0;
|
||||
mstp_port->EventCount = 0;
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_PASS_TOKEN;
|
||||
@@ -927,9 +939,10 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
if (mstp_port->SoleMaster == true) {
|
||||
/* SoleMasterRestartMaintenancePFM */
|
||||
mstp_port->Poll_Station = next_next_station;
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_POLL_FOR_MASTER,
|
||||
mstp_port->Poll_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
/* no known successor node */
|
||||
mstp_port->Next_Station = mstp_port->This_Station;
|
||||
mstp_port->RetryCount = 0;
|
||||
@@ -943,9 +956,9 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* ResetMaintenancePFM */
|
||||
mstp_port->Poll_Station = mstp_port->This_Station;
|
||||
/* transmit a Token frame to NS */
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_TOKEN, mstp_port->Next_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
mstp_port->RetryCount = 0;
|
||||
/* changed in Errata SSPC-135-2004 */
|
||||
mstp_port->TokenCount = 1;
|
||||
@@ -955,9 +968,9 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
} else {
|
||||
/* SendMaintenancePFM */
|
||||
mstp_port->Poll_Station = next_poll_station;
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_POLL_FOR_MASTER,
|
||||
mstp_port->Poll_Station, mstp_port->This_Station, NULL, 0);
|
||||
mstp_port->RetryCount = 0;
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_POLL_FOR_MASTER;
|
||||
}
|
||||
@@ -980,9 +993,9 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* RetrySendToken */
|
||||
mstp_port->RetryCount++;
|
||||
/* Transmit a Token frame to NS */
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_TOKEN, mstp_port->Next_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
mstp_port->EventCount = 0;
|
||||
/* re-enter the current state to listen for NS */
|
||||
/* to begin using the token. */
|
||||
@@ -992,9 +1005,10 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* note: if NS=TS-1, this node could send PFM to self! */
|
||||
mstp_port->Poll_Station = next_next_station;
|
||||
/* Transmit a Poll For Master frame to PS. */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_POLL_FOR_MASTER,
|
||||
mstp_port->Poll_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
/* no known successor node */
|
||||
mstp_port->Next_Station = mstp_port->This_Station;
|
||||
mstp_port->RetryCount = 0;
|
||||
@@ -1034,9 +1048,10 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* on the network and is empowered to create a token. */
|
||||
mstp_port->Poll_Station = next_this_station;
|
||||
/* Transmit a Poll For Master frame to PS. */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_POLL_FOR_MASTER,
|
||||
mstp_port->Poll_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
/* indicate that the next station is unknown */
|
||||
mstp_port->Next_Station = mstp_port->This_Station;
|
||||
mstp_port->RetryCount = 0;
|
||||
@@ -1067,17 +1082,17 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* a successor node. */
|
||||
if (mstp_port->ReceivedValidFrame == true) {
|
||||
if ((mstp_port->DestinationAddress ==
|
||||
mstp_port->This_Station) &&
|
||||
mstp_port->This_Station) &&
|
||||
(mstp_port->FrameType ==
|
||||
FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER)) {
|
||||
FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER)) {
|
||||
/* ReceivedReplyToPFM */
|
||||
mstp_port->SoleMaster = false;
|
||||
mstp_port->Next_Station = mstp_port->SourceAddress;
|
||||
mstp_port->EventCount = 0;
|
||||
/* Transmit a Token frame to NS */
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_TOKEN, mstp_port->Next_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
mstp_port->Poll_Station = mstp_port->This_Station;
|
||||
mstp_port->TokenCount = 0;
|
||||
mstp_port->RetryCount = 0;
|
||||
@@ -1092,8 +1107,9 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
transition_now = true;
|
||||
}
|
||||
mstp_port->ReceivedValidFrame = false;
|
||||
} else if ((mstp_port->SilenceTimer((void *)mstp_port) >
|
||||
mstp_port->Tusage_timeout) ||
|
||||
} else if (
|
||||
(mstp_port->SilenceTimer((void *)mstp_port) >
|
||||
mstp_port->Tusage_timeout) ||
|
||||
(mstp_port->ReceivedInvalidFrame == true)) {
|
||||
if (mstp_port->SoleMaster == true) {
|
||||
/* SoleMaster */
|
||||
@@ -1110,7 +1126,8 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* poll for a master at address PS. */
|
||||
mstp_port->EventCount = 0;
|
||||
/* transmit a Token frame to NS */
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN,
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station, mstp_port->This_Station,
|
||||
NULL, 0);
|
||||
mstp_port->RetryCount = 0;
|
||||
@@ -1120,8 +1137,8 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* SendNextPFM */
|
||||
mstp_port->Poll_Station = next_poll_station;
|
||||
/* Transmit a Poll For Master frame to PS. */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_POLL_FOR_MASTER,
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_POLL_FOR_MASTER,
|
||||
mstp_port->Poll_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
mstp_port->RetryCount = 0;
|
||||
@@ -1158,12 +1175,13 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* then call MSTP_Create_And_Send_Frame to transmit the reply
|
||||
* frame */
|
||||
/* and enter the IDLE state to wait for the next frame. */
|
||||
MSTP_Send_Frame(mstp_port,
|
||||
&mstp_port->OutputBuffer[0], (uint16_t)length);
|
||||
MSTP_Send_Frame(
|
||||
mstp_port, &mstp_port->OutputBuffer[0], (uint16_t)length);
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
|
||||
/* clear our flag we were holding for comparison */
|
||||
mstp_port->ReceivedValidFrame = false;
|
||||
} else if (mstp_port->SilenceTimer((void *)mstp_port) >
|
||||
} else if (
|
||||
mstp_port->SilenceTimer((void *)mstp_port) >
|
||||
mstp_port->Treply_delay) {
|
||||
/* DeferredReply */
|
||||
/* If no reply will be available from the higher layers */
|
||||
@@ -1175,9 +1193,9 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* Call MSTP_Create_And_Send_Frame to transmit a Reply Postponed
|
||||
* frame, */
|
||||
/* and enter the IDLE state. */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_REPLY_POSTPONED, mstp_port->SourceAddress,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_REPLY_POSTPONED,
|
||||
mstp_port->SourceAddress, mstp_port->This_Station, NULL, 0);
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
|
||||
/* clear our flag we were holding for comparison */
|
||||
mstp_port->ReceivedValidFrame = false;
|
||||
@@ -1226,7 +1244,8 @@ void MSTP_Slave_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
}
|
||||
break;
|
||||
case FRAME_TYPE_TEST_REQUEST:
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TEST_RESPONSE,
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_TEST_RESPONSE,
|
||||
mstp_port->SourceAddress, mstp_port->This_Station,
|
||||
&mstp_port->InputBuffer[0], mstp_port->DataLength);
|
||||
break;
|
||||
@@ -1249,16 +1268,17 @@ void MSTP_Slave_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
/* within Treply_delay after the reception of the */
|
||||
/* final octet of the requesting frame */
|
||||
/* (the mechanism used to determine this is a local
|
||||
* matter), */
|
||||
* matter), */
|
||||
/* then call MSTP_Create_And_Send_Frame to transmit the
|
||||
* reply frame */
|
||||
* reply frame */
|
||||
/* and enter the IDLE state to wait for the next frame.
|
||||
*/
|
||||
MSTP_Send_Frame(mstp_port,
|
||||
&mstp_port->OutputBuffer[0], (uint16_t)length);
|
||||
*/
|
||||
MSTP_Send_Frame(
|
||||
mstp_port, &mstp_port->OutputBuffer[0], (uint16_t)length);
|
||||
/* clear our flag we were holding for comparison */
|
||||
mstp_port->ReceivedValidFrame = false;
|
||||
} else if (mstp_port->SilenceTimer((void *)mstp_port) >
|
||||
} else if (
|
||||
mstp_port->SilenceTimer((void *)mstp_port) >
|
||||
mstp_port->Treply_delay) {
|
||||
/* If no reply will be available from the higher layers
|
||||
within Treply_delay after the reception of the final
|
||||
@@ -1398,7 +1418,8 @@ static void MSTP_Zero_Config_State_Idle(struct mstp_port_struct_t *mstp_port)
|
||||
/* configure max master at maximum */
|
||||
/* confirm this station with a quick test */
|
||||
mstp_port->Zero_Config_Max_Master = DEFAULT_MAX_MASTER;
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TEST_REQUEST,
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_TEST_REQUEST,
|
||||
mstp_port->Zero_Config_Station, mstp_port->Zero_Config_Station,
|
||||
mstp_port->UUID, sizeof(mstp_port->UUID));
|
||||
mstp_port->Zero_Config_State = MSTP_ZERO_CONFIG_STATE_CONFIRM;
|
||||
@@ -1434,18 +1455,18 @@ static void MSTP_Zero_Config_State_Lurk(struct mstp_port_struct_t *mstp_port)
|
||||
if (src == mstp_port->Zero_Config_Station) {
|
||||
/* AddressInUse */
|
||||
/* monitor PFM from the next address */
|
||||
mstp_port->Zero_Config_Station =
|
||||
MSTP_Zero_Config_Station_Increment(
|
||||
mstp_port->Zero_Config_Station);
|
||||
mstp_port->Zero_Config_Station = MSTP_Zero_Config_Station_Increment(
|
||||
mstp_port->Zero_Config_Station);
|
||||
mstp_port->Poll_Count = 0;
|
||||
} else if ((frame == FRAME_TYPE_POLL_FOR_MASTER) &&
|
||||
} else if (
|
||||
(frame == FRAME_TYPE_POLL_FOR_MASTER) &&
|
||||
(dst == mstp_port->Zero_Config_Station)) {
|
||||
/* calculate this node poll count priority number */
|
||||
count = Nmin_poll + mstp_port->Npoll_slot;
|
||||
if (mstp_port->Poll_Count == count) {
|
||||
/* PollResponse */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER, src,
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER, src,
|
||||
mstp_port->Zero_Config_Station, NULL, 0);
|
||||
mstp_port->Zero_Config_State = MSTP_ZERO_CONFIG_STATE_CLAIM;
|
||||
} else {
|
||||
@@ -1487,16 +1508,16 @@ static void MSTP_Zero_Config_State_Claim(struct mstp_port_struct_t *mstp_port)
|
||||
if (src == mstp_port->Zero_Config_Station) {
|
||||
/* ClaimAddressInUse */
|
||||
/* monitor PFM from the next address */
|
||||
mstp_port->Zero_Config_Station =
|
||||
MSTP_Zero_Config_Station_Increment(
|
||||
mstp_port->Zero_Config_Station);
|
||||
mstp_port->Zero_Config_Station = MSTP_Zero_Config_Station_Increment(
|
||||
mstp_port->Zero_Config_Station);
|
||||
mstp_port->Poll_Count = 0;
|
||||
mstp_port->Zero_Config_State = MSTP_ZERO_CONFIG_STATE_LURK;
|
||||
} else if (frame == FRAME_TYPE_TOKEN) {
|
||||
if (dst == mstp_port->Zero_Config_Station) {
|
||||
/* ClaimTokenForUs */
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TEST_REQUEST,
|
||||
src, mstp_port->Zero_Config_Station, mstp_port->UUID,
|
||||
MSTP_Create_And_Send_Frame(
|
||||
mstp_port, FRAME_TYPE_TEST_REQUEST, src,
|
||||
mstp_port->Zero_Config_Station, mstp_port->UUID,
|
||||
MSTP_UUID_SIZE);
|
||||
mstp_port->Zero_Config_State = MSTP_ZERO_CONFIG_STATE_CONFIRM;
|
||||
}
|
||||
@@ -1541,8 +1562,9 @@ static void MSTP_Zero_Config_State_Confirm(struct mstp_port_struct_t *mstp_port)
|
||||
match = false;
|
||||
}
|
||||
if (match &&
|
||||
(memcmp(mstp_port->InputBuffer, mstp_port->UUID,
|
||||
MSTP_UUID_SIZE) != 0)) {
|
||||
(memcmp(
|
||||
mstp_port->InputBuffer, mstp_port->UUID, MSTP_UUID_SIZE) !=
|
||||
0)) {
|
||||
match = false;
|
||||
}
|
||||
if (match) {
|
||||
@@ -1556,15 +1578,15 @@ static void MSTP_Zero_Config_State_Confirm(struct mstp_port_struct_t *mstp_port)
|
||||
} else if (src == mstp_port->Zero_Config_Station) {
|
||||
/* ConfirmationAddressInUse */
|
||||
/* monitor PFM from the next address */
|
||||
mstp_port->Zero_Config_Station =
|
||||
MSTP_Zero_Config_Station_Increment(
|
||||
mstp_port->Zero_Config_Station);
|
||||
mstp_port->Zero_Config_Station = MSTP_Zero_Config_Station_Increment(
|
||||
mstp_port->Zero_Config_Station);
|
||||
mstp_port->Zero_Config_State = MSTP_ZERO_CONFIG_STATE_LURK;
|
||||
}
|
||||
} else if (mstp_port->ReceivedInvalidFrame) {
|
||||
/* ConfirmationInvalidFrame */
|
||||
mstp_port->ReceivedInvalidFrame = false;
|
||||
} else if (mstp_port->SilenceTimer((void *)mstp_port) >=
|
||||
} else if (
|
||||
mstp_port->SilenceTimer((void *)mstp_port) >=
|
||||
mstp_port->Treply_timeout) {
|
||||
/* ConfirmationTimeout */
|
||||
/* In case validating device doesn't support Test Request */
|
||||
|
||||
+17
-15
@@ -47,9 +47,9 @@ struct mstp_port_struct_t {
|
||||
/* A Boolean flag set to TRUE by the master machine if this node is the
|
||||
only known master node. */
|
||||
unsigned SoleMaster : 1;
|
||||
/* A Boolean flag set to TRUE if this node is a slave node */
|
||||
/* A Boolean flag set to TRUE if this node is a slave node */
|
||||
unsigned SlaveNodeEnabled : 1;
|
||||
/* A Boolean flag set to TRUE if this node is using a ZeroConfig address */
|
||||
/* A Boolean flag set to TRUE if this node is using a ZeroConfig address */
|
||||
unsigned ZeroConfigEnabled : 1;
|
||||
/* stores the latest received data */
|
||||
uint8_t DataRegister;
|
||||
@@ -204,11 +204,11 @@ struct mstp_port_struct_t {
|
||||
not to exceed 35 milliseconds.) */
|
||||
uint8_t Tusage_timeout;
|
||||
|
||||
/* The minimum time after the end of the stop bit of the final
|
||||
octet of a received frame before a node may enable its
|
||||
EIA-485 driver: 40 bit times.
|
||||
40 bits is 4 octets including a start and stop bit with each octet.
|
||||
turnaround_time_milliseconds = (Tturnaround*1000UL)/RS485_Baud; */
|
||||
/* The minimum time after the end of the stop bit of the final
|
||||
octet of a received frame before a node may enable its
|
||||
EIA-485 driver: 40 bit times.
|
||||
40 bits is 4 octets including a start and stop bit with each octet.
|
||||
turnaround_time_milliseconds = (Tturnaround*1000UL)/RS485_Baud; */
|
||||
uint8_t Tturnaround_timeout;
|
||||
|
||||
/*Platform-specific port data */
|
||||
@@ -233,7 +233,8 @@ BACNET_STACK_EXPORT
|
||||
bool MSTP_Line_Active(const struct mstp_port_struct_t *mstp_port);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t MSTP_Create_Frame(uint8_t *buffer,
|
||||
uint16_t MSTP_Create_Frame(
|
||||
uint8_t *buffer,
|
||||
uint16_t buffer_len,
|
||||
uint8_t frame_type,
|
||||
uint8_t destination,
|
||||
@@ -266,26 +267,27 @@ void MSTP_Zero_Config_FSM(struct mstp_port_struct_t *mstp_port);
|
||||
/* FIXME: developer must implement these in their DLMSTP module */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t MSTP_Put_Receive(
|
||||
struct mstp_port_struct_t *mstp_port);
|
||||
uint16_t MSTP_Put_Receive(struct mstp_port_struct_t *mstp_port);
|
||||
|
||||
/* for the MS/TP state machine to use for getting data to send */
|
||||
/* Return: amount of PDU data */
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t MSTP_Get_Send(struct mstp_port_struct_t *mstp_port,
|
||||
uint16_t MSTP_Get_Send(
|
||||
struct mstp_port_struct_t *mstp_port,
|
||||
unsigned timeout); /* milliseconds to wait for a packet */
|
||||
/* for the MS/TP state machine to use for getting the reply for
|
||||
Data-Expecting-Reply Frame */
|
||||
/* Return: amount of PDU data */
|
||||
BACNET_STACK_EXPORT
|
||||
uint16_t MSTP_Get_Reply(struct mstp_port_struct_t *mstp_port,
|
||||
uint16_t MSTP_Get_Reply(
|
||||
struct mstp_port_struct_t *mstp_port,
|
||||
unsigned timeout); /* milliseconds to wait for a packet */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void MSTP_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port,
|
||||
const uint8_t * buffer,
|
||||
uint16_t nbytes);
|
||||
struct mstp_port_struct_t *mstp_port,
|
||||
const uint8_t *buffer,
|
||||
uint16_t nbytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -15,19 +15,21 @@
|
||||
|
||||
/** @file mstptext.c Text mapping functions for BACnet MS/TP */
|
||||
|
||||
static INDTEXT_DATA mstp_receive_state_text[] = { { MSTP_RECEIVE_STATE_IDLE,
|
||||
"IDLE" },
|
||||
static INDTEXT_DATA mstp_receive_state_text[] = {
|
||||
{ MSTP_RECEIVE_STATE_IDLE, "IDLE" },
|
||||
{ MSTP_RECEIVE_STATE_PREAMBLE, "PREAMBLE" },
|
||||
{ MSTP_RECEIVE_STATE_HEADER, "HEADER" },
|
||||
{ MSTP_RECEIVE_STATE_DATA, "DATA" }, { 0, NULL } };
|
||||
{ MSTP_RECEIVE_STATE_DATA, "DATA" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const char *mstptext_receive_state(unsigned index)
|
||||
{
|
||||
return indtext_by_index_default(mstp_receive_state_text, index, "unknown");
|
||||
}
|
||||
|
||||
static INDTEXT_DATA mstp_master_state_text[] = { { MSTP_MASTER_STATE_INITIALIZE,
|
||||
"INITIALIZE" },
|
||||
static INDTEXT_DATA mstp_master_state_text[] = {
|
||||
{ MSTP_MASTER_STATE_INITIALIZE, "INITIALIZE" },
|
||||
{ MSTP_MASTER_STATE_IDLE, "IDLE" },
|
||||
{ MSTP_MASTER_STATE_USE_TOKEN, "USE_TOKEN" },
|
||||
{ MSTP_MASTER_STATE_WAIT_FOR_REPLY, "WAIT_FOR_REPLY" },
|
||||
@@ -36,32 +38,37 @@ static INDTEXT_DATA mstp_master_state_text[] = { { MSTP_MASTER_STATE_INITIALIZE,
|
||||
{ MSTP_MASTER_STATE_NO_TOKEN, "NO_TOKEN" },
|
||||
{ MSTP_MASTER_STATE_POLL_FOR_MASTER, "POLL_FOR_MASTER" },
|
||||
{ MSTP_MASTER_STATE_ANSWER_DATA_REQUEST, "ANSWER_DATA_REQUEST" },
|
||||
{ 0, NULL } };
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const char *mstptext_master_state(unsigned index)
|
||||
{
|
||||
return indtext_by_index_default(mstp_master_state_text, index, "unknown");
|
||||
}
|
||||
|
||||
static INDTEXT_DATA mstp_frame_type_text[] = { { FRAME_TYPE_TOKEN, "TOKEN" },
|
||||
static INDTEXT_DATA mstp_frame_type_text[] = {
|
||||
{ FRAME_TYPE_TOKEN, "TOKEN" },
|
||||
{ FRAME_TYPE_POLL_FOR_MASTER, "POLL_FOR_MASTER" },
|
||||
{ FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER, "REPLY_TO_POLL_FOR_MASTER" },
|
||||
{ FRAME_TYPE_TEST_REQUEST, "TEST_REQUEST" },
|
||||
{ FRAME_TYPE_TEST_RESPONSE, "TEST_RESPONSE" },
|
||||
{ FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY, "BACNET_DATA_EXPECTING_REPLY" },
|
||||
{ FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY,
|
||||
"BACNET_DATA_NOT_EXPECTING_REPLY" },
|
||||
"BACNET_DATA_NOT_EXPECTING_REPLY" },
|
||||
{ FRAME_TYPE_REPLY_POSTPONED, "REPLY_POSTPONED" },
|
||||
{ FRAME_TYPE_BACNET_EXTENDED_DATA_EXPECTING_REPLY,
|
||||
"BACNET_EXTENDED_DATA_EXPECTING_REPLY" },
|
||||
"BACNET_EXTENDED_DATA_EXPECTING_REPLY" },
|
||||
{ FRAME_TYPE_BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY,
|
||||
"BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY" },
|
||||
{ FRAME_TYPE_IPV6_ENCAPSULATION, "IPV6_ENCAPSULATION" }, { 0, NULL } };
|
||||
"BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY" },
|
||||
{ FRAME_TYPE_IPV6_ENCAPSULATION, "IPV6_ENCAPSULATION" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const char *mstptext_frame_type(unsigned index)
|
||||
{
|
||||
return indtext_by_index_split_default(mstp_frame_type_text, index,
|
||||
FRAME_TYPE_PROPRIETARY_MIN, "UNKNOWN", "PROPRIETARY");
|
||||
return indtext_by_index_split_default(
|
||||
mstp_frame_type_text, index, FRAME_TYPE_PROPRIETARY_MIN, "UNKNOWN",
|
||||
"PROPRIETARY");
|
||||
}
|
||||
|
||||
static INDTEXT_DATA mstp_zero_config_state_text[] = {
|
||||
@@ -72,9 +79,10 @@ static INDTEXT_DATA mstp_zero_config_state_text[] = {
|
||||
{ MSTP_ZERO_CONFIG_STATE_CONFIRM, "CONFIRM" },
|
||||
{ MSTP_ZERO_CONFIG_STATE_USE, "USE" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
};
|
||||
|
||||
const char *mstptext_zero_config_state(unsigned index)
|
||||
{
|
||||
return indtext_by_index_default(mstp_zero_config_state_text, index, "unknown");
|
||||
return indtext_by_index_default(
|
||||
mstp_zero_config_state_text, index, "unknown");
|
||||
}
|
||||
|
||||
@@ -16,18 +16,14 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
const char *mstptext_receive_state(
|
||||
unsigned index);
|
||||
BACNET_STACK_EXPORT
|
||||
const char *mstptext_master_state(
|
||||
unsigned index);
|
||||
BACNET_STACK_EXPORT
|
||||
const char *mstptext_frame_type(
|
||||
unsigned index);
|
||||
BACNET_STACK_EXPORT
|
||||
const char *mstptext_zero_config_state(
|
||||
unsigned index);
|
||||
BACNET_STACK_EXPORT
|
||||
const char *mstptext_receive_state(unsigned index);
|
||||
BACNET_STACK_EXPORT
|
||||
const char *mstptext_master_state(unsigned index);
|
||||
BACNET_STACK_EXPORT
|
||||
const char *mstptext_frame_type(unsigned index);
|
||||
BACNET_STACK_EXPORT
|
||||
const char *mstptext_zero_config_state(unsigned index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user