Export symbols in order to support shared libraries (#54)

* Add BAC_ROUTING compile definition

* Reorder cmake

* Fix OpenSSL support: support both 1.0 and 1.1t pus

* Explicitly export symbols, hidden by default

* Build shared libraries on travis using cmake

* Learn Makefile about static library

* Fix build using mingw with cmake

* Do not cleanup twice or after potential free
This commit is contained in:
Anonymous Maarten
2020-03-06 22:42:03 +01:00
committed by GitHub
parent bb5fafc06a
commit 4a916468c6
174 changed files with 2200 additions and 91 deletions
+8
View File
@@ -27,6 +27,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#include "bacnet/npdu.h"
@@ -38,15 +39,19 @@
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);
/* 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 */
@@ -55,14 +60,17 @@ extern "C" {
/* 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
void arcnet_get_my_address(
BACNET_ADDRESS * my_address);
BACNET_STACK_EXPORT
void arcnet_get_broadcast_address(
BACNET_ADDRESS * dest); /* destination address */
+32
View File
@@ -39,6 +39,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#include "bacnet/bacenum.h"
@@ -193,93 +194,124 @@ 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);
/* 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);
/* 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);
/* 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,
BACNET_CHALLENGE_REQUEST * bc_req);
BACNET_STACK_EXPORT
int encode_security_payload(uint8_t * apdu,
BACNET_SECURITY_PAYLOAD * payload);
BACNET_STACK_EXPORT
int encode_security_response(uint8_t * apdu,
BACNET_SECURITY_RESPONSE * resp);
BACNET_STACK_EXPORT
int encode_request_key_update(uint8_t * apdu,
BACNET_REQUEST_KEY_UPDATE * req);
BACNET_STACK_EXPORT
int encode_key_entry(uint8_t * apdu,
BACNET_KEY_ENTRY * entry);
BACNET_STACK_EXPORT
int encode_update_key_set(uint8_t * apdu,
BACNET_UPDATE_KEY_SET * key_set);
BACNET_STACK_EXPORT
int encode_update_distribution_key(uint8_t * apdu,
BACNET_UPDATE_DISTRIBUTION_KEY * dist_key);
BACNET_STACK_EXPORT
int encode_request_master_key(uint8_t * apdu,
BACNET_REQUEST_MASTER_KEY * req_master_key);
BACNET_STACK_EXPORT
int encode_set_master_key(uint8_t * apdu,
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(uint8_t * apdu,
uint32_t apdu_len_remaining,
BACNET_CHALLENGE_REQUEST * bc_req);
BACNET_STACK_EXPORT
int decode_security_payload_safe(uint8_t * apdu,
uint32_t apdu_len_remaining,
BACNET_SECURITY_PAYLOAD * payload);
BACNET_STACK_EXPORT
int decode_security_response_safe(uint8_t * apdu,
uint32_t apdu_len_remaining,
BACNET_SECURITY_RESPONSE * resp);
BACNET_STACK_EXPORT
int decode_request_key_update_safe(uint8_t * apdu,
uint32_t apdu_len_remaining,
BACNET_REQUEST_KEY_UPDATE * req);
BACNET_STACK_EXPORT
int decode_key_entry_safe(uint8_t * apdu,
uint32_t apdu_len_remaining,
BACNET_KEY_ENTRY * entry);
BACNET_STACK_EXPORT
int decode_update_key_set_safe(uint8_t * apdu,
uint32_t apdu_len_remaining,
BACNET_UPDATE_KEY_SET * key_set);
BACNET_STACK_EXPORT
int decode_update_distribution_key_safe(uint8_t * apdu,
uint32_t apdu_len_remaining,
BACNET_UPDATE_DISTRIBUTION_KEY * dist_key);
BACNET_STACK_EXPORT
int decode_request_master_key_safe(uint8_t * apdu,
uint32_t apdu_len_remaining,
BACNET_REQUEST_MASTER_KEY * req_master_key);
BACNET_STACK_EXPORT
int decode_set_master_key_safe(uint8_t * apdu,
uint32_t apdu_len_remaining,
BACNET_SET_MASTER_KEY * set_master_key);
+19
View File
@@ -27,6 +27,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#include "bacnet/npdu.h"
#include "bacport.h"
@@ -46,27 +47,36 @@ extern "C" {
/* 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(
char *ifname);
BACNET_STACK_EXPORT
void bip_cleanup(
void);
/* common BACnet/IP functions */
BACNET_STACK_EXPORT
void bip_set_socket(
int sock_fd);
BACNET_STACK_EXPORT
int bip_socket(
void);
BACNET_STACK_EXPORT
bool bip_valid(
void);
BACNET_STACK_EXPORT
void bip_get_broadcast_address(
BACNET_ADDRESS * dest); /* destination address */
BACNET_STACK_EXPORT
void bip_get_my_address(
BACNET_ADDRESS * my_address);
/* function to send a packet out the BACnet/IP socket */
/* returns zero on success, non-zero on failure */
BACNET_STACK_EXPORT
int bip_send_pdu(
BACNET_ADDRESS * dest, /* destination address */
BACNET_NPDU_DATA * npdu_data, /* network information */
@@ -75,6 +85,7 @@ extern "C" {
/* receives a BACnet/IP packet */
/* returns the number of octets in the PDU, or zero on failure */
BACNET_STACK_EXPORT
uint16_t bip_receive(
BACNET_ADDRESS * src, /* source address */
uint8_t * pdu, /* PDU data */
@@ -82,24 +93,31 @@ extern "C" {
unsigned timeout); /* milliseconds to wait for a packet */
/* use network byte order for setting */
BACNET_STACK_EXPORT
void bip_set_port(
uint16_t port);
BACNET_STACK_EXPORT
bool bip_port_changed(void);
/* returns network byte order */
BACNET_STACK_EXPORT
uint16_t bip_get_port(
void);
/* use network byte order for setting */
BACNET_STACK_EXPORT
void bip_set_addr(
uint32_t net_address);
/* returns network byte order */
BACNET_STACK_EXPORT
uint32_t bip_get_addr(
void);
/* use network byte order for setting */
BACNET_STACK_EXPORT
void bip_set_broadcast_addr(
uint32_t net_address);
/* returns network byte order */
BACNET_STACK_EXPORT
uint32_t bip_get_broadcast_addr(
void);
@@ -108,6 +126,7 @@ extern "C" {
a name that is a domain name
returns 0 if not found, or
an IP address in network byte order */
BACNET_STACK_EXPORT
long bip_getaddrbyname(
const char *host_name);
+16
View File
@@ -16,6 +16,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#include "bacnet/npdu.h"
#include "bacnet/datalink/bvlc6.h"
@@ -33,19 +34,25 @@ extern "C" {
/* 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,
@@ -53,28 +60,37 @@ extern "C" {
unsigned timeout);
/* functions that are custom per port */
BACNET_STACK_EXPORT
void bip6_set_interface(
char *ifname);
BACNET_STACK_EXPORT
bool bip6_address_match_self(
BACNET_IP6_ADDRESS *addr);
BACNET_STACK_EXPORT
bool bip6_set_addr(
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
bool bip6_set_broadcast_addr(
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(
BACNET_IP6_ADDRESS *addr,
uint8_t * mtu,
+23
View File
@@ -28,6 +28,7 @@
#include <stdint.h>
#include <stddef.h>
#include <time.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#include "bacnet/npdu.h"
#include "bacnet/datalink/bip.h"
@@ -40,6 +41,7 @@ extern "C" {
#endif /* __cplusplus */
#if defined(BBMD_ENABLED) && BBMD_ENABLED
BACNET_STACK_EXPORT
void bvlc_maintenance_timer(
time_t seconds);
#else
@@ -57,55 +59,67 @@ extern "C" {
struct in_addr broadcast_mask; /* in tework format */
} BBMD_TABLE_ENTRY;
BACNET_STACK_EXPORT
uint16_t bvlc_receive(
BACNET_ADDRESS * src, /* returns the source address */
uint8_t * npdu, /* returns the NPDU */
uint16_t max_npdu, /* amount of space available in the NPDU */
unsigned timeout); /* number of milliseconds to wait for a packet */
BACNET_STACK_EXPORT
int bvlc_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);
BACNET_STACK_EXPORT
int bvlc_send_mpdu(
struct sockaddr_in *dest,
uint8_t * mtu,
uint16_t mtu_len);
#if defined(BBMD_CLIENT_ENABLED) && BBMD_CLIENT_ENABLED
BACNET_STACK_EXPORT
int bvlc_encode_write_bdt_init(
uint8_t * pdu,
unsigned entries);
BACNET_STACK_EXPORT
int bvlc_encode_read_fdt(
uint8_t * pdu);
BACNET_STACK_EXPORT
int bvlc_encode_delete_fdt_entry(
uint8_t * pdu,
uint32_t address, /* in network byte order */
uint16_t port); /* in network byte order */
BACNET_STACK_EXPORT
int bvlc_encode_original_unicast_npdu(
uint8_t * pdu,
uint8_t * npdu,
unsigned npdu_length);
BACNET_STACK_EXPORT
int bvlc_encode_original_broadcast_npdu(
uint8_t * pdu,
uint8_t * npdu,
unsigned npdu_length);
#endif
BACNET_STACK_EXPORT
int bvlc_encode_read_bdt(
uint8_t * pdu);
BACNET_STACK_EXPORT
int bvlc_bbmd_read_bdt(
uint32_t bbmd_address,
uint16_t bbmd_port);
/* registers with a bbmd as a foreign device */
BACNET_STACK_EXPORT
int bvlc_register_with_bbmd(
uint32_t bbmd_address, /* in network byte order */
uint16_t bbmd_port, /* in network byte order */
uint16_t time_to_live_seconds);
/* Note any BVLC_RESULT code, or NAK the BVLL message in the unsupported cases. */
BACNET_STACK_EXPORT
int bvlc_for_non_bbmd(
struct sockaddr_in *sout,
uint8_t * npdu,
@@ -114,6 +128,7 @@ extern "C" {
/* Returns the last BVLL Result we received, either as the result of a BBMD
* request we sent, or (if not a BBMD or Client), from trying to register
* as a foreign device. */
BACNET_STACK_EXPORT
BACNET_BVLC_RESULT bvlc_get_last_result(
void);
@@ -121,6 +136,7 @@ extern "C" {
* We have to store this higher layer code for when the lower layers
* need to know what it is, especially to differentiate between
* BVLC_ORIGINAL_UNICAST_NPDU and BVLC_ORIGINAL_BROADCAST_NPDU. */
BACNET_STACK_EXPORT
BACNET_BVLC_FUNCTION bvlc_get_function_code(
void);
@@ -132,26 +148,31 @@ extern "C" {
/* Get handle to broadcast distribution table. Returns the number of
* valid entries in the table. */
BACNET_STACK_EXPORT
int bvlc_get_bdt_local(
const BBMD_TABLE_ENTRY** table);
/* Invalidate all entries in the broadcast distribution table */
BACNET_STACK_EXPORT
void bvlc_clear_bdt_local(void);
/* Add new entry to broadcast distribution table. Returns true if the new
* entry was added successfully */
BACNET_STACK_EXPORT
bool bvlc_add_bdt_entry_local(
BBMD_TABLE_ENTRY* entry);
/* Backup broadcast distribution table to a file.
* Filename is the BBMD_BACKUP_FILE constant
*/
BACNET_STACK_EXPORT
void bvlc_bdt_backup_local(
void);
/* Restore broadcast distribution from a file.
* Filename is the BBMD_BACKUP_FILE constant
*/
BACNET_STACK_EXPORT
void bvlc_bdt_restore_local(
void);
@@ -170,10 +191,12 @@ extern "C" {
/* Set global IP address of a NAT enabled router which is used in forwarded
* messages. Enables NAT handling.
*/
BACNET_STACK_EXPORT
void bvlc_set_global_address_for_nat(const struct in_addr* addr);
/* Disable NAT handling of BBMD.
*/
BACNET_STACK_EXPORT
void bvlc_disable_nat(void);
#ifdef __cplusplus
+39
View File
@@ -13,6 +13,7 @@
#include <stdint.h>
#include <stddef.h>
#include <time.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#include "bacnet/npdu.h"
@@ -161,24 +162,30 @@ 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,
BACNET_IP6_ADDRESS * ip6_address);
BACNET_STACK_EXPORT
int bvlc6_decode_address(
uint8_t * pdu,
uint16_t pdu_len,
BACNET_IP6_ADDRESS * ip6_address);
BACNET_STACK_EXPORT
bool bvlc6_address_copy(
BACNET_IP6_ADDRESS * dst,
BACNET_IP6_ADDRESS * src);
BACNET_STACK_EXPORT
bool bvlc6_address_different(
BACNET_IP6_ADDRESS * dst,
BACNET_IP6_ADDRESS * src);
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,
@@ -189,6 +196,7 @@ extern "C" {
uint16_t addr5,
uint16_t addr6,
uint16_t addr7);
BACNET_STACK_EXPORT
bool bvlc6_address_get(
BACNET_IP6_ADDRESS * addr,
uint16_t *addr0,
@@ -200,35 +208,42 @@ extern "C" {
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(
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(
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(
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,
@@ -236,6 +251,7 @@ extern "C" {
uint32_t vmac_dst,
uint8_t * npdu,
uint16_t npdu_len);
BACNET_STACK_EXPORT
int bvlc6_decode_original_unicast(
uint8_t * pdu,
uint16_t pdu_len,
@@ -245,12 +261,14 @@ extern "C" {
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,
uint8_t * npdu,
uint16_t npdu_len);
BACNET_STACK_EXPORT
int bvlc6_decode_original_broadcast(
uint8_t * pdu,
uint16_t pdu_len,
@@ -259,23 +277,27 @@ extern "C" {
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(
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,
BACNET_IP6_ADDRESS * bip6_address);
BACNET_STACK_EXPORT
int bvlc6_decode_forwarded_address_resolution(
uint8_t * pdu,
uint16_t pdu_len,
@@ -283,37 +305,44 @@ extern "C" {
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(
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(
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(
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,
@@ -321,6 +350,7 @@ extern "C" {
BACNET_IP6_ADDRESS * address,
uint8_t * npdu,
uint16_t npdu_len);
BACNET_STACK_EXPORT
int bvlc6_decode_forwarded_npdu(
uint8_t * pdu,
uint16_t pdu_len,
@@ -330,33 +360,39 @@ extern "C" {
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(
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,
BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY * fdt_entry);
BACNET_STACK_EXPORT
int bvlc6_decode_delete_foreign_device(
uint8_t * pdu,
uint16_t pdu_len,
uint32_t * vmac_src,
BACNET_IP6_FOREIGN_DEVICE_TABLE_ENTRY * fdt_entry);
BACNET_STACK_EXPORT
int bvlc6_encode_secure_bvll(
uint8_t * pdu,
uint16_t pdu_size,
uint8_t * sbuf,
uint16_t sbuf_len);
BACNET_STACK_EXPORT
int bvlc6_decode_secure_bvll(
uint8_t * pdu,
uint16_t pdu_len,
@@ -364,12 +400,14 @@ extern "C" {
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,
uint8_t * npdu,
uint16_t npdu_len);
BACNET_STACK_EXPORT
int bvlc6_decode_distribute_broadcast_to_network(
uint8_t * pdu,
uint16_t pdu_len,
@@ -380,6 +418,7 @@ extern "C" {
#ifdef TEST
#include "ctest.h"
BACNET_STACK_EXPORT
void test_BVLC6(
Test * pTest);
#endif
+3
View File
@@ -26,14 +26,17 @@
#include <stddef.h>
#include <stdint.h>
#include "bacnet/bacnet_stack_exports.h"
#ifdef __cplusplus
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);
+16 -7
View File
@@ -24,6 +24,7 @@
#ifndef DATALINK_H
#define DATALINK_H
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/config.h"
#include "bacnet/bacdef.h"
@@ -72,7 +73,8 @@
#define datalink_cleanup bip_cleanup
#define datalink_get_broadcast_address bip_get_broadcast_address
#ifdef BAC_ROUTING
extern void routed_get_my_address(
BACNET_STACK_EXPORT
void routed_get_my_address(
BACNET_ADDRESS * my_address);
#define datalink_get_my_address routed_get_my_address
#else
@@ -99,25 +101,32 @@ extern void routed_get_my_address(
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
int datalink_send_pdu(
BACNET_ADDRESS * dest,
BACNET_NPDU_DATA * npdu_data,
uint8_t * pdu,
unsigned pdu_len);
extern uint16_t datalink_receive(
BACNET_STACK_EXPORT
uint16_t datalink_receive(
BACNET_ADDRESS * src,
uint8_t * pdu,
uint16_t max_pdu,
unsigned timeout);
extern void datalink_cleanup(
BACNET_STACK_EXPORT
void datalink_cleanup(
void);
extern void datalink_get_broadcast_address(
BACNET_STACK_EXPORT
void datalink_get_broadcast_address(
BACNET_ADDRESS * dest);
extern void datalink_get_my_address(
BACNET_STACK_EXPORT
void datalink_get_my_address(
BACNET_ADDRESS * my_address);
extern void datalink_set_interface(
BACNET_STACK_EXPORT
void datalink_set_interface(
char *ifname);
extern void datalink_set(
BACNET_STACK_EXPORT
void datalink_set(
char *datalink_string);
#ifdef __cplusplus
+9
View File
@@ -25,24 +25,33 @@
#ifndef DLENV_H
#define DLENV_H
#include "bacnet/bacnet_stack_exports.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
void dlenv_init(
void);
BACNET_STACK_EXPORT
int dlenv_register_as_foreign_device(
void);
BACNET_STACK_EXPORT
void dlenv_maintenance_timer(
uint16_t elapsed_seconds);
/* Simple setters and getter. */
BACNET_STACK_EXPORT
void dlenv_bbmd_address_set(
long address);
BACNET_STACK_EXPORT
void dlenv_bbmd_port_set(
int port);
BACNET_STACK_EXPORT
void dlenv_bbmd_ttl_set(
int ttl_secs);
BACNET_STACK_EXPORT
int dlenv_bbmd_result(
void);
+20
View File
@@ -27,6 +27,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#include "bacnet/npdu.h"
@@ -47,14 +48,18 @@ typedef struct dlmstp_packet {
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);
/* 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 */
@@ -62,6 +67,7 @@ extern "C" {
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 */
@@ -75,8 +81,10 @@ extern "C" {
/* 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);
@@ -85,35 +93,47 @@ extern "C" {
/* 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);
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);
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);
#ifdef __cplusplus
+11
View File
@@ -27,6 +27,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#include "bacnet/npdu.h"
@@ -38,15 +39,19 @@
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);
/* 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 */
@@ -55,23 +60,29 @@ extern "C" {
/* 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
void ethernet_set_my_address(
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,
BACNET_ADDRESS * dest);
BACNET_STACK_EXPORT
int ethernet_send(
uint8_t * mtu,
int mtu_len);
+12
View File
@@ -28,6 +28,7 @@
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/datalink/mstpdef.h"
struct mstp_port_struct_t {
@@ -173,21 +174,27 @@ struct mstp_port_struct_t {
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
void MSTP_Init(
volatile struct mstp_port_struct_t *mstp_port);
BACNET_STACK_EXPORT
void MSTP_Receive_Frame_FSM(
volatile struct mstp_port_struct_t
*mstp_port);
BACNET_STACK_EXPORT
bool MSTP_Master_Node_FSM(
volatile struct mstp_port_struct_t
*mstp_port);
BACNET_STACK_EXPORT
void MSTP_Slave_Node_FSM(
volatile struct mstp_port_struct_t *mstp_port);
/* returns true if line is active */
BACNET_STACK_EXPORT
bool MSTP_Line_Active(
volatile struct mstp_port_struct_t *mstp_port);
BACNET_STACK_EXPORT
uint16_t MSTP_Create_Frame(
uint8_t * buffer, /* where frame is loaded */
uint16_t buffer_len, /* amount of space available */
@@ -197,6 +204,7 @@ extern "C" {
uint8_t * data, /* any data to be sent - may be null */
uint16_t data_len); /* number of bytes of data (up to 501) */
BACNET_STACK_EXPORT
void MSTP_Create_And_Send_Frame(
volatile struct mstp_port_struct_t *mstp_port, /* port to send from */
uint8_t frame_type, /* type of frame to send - see defines */
@@ -205,23 +213,27 @@ extern "C" {
uint8_t * data, /* any data to be sent - may be null */
uint16_t data_len);
BACNET_STACK_EXPORT
void MSTP_Fill_BACnet_Address(
BACNET_ADDRESS * src,
uint8_t mstp_address);
/* functions used by the MS/TP state machine to put or get data */
/* FIXME: developer must implement these in their DLMSTP module */
BACNET_STACK_EXPORT
uint16_t MSTP_Put_Receive(
volatile 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(
volatile 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(
volatile struct mstp_port_struct_t *mstp_port,
unsigned timeout); /* milliseconds to wait for a packet */
+5
View File
@@ -24,14 +24,19 @@
#ifndef MSTPTEXT_H
#define MSTPTEXT_H
#include "bacnet/bacnet_stack_exports.h"
#ifdef __cplusplus
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);