Changed the client functions to be defined only when BBMD_CLIENT_ENABLED=1, which cleaned up the warnings.
This commit is contained in:
@@ -70,6 +70,28 @@ extern "C" {
|
|||||||
uint8_t * pdu, /* any data to be sent - may be null */
|
uint8_t * pdu, /* any data to be sent - may be null */
|
||||||
unsigned pdu_len);
|
unsigned pdu_len);
|
||||||
|
|
||||||
|
#if defined(BBMD_CLIENT_ENABLED) && BBMD_CLIENT_ENABLED
|
||||||
|
int bvlc_encode_write_bdt_init(
|
||||||
|
uint8_t * pdu,
|
||||||
|
unsigned entries);
|
||||||
|
int bvlc_encode_read_bdt(
|
||||||
|
uint8_t * pdu);
|
||||||
|
int bvlc_encode_read_fdt(
|
||||||
|
uint8_t * pdu);
|
||||||
|
int bvlc_encode_delete_fdt_entry(
|
||||||
|
uint8_t * pdu,
|
||||||
|
uint32_t address, /* in network byte order */
|
||||||
|
uint16_t port); /* in network byte order */
|
||||||
|
int bvlc_encode_original_unicast_npdu(
|
||||||
|
uint8_t * pdu,
|
||||||
|
uint8_t * npdu,
|
||||||
|
unsigned npdu_length);
|
||||||
|
int bvlc_encode_original_broadcast_npdu(
|
||||||
|
uint8_t * pdu,
|
||||||
|
uint8_t * npdu,
|
||||||
|
unsigned npdu_length);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
+56
-44
@@ -119,6 +119,24 @@ void bvlc_maintenance_timer(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* copy the source internet address to the BACnet address */
|
||||||
|
/* FIXME: IPv6? */
|
||||||
|
static void bvlc_internet_to_bacnet_address(
|
||||||
|
BACNET_ADDRESS * src, /* returns the BACnet source address */
|
||||||
|
struct sockaddr_in *sin)
|
||||||
|
{ /* source address in network order */
|
||||||
|
|
||||||
|
if (src && sin) {
|
||||||
|
memcpy(&src->mac[0], &sin->sin_addr.s_addr, 4);
|
||||||
|
memcpy(&src->mac[4], &sin->sin_port, 2);
|
||||||
|
src->mac_len = (uint8_t) 6;
|
||||||
|
src->net = 0;
|
||||||
|
src->len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Addressing within B/IP Networks
|
/* Addressing within B/IP Networks
|
||||||
In the case of B/IP networks, six octets consisting of the four-octet
|
In the case of B/IP networks, six octets consisting of the four-octet
|
||||||
IP address followed by a two-octet UDP port number (both of
|
IP address followed by a two-octet UDP port number (both of
|
||||||
@@ -192,6 +210,7 @@ static int bvlc_encode_bvlc_result(
|
|||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(BBMD_CLIENT_ENABLED) && BBMD_CLIENT_ENABLED
|
||||||
int bvlc_encode_write_bdt_init(
|
int bvlc_encode_write_bdt_init(
|
||||||
uint8_t * pdu,
|
uint8_t * pdu,
|
||||||
unsigned entries)
|
unsigned entries)
|
||||||
@@ -212,8 +231,10 @@ int bvlc_encode_write_bdt_init(
|
|||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int bvlc_encode_read_bdt(
|
#if defined(BBMD_CLIENT_ENABLED) && BBMD_CLIENT_ENABLED
|
||||||
|
int bvlc_encode_read_bdt(
|
||||||
uint8_t * pdu)
|
uint8_t * pdu)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
@@ -230,6 +251,7 @@ static int bvlc_encode_read_bdt(
|
|||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int bvlc_encode_read_bdt_ack_init(
|
static int bvlc_encode_read_bdt_ack_init(
|
||||||
uint8_t * pdu,
|
uint8_t * pdu,
|
||||||
@@ -334,7 +356,8 @@ static int bvlc_encode_register_foreign_device(
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bvlc_encode_read_fdt(
|
#if defined(BBMD_CLIENT_ENABLED) && BBMD_CLIENT_ENABLED
|
||||||
|
int bvlc_encode_read_fdt(
|
||||||
uint8_t * pdu)
|
uint8_t * pdu)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
@@ -351,6 +374,7 @@ static int bvlc_encode_read_fdt(
|
|||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int bvlc_encode_read_fdt_ack_init(
|
static int bvlc_encode_read_fdt_ack_init(
|
||||||
uint8_t * pdu,
|
uint8_t * pdu,
|
||||||
@@ -412,30 +436,33 @@ static int bvlc_encode_read_fdt_ack(
|
|||||||
return pdu_len;
|
return pdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bvlc_encode_delete_fdt_entry(
|
#if defined(BBMD_CLIENT_ENABLED) && BBMD_CLIENT_ENABLED
|
||||||
|
int bvlc_encode_delete_fdt_entry(
|
||||||
uint8_t * pdu,
|
uint8_t * pdu,
|
||||||
struct in_addr *address,
|
uint32_t address, /* in network byte order */
|
||||||
uint16_t port)
|
uint16_t port) /* in network byte order */
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
if (pdu) {
|
if (pdu) {
|
||||||
pdu[0] = BVLL_TYPE_BACNET_IP;
|
pdu[0] = BVLL_TYPE_BACNET_IP;
|
||||||
pdu[1] = BVLC_READ_FOREIGN_DEVICE_TABLE;
|
pdu[1] = BVLC_DELETE_FOREIGN_DEVICE_TABLE_ENTRY;
|
||||||
/* The 2-octet BVLC Length field is the length, in octets,
|
/* The 2-octet BVLC Length field is the length, in octets,
|
||||||
of the entire BVLL message, including the two octets of the
|
of the entire BVLL message, including the two octets of the
|
||||||
length field itself, most significant octet first. */
|
length field itself, most significant octet first. */
|
||||||
encode_unsigned16(&pdu[2], 10);
|
encode_unsigned16(&pdu[2], 10);
|
||||||
/* FDT Entry */
|
/* FDT Entry */
|
||||||
encode_unsigned32(&pdu[4], address->s_addr);
|
encode_unsigned32(&pdu[4], address);
|
||||||
encode_unsigned16(&pdu[8], port);
|
encode_unsigned16(&pdu[8], port);
|
||||||
len = 10;
|
len = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int bvlc_encode_original_unicast_npdu(
|
#if defined(BBMD_CLIENT_ENABLED) && BBMD_CLIENT_ENABLED
|
||||||
|
int bvlc_encode_original_unicast_npdu(
|
||||||
uint8_t * pdu,
|
uint8_t * pdu,
|
||||||
uint8_t * npdu,
|
uint8_t * npdu,
|
||||||
unsigned npdu_length)
|
unsigned npdu_length)
|
||||||
@@ -460,8 +487,10 @@ static int bvlc_encode_original_unicast_npdu(
|
|||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int bvlc_encode_original_broadcast_npdu(
|
#if defined(BBMD_CLIENT_ENABLED) && BBMD_CLIENT_ENABLED
|
||||||
|
int bvlc_encode_original_broadcast_npdu(
|
||||||
uint8_t * pdu,
|
uint8_t * pdu,
|
||||||
uint8_t * npdu,
|
uint8_t * npdu,
|
||||||
unsigned npdu_length)
|
unsigned npdu_length)
|
||||||
@@ -486,41 +515,7 @@ static int bvlc_encode_original_broadcast_npdu(
|
|||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* copy the source internet address to the BACnet address */
|
|
||||||
/* FIXME: IPv6? */
|
|
||||||
static void bvlc_internet_to_bacnet_address(
|
|
||||||
BACNET_ADDRESS * src, /* returns the BACnet source address */
|
|
||||||
struct sockaddr_in *sin)
|
|
||||||
{ /* source address in network order */
|
|
||||||
|
|
||||||
if (src && sin) {
|
|
||||||
memcpy(&src->mac[0], &sin->sin_addr.s_addr, 4);
|
|
||||||
memcpy(&src->mac[4], &sin->sin_port, 2);
|
|
||||||
src->mac_len = (uint8_t) 6;
|
|
||||||
src->net = 0;
|
|
||||||
src->len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* copy the source internet address to the BACnet address */
|
|
||||||
/* FIXME: IPv6? */
|
|
||||||
static void bvlc_bacnet_to_internet_address(
|
|
||||||
struct sockaddr_in *sin, /* source address in network order */
|
|
||||||
BACNET_ADDRESS * src)
|
|
||||||
{ /* returns the BACnet source address */
|
|
||||||
|
|
||||||
if (src && sin) {
|
|
||||||
if (src->mac_len == 6) {
|
|
||||||
memcpy(&sin->sin_addr.s_addr, &src->mac[0], 4);
|
|
||||||
memcpy(&sin->sin_port, &src->mac[4], 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool bvlc_create_bdt(
|
static bool bvlc_create_bdt(
|
||||||
uint8_t * npdu,
|
uint8_t * npdu,
|
||||||
@@ -1193,6 +1188,23 @@ int bvlc_send_pdu(
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "ctest.h"
|
#include "ctest.h"
|
||||||
|
|
||||||
|
/* copy the source internet address to the BACnet address */
|
||||||
|
/* FIXME: IPv6? */
|
||||||
|
static void bvlc_bacnet_to_internet_address(
|
||||||
|
struct sockaddr_in *sin, /* source address in network order */
|
||||||
|
BACNET_ADDRESS * src)
|
||||||
|
{ /* returns the BACnet source address */
|
||||||
|
|
||||||
|
if (src && sin) {
|
||||||
|
if (src->mac_len == 6) {
|
||||||
|
memcpy(&sin->sin_addr.s_addr, &src->mac[0], 4);
|
||||||
|
memcpy(&sin->sin_port, &src->mac[4], 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void testBIPAddress(
|
void testBIPAddress(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user