Make most of functions const correct (#714)

* Make most of the functions const correct

Used clang-tidy and sonarlint to help find places where const could
pretty easily applied. Also lot of hand work.

This commit does not yet touch handlers and typedefs of those.

* Fix Arduino uno handler_who_is() has extra parenthesis

For some reason there is extra parenthesis. Remove it this is more
likely buildable.

* Bugfix/bacapp: Fix uninitilized array_index

We have changed bacapp_snprintf_value() to be const correct. After that
we got

```
/home/runner/work/bacnet-stack/bacnet-stack/src/bacnet/bacapp.c:3183:27: warning: 4th function call argument is an uninitialized value [core.CallAndMessage]
                ret_val = bacapp_snprintf_weeklyschedule(
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
```

So analyzer could now spot that we do not actually initilize array_index
at all. Fix this by setting array_index to zero. Note that I actually do
not know if zeroing is right thing to do here. I choose zero as if this
has worked before it is most likely that it will work with zero value.

* cmake: Add and ignore Wwrite-strings compiler option

Wwrite-strings helps find places where const correctness is broken.

Example it will warn about these

```C

void func1(char* str);

func("test") /* "test" is const so we should not pass it to func1().

char* func2()
{
  return "test"; /* func2() should return const char*.
}
```

We still need to ignore it as not all are fixed but let's add it already
so we remember that it should be opened at some point.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
Kari Argillander
2024-08-29 22:08:02 +03:00
committed by GitHub
parent 0177c59f4a
commit a2f1d6959d
408 changed files with 2608 additions and 2336 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ long bip_getaddrbyname(const char *host_name)
* @param ifname [in] The named interface to use for the network layer.
* Eg, for Linux, ifname is eth0, ath0, arc0, and others.
*/
void bip_set_interface(char *ifname)
void bip_set_interface(const char *ifname)
{
uint8_t local_address[] = { 0, 0, 0, 0 };
uint8_t broadcast_address[] = { 0, 0, 0, 0 };
+4 -5
View File
@@ -34,7 +34,7 @@ static uint8_t BIP_Broadcast_Address[4] = { 0, 0, 0, 0 };
/** Converter from uint8_t[4] type address to uint32_t
*
*/
uint32_t convertBIP_Address2uint32(uint8_t *bip_address)
uint32_t convertBIP_Address2uint32(const suint8_t *bip_address)
{
return (uint32_t)((bip_address[0] * 2 ^ 24) + (bip_address[1] * 2 ^ 16) +
(bip_address[2] * 2 ^ 8) + bip_address[3]);
@@ -74,7 +74,7 @@ bool bip_valid(void)
return (BIP_Socket < MAX_SOCK_NUM);
}
void bip_set_addr(uint8_t *net_address)
void bip_set_addr(const uint8_t *net_address)
{ /* in network byte order */
for (uint8_t i = 0; i < 4; i++)
BIP_Address[i] = net_address[i];
@@ -86,7 +86,7 @@ uint8_t *bip_get_addr(void)
return BIP_Address;
}
void bip_set_broadcast_addr(uint8_t *net_address)
void bip_set_broadcast_addr(const uint8_t *net_address)
{ /* in network byte order */
for (uint8_t i = 0; i < 4; i++)
BIP_Broadcast_Address[i] = net_address[i];
@@ -109,9 +109,8 @@ uint16_t bip_get_port(void)
return ntohs(BIP_Port);
}
static int bip_decode_bip_address(BACNET_ADDRESS *bac_addr,
static int bip_decode_bip_address(const BACNET_ADDRESS *bac_addr,
uint8_t *address, /* in network format */
uint16_t *port)
{ /* in network format */
int len = 0;
+4 -4
View File
@@ -28,11 +28,11 @@ extern "C" {
/* on Linux, ifname is eth0, ath0, arc0, and others.
on Windows, ifname is the dotted ip address of the interface */
bool bip_init(char *ifname);
void bip_set_interface(char *ifname);
void bip_set_interface(const char *ifname);
void bip_cleanup(void);
/* Convert uint8_t IPv4 to uint32 */
uint32_t convertBIP_Address2uint32(uint8_t * bip_address);
uint32_t convertBIP_Address2uint32(const uint8_t * bip_address);
void convertUint32Address_2_uint8Address(uint32_t ip,
uint8_t * address);
/* common BACnet/IP functions */
@@ -68,12 +68,12 @@ extern "C" {
uint16_t bip_get_port(void);
/* use network byte order for setting */
void bip_set_addr(uint8_t * net_address);
void bip_set_addr(const uint8_t * net_address);
/* returns network byte order */
uint8_t *bip_get_addr(void);
/* use network byte order for setting */
void bip_set_broadcast_addr(uint8_t * net_address);
void bip_set_broadcast_addr(const uint8_t * net_address);
/* returns network byte order */
uint8_t *bip_get_broadcast_addr(void);
+4 -8
View File
@@ -54,12 +54,9 @@ static int bvlc_encode_bvlc_result(uint8_t *pdu, BACNET_BVLC_RESULT result_code)
* @return Upon successful completion, returns the number of bytes sent.
* Otherwise, -1 shall be returned and errno set to indicate the error.
*/
static int bvlc_send_mpdu(uint8_t *dest_addr, /* the destination address */
uint16_t *dest_port, /* the destination port */
static int bvlc_send_mpdu(const uint8_t *dest_addr, /* the destination address */
const uint16_t *dest_port, /* the destination port */
uint8_t *mtu, /* the data */
uint16_t mtu_len)
{ /* amount of data to send */
/* assumes that the driver has already been initialized */
@@ -75,9 +72,8 @@ static int bvlc_send_mpdu(uint8_t *dest_addr, /* the destination address */
* @param dest_addr - destination address
* @param dest_port - destination port
*/
static void bvlc_send_result(uint8_t *dest_addr,
uint16_t *dest_port, /* the destination address */
static void bvlc_send_result(const uint8_t *dest_addr,
const uint16_t *dest_port, /* the destination address */
BACNET_BVLC_RESULT result_code)
{
uint8_t mtu[BIP_MPDU_MAX] = { 0 };
+1 -1
View File
@@ -64,7 +64,7 @@ void handler_who_is(
} else if (len != -1) {
/* is my device id within the limits? */
target_device = Device_Object_Instance_Number();
if (((target_device >= low_limit) && (target_device <= high_limit)) {
if ((target_device >= low_limit) && (target_device <= high_limit)) {
sendIamUnicast(&Handler_Transmit_Buffer[0], src);
}
}
+4 -3
View File
@@ -126,7 +126,8 @@ static struct my_object_functions *Device_Objects_Find_Functions(
}
static int Read_Property_Common(
struct my_object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
const struct my_object_functions *pObject,
BACNET_READ_PROPERTY_DATA *rpdata)
{
int apdu_len = BACNET_STATUS_ERROR;
BACNET_CHARACTER_STRING char_string;
@@ -299,7 +300,7 @@ bool Device_Object_Name(
return status;
}
bool Device_Set_Object_Name(BACNET_CHARACTER_STRING *object_name)
bool Device_Set_Object_Name(const BACNET_CHARACTER_STRING *object_name)
{
bool status = false; /*return value */
@@ -574,7 +575,7 @@ int Device_Object_List_Element_Encode(
return apdu_len;
}
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
BACNET_OBJECT_TYPE *object_type,
uint32_t *object_instance)
{
+6 -6
View File
@@ -195,10 +195,10 @@ void dlmstp_fill_bacnet_address(BACNET_ADDRESS *src, uint8_t mstp_address)
}
}
static bool dlmstp_compare_data_expecting_reply(uint8_t *request_pdu,
static bool dlmstp_compare_data_expecting_reply(const uint8_t *request_pdu,
uint16_t request_pdu_len,
uint8_t src_address,
uint8_t *reply_pdu,
const uint8_t *reply_pdu,
uint16_t reply_pdu_len,
uint8_t dest_address)
{
@@ -314,7 +314,7 @@ static void MSTP_Send_Frame(
uint8_t frame_type, /* type of frame to send - see defines */
uint8_t destination, /* destination address */
uint8_t source, /* source address */
uint8_t *data, /* any data to be sent - may be null */
const uint8_t *data, /* any data to be sent - may be null */
uint16_t data_len)
{ /* number of bytes of data (up to 501) */
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
@@ -735,7 +735,7 @@ static bool MSTP_Master_Node_FSM(void)
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
(uint8_t *)&pkt->buffer[0], pkt->length);
&pkt->buffer[0], pkt->length);
FrameCount++;
switch (frame_type) {
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
@@ -1081,7 +1081,7 @@ static bool MSTP_Master_Node_FSM(void)
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
(uint8_t *)&pkt->buffer[0], pkt->length);
&pkt->buffer[0], pkt->length);
Master_State = MSTP_MASTER_STATE_IDLE;
/* clear our flag we were holding for comparison */
MSTP_Flag.ReceivedValidFrame = false;
@@ -1165,7 +1165,7 @@ static void MSTP_Slave_Node_FSM(void)
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
(uint8_t *)&pkt->buffer[0], pkt->length);
&pkt->buffer[0], pkt->length);
(void)Ringbuf_Pop(&PDU_Queue, NULL);
}
/* clear our flag we were holding for comparison */
+1 -1
View File
@@ -294,7 +294,7 @@ bool Network_Port_MAC_Address(
* @return true if object-name was set
*/
bool Network_Port_MAC_Address_Set(
uint32_t object_instance, uint8_t *mac_src, uint8_t mac_len)
uint32_t object_instance, const uint8_t *mac_src, uint8_t mac_len)
{
if (mac_len == 1) {
Object_List[0].MAC_Address[0] = mac_src[0];
+1 -1
View File
@@ -171,7 +171,7 @@ void RS485_Transmitter_Enable(bool enable)
* ALGORITHM: none
* NOTES: none
*****************************************************************************/
void RS485_Send_Data(uint8_t *buffer, /* data to send */
void RS485_Send_Data(const uint8_t *buffer, /* data to send */
uint16_t nbytes)
{ /* number of bytes of data */
/* LED on send */
+1 -1
View File
@@ -22,7 +22,7 @@ extern "C" {
bool enable);
void RS485_Send_Data(
uint8_t * buffer, /* data to send */
const uint8_t * buffer, /* data to send */
uint16_t nbytes); /* number of bytes of data */
bool RS485_ReceiveError(
+3 -3
View File
@@ -37,13 +37,13 @@ extern "C" {
uint32_t object_instance);
bool Analog_Input_Name_Set(
uint32_t object_instance,
char *new_name);
const char *new_name);
char *Analog_Input_Description(
const char *Analog_Input_Description(
uint32_t instance);
bool Analog_Input_Description_Set(
uint32_t instance,
char *new_name);
const char *new_name);
bool Analog_Input_Units_Set(
uint32_t instance,
+3 -3
View File
@@ -226,7 +226,7 @@ static void MSTP_Send_Frame(
uint8_t frame_type, /* type of frame to send - see defines */
uint8_t destination, /* destination address */
uint8_t source, /* source address */
uint8_t *pdu, /* any data to be sent - may be null */
const uint8_t *pdu, /* any data to be sent - may be null */
uint16_t pdu_len)
{ /* number of bytes of data (up to 501) */
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
@@ -635,7 +635,7 @@ static bool MSTP_Master_Node_FSM(void)
if (TransmitPacketLen) {
MSTP_Send_Frame(FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY,
MSTP_BROADCAST_ADDRESS, This_Station,
(uint8_t *)&TransmitPacket[0], TransmitPacketLen);
&TransmitPacket[0], TransmitPacketLen);
FrameCount++;
} else {
/* NothingToSend */
@@ -959,7 +959,7 @@ static bool MSTP_Master_Node_FSM(void)
/* Note: optimized such that we are never a client */
MSTP_Send_Frame(FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY,
TransmitPacketDest, This_Station,
(uint8_t *)&TransmitPacket[0], TransmitPacketLen);
&TransmitPacket[0], TransmitPacketLen);
MSTP_Flag.TransmitPacketPending = false;
Master_State = MSTP_MASTER_STATE_IDLE;
} else {
+1 -1
View File
@@ -144,7 +144,7 @@ void RS485_Turnaround_Delay(void)
* @param buffer - data to send
* @param nbytes - number of bytes of data
*/
void RS485_Send_Data(uint8_t *buffer,
void RS485_Send_Data(const uint8_t *buffer,
uint16_t nbytes)
{
while (nbytes) {
+1 -1
View File
@@ -21,7 +21,7 @@ extern "C" {
bool enable);
void RS485_Send_Data(
uint8_t * buffer, /* data to send */
const uint8_t * buffer, /* data to send */
uint16_t nbytes); /* number of bytes of data */
bool RS485_ReceiveError(
+10 -8
View File
@@ -18,7 +18,7 @@
#include "bacnet/basic/object/device.h"
#include "bname.h"
static bool bacnet_name_isvalid(uint8_t encoding, uint8_t length, char *str)
static bool bacnet_name_isvalid(uint8_t encoding, uint8_t length, const char *str)
{
bool valid = false;
@@ -35,7 +35,7 @@ static bool bacnet_name_isvalid(uint8_t encoding, uint8_t length, char *str)
}
bool bacnet_name_save(
uint16_t offset, uint8_t encoding, char *str, uint8_t length)
uint16_t offset, uint8_t encoding, const char *str, uint8_t length)
{
uint8_t buffer[NV_EEPROM_NAME_SIZE] = { 0 };
uint8_t i = 0;
@@ -55,11 +55,11 @@ bool bacnet_name_save(
return false;
}
bool bacnet_name_set(uint16_t offset, BACNET_CHARACTER_STRING *char_string)
bool bacnet_name_set(uint16_t offset, const BACNET_CHARACTER_STRING *char_string)
{
uint8_t encoding = 0;
uint8_t length = 0;
char *str = NULL;
const char *str = NULL;
length = characterstring_length(char_string);
encoding = characterstring_encoding(char_string);
@@ -70,7 +70,7 @@ bool bacnet_name_set(uint16_t offset, BACNET_CHARACTER_STRING *char_string)
bool bacnet_name_write_unique(uint16_t offset,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING *char_string,
const BACNET_CHARACTER_STRING *char_string,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
{
@@ -120,7 +120,7 @@ bool bacnet_name_write_unique(uint16_t offset,
/* no required minumum length or duplicate checking */
bool bacnet_name_write(uint16_t offset,
BACNET_CHARACTER_STRING *char_string,
const BACNET_CHARACTER_STRING *char_string,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
{
@@ -149,14 +149,16 @@ bool bacnet_name_write(uint16_t offset,
return status;
}
void bacnet_name_init(uint16_t offset, char *default_string)
void bacnet_name_init(uint16_t offset, const char *default_string)
{
(void)bacnet_name_save(
offset, CHARACTER_UTF8, default_string, strlen(default_string));
}
void bacnet_name(
uint16_t offset, BACNET_CHARACTER_STRING *char_string, char *default_string)
uint16_t offset,
BACNET_CHARACTER_STRING *char_string,
const char *default_string)
{
uint8_t encoding = 0;
uint8_t length = 0;
+6 -6
View File
@@ -17,30 +17,30 @@ extern "C" {
bool bacnet_name_set(
uint16_t eeprom_offset,
BACNET_CHARACTER_STRING * char_string);
const BACNET_CHARACTER_STRING * char_string);
void bacnet_name_init(
uint16_t eeprom_offset,
char *default_string);
const char *default_string);
bool bacnet_name_save(
uint16_t offset,
uint8_t encoding,
char *str,
const char *str,
uint8_t length);
void bacnet_name(
uint16_t eeprom_offset,
BACNET_CHARACTER_STRING * char_string,
char *default_string);
const char *default_string);
bool bacnet_name_write_unique(
uint16_t offset,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING * char_string,
const BACNET_CHARACTER_STRING * char_string,
BACNET_ERROR_CLASS * error_class,
BACNET_ERROR_CODE * error_code);
/* no required minumum length or duplicate checking */
bool bacnet_name_write(
uint16_t offset,
BACNET_CHARACTER_STRING * char_string,
const BACNET_CHARACTER_STRING * char_string,
BACNET_ERROR_CLASS * error_class,
BACNET_ERROR_CODE * error_code);
+1 -1
View File
@@ -551,7 +551,7 @@ int Device_Object_List_Element_Encode(
return apdu_len;
}
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
BACNET_OBJECT_TYPE *object_type,
uint32_t *object_instance)
{
+7 -7
View File
@@ -196,10 +196,10 @@ void dlmstp_fill_bacnet_address(BACNET_ADDRESS *src, uint8_t mstp_address)
}
}
static bool dlmstp_compare_data_expecting_reply(uint8_t *request_pdu,
static bool dlmstp_compare_data_expecting_reply(const uint8_t *request_pdu,
uint16_t request_pdu_len,
uint8_t src_address,
uint8_t *reply_pdu,
const uint8_t *reply_pdu,
uint16_t reply_pdu_len,
uint8_t dest_address)
{
@@ -314,8 +314,8 @@ static bool dlmstp_compare_data_expecting_reply(uint8_t *request_pdu,
static void MSTP_Send_Frame(
uint8_t frame_type, /* type of frame to send - see defines */
uint8_t destination, /* destination address */
uint8_t source, /* source address */
uint8_t *data, /* any data to be sent - may be null */
uint8_t source, /* source address */
const uint8_t *data, /* any data to be sent - may be null */
uint16_t data_len)
{ /* number of bytes of data (up to 501) */
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
@@ -757,7 +757,7 @@ static bool MSTP_Master_Node_FSM(void)
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
(uint8_t *)&pkt->buffer[0], pkt->length);
&pkt->buffer[0], pkt->length);
FrameCount++;
switch (frame_type) {
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
@@ -1111,7 +1111,7 @@ static bool MSTP_Master_Node_FSM(void)
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
(uint8_t *)&pkt->buffer[0], pkt->length);
&pkt->buffer[0], pkt->length);
Master_State = MSTP_MASTER_STATE_IDLE;
/* clear our flag we were holding for comparison */
MSTP_Flag.ReceivedValidFrame = false;
@@ -1195,7 +1195,7 @@ static void MSTP_Slave_Node_FSM(void)
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
(uint8_t *)&pkt->buffer[0], pkt->length);
&pkt->buffer[0], pkt->length);
(void)Ringbuf_Pop(&PDU_Queue, NULL);
}
/* clear our flag we were holding for comparison */
+1 -1
View File
@@ -30,7 +30,7 @@ int eeprom_bytes_read(
}
int eeprom_bytes_write(uint16_t eeaddr, /* EEPROM starting memory address */
uint8_t *buf, /* data to send */
const uint8_t *buf, /* data to send */
int len)
{ /* number of bytes of data */
int count = 0;
+1 -1
View File
@@ -21,7 +21,7 @@ extern "C" {
int nbytes); /* number of bytes of data to read */
int eeprom_bytes_write(
uint16_t ee_address, /* EEPROM starting memory address */
uint8_t * buffer, /* data to send */
const uint8_t * buffer, /* data to send */
int nbytes); /* number of bytes of data */
#ifdef __cplusplus
+1 -1
View File
@@ -295,7 +295,7 @@ bool Network_Port_MAC_Address(
* @return true if object-name was set
*/
bool Network_Port_MAC_Address_Set(
uint32_t object_instance, uint8_t *mac_src, uint8_t mac_len)
uint32_t object_instance, const uint8_t *mac_src, uint8_t mac_len)
{
if (mac_len == 1) {
Object_List[0].MAC_Address[0] = mac_src[0];
+1 -1
View File
@@ -175,7 +175,7 @@ bool rs485_receive_error(void)
* RETURN: none
* NOTES: none
*****************************************************************************/
void rs485_bytes_send(uint8_t *buffer, /* data to send */
void rs485_bytes_send(const uint8_t *buffer, /* data to send */
uint16_t nbytes)
{ /* number of bytes of data */
led_on(LED_5);
+1 -1
View File
@@ -23,7 +23,7 @@ extern "C" {
bool rs485_receive_error(
void);
void rs485_bytes_send(
uint8_t * buffer, /* data to send */
const uint8_t * buffer, /* data to send */
uint16_t nbytes); /* number of bytes of data */
uint32_t rs485_baud_rate(
void);
+9 -7
View File
@@ -162,7 +162,7 @@ void bip_get_broadcast_address(BACNET_ADDRESS *dest)
*
* @param addr - network IPv4 address
*/
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
bool bip_set_addr(const BACNET_IP_ADDRESS *addr)
{
(void)addr;
/* not something we do within this driver */
@@ -189,7 +189,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
* @param addr - network IPv4 address
* @return true if the address was set
*/
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
bool bip_set_broadcast_addr(const BACNET_IP_ADDRESS *addr)
{
(void)addr;
/* not something we do within this driver */
@@ -257,7 +257,8 @@ uint8_t bip_get_subnet_prefix(void)
* @return Upon successful completion, returns the number of bytes sent.
* Otherwise, -1 shall be returned and errno set to indicate the error.
*/
int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
int bip_send_mpdu(
const BACNET_IP_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
{
struct sockaddr_in bip_dest = { 0 };
@@ -276,7 +277,7 @@ int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
/* Send the packet */
debug_print_ipv4(
"Sending MPDU->", &bip_dest.sin_addr, bip_dest.sin_port, mtu_len);
return sendto(BIP_Socket, (char *)mtu, mtu_len, 0,
return sendto(BIP_Socket, (const char *)mtu, mtu_len, 0,
(struct sockaddr *)&bip_dest, sizeof(struct sockaddr));
}
@@ -472,7 +473,8 @@ static char *ifname_default(void)
* @param addr [out] The netmask addr, broadcast addr, ip addr.
* @param request [in] addr broadaddr netmask
*/
static int get_local_address(char *ifname, struct in_addr *addr, char *request)
static int get_local_address(
const char *ifname, struct in_addr *addr, const char *request)
{
char rv = '\0'; /* return value */
@@ -543,7 +545,7 @@ int bip_set_broadcast_binding(
* @param ifname [in] The named interface to use for the network layer.
* Eg, for MAC OS X, ifname is en0, en1, and others.
*/
void bip_set_interface(char *ifname)
void bip_set_interface(const char *ifname)
{
struct in_addr local_address;
struct in_addr broadcast_address;
@@ -602,7 +604,7 @@ void bip_set_interface(char *ifname)
}
}
static int createSocket(struct sockaddr_in *sin)
static int createSocket(const struct sockaddr_in *sin)
{
int status = 0; /* return from socket lib calls */
int sockopt = 0;
+5 -4
View File
@@ -181,7 +181,7 @@ void bip6_get_my_address(BACNET_ADDRESS *addr)
*
* @param addr - network IPv6 address
*/
bool bip6_set_addr(BACNET_IP6_ADDRESS *addr)
bool bip6_set_addr(const BACNET_IP6_ADDRESS *addr)
{
return bvlc6_address_copy(&BIP6_Addr, addr);
}
@@ -201,7 +201,7 @@ bool bip6_get_addr(BACNET_IP6_ADDRESS *addr)
*
* @param addr - network IPv6 address
*/
bool bip6_set_broadcast_addr(BACNET_IP6_ADDRESS *addr)
bool bip6_set_broadcast_addr(const BACNET_IP6_ADDRESS *addr)
{
return bvlc6_address_copy(&BIP6_Broadcast_Addr, addr);
}
@@ -227,7 +227,8 @@ bool bip6_get_broadcast_addr(BACNET_IP6_ADDRESS *addr)
* @return Upon successful completion, returns the number of bytes sent.
* Otherwise, -1 shall be returned and errno set to indicate the error.
*/
int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
int bip6_send_mpdu(
const BACNET_IP6_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
{
struct sockaddr_in6 bvlc_dest = { 0 };
uint16_t addr16[8];
@@ -252,7 +253,7 @@ int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
bvlc_dest.sin6_scope_id = BIP6_Socket_Scope_Id;
debug_print_ipv6("Sending MPDU->", &bvlc_dest.sin6_addr);
/* Send the packet */
return sendto(BIP6_Socket, (char *)mtu, mtu_len, 0,
return sendto(BIP6_Socket, (const char *)mtu, mtu_len, 0,
(struct sockaddr *)&bvlc_dest, sizeof(bvlc_dest));
}
+1 -2
View File
@@ -27,8 +27,7 @@
* @param utc - True for UTC sync, False for Local time
* @return True if time is set
*/
void datetime_timesync(
BACNET_DATE *bdate, BACNET_TIME *btime, bool utc)
void datetime_timesync(BACNET_DATE *bdate, BACNET_TIME *btime, bool utc)
{
(void)bdate;
(void)btime;
+1 -1
View File
@@ -396,7 +396,7 @@ bool RS485_Set_Baud_Rate(uint32_t baud)
*****************************************************************************/
void RS485_Send_Frame(
struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes)
{ /* number of bytes of data (up to 501) */
uint32_t turnaround_time = Tturnaround * 1000;
+2 -2
View File
@@ -30,8 +30,8 @@ void RS485_Initialize(void);
BACNET_STACK_EXPORT
void RS485_Send_Frame(
struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes); /* number of bytes of data (up to 501) */
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes); /* number of bytes of data (up to 501) */
BACNET_STACK_EXPORT
void RS485_Check_UART_Data(
+3 -3
View File
@@ -73,13 +73,13 @@ extern "C" {
BACNET_CHARACTER_STRING * object_name);
bool Analog_Input_Name_Set(
uint32_t object_instance,
char *new_name);
const char *new_name);
char *Analog_Input_Description(
const char *Analog_Input_Description(
uint32_t instance);
bool Analog_Input_Description_Set(
uint32_t instance,
char *new_name);
const char *new_name);
bool Analog_Input_Units_Set(
uint32_t instance,
+1 -1
View File
@@ -15,7 +15,7 @@ long bip_get_addr_by_name(const char *host_name)
return 0;
}
void bip_set_interface(char *ifname)
void bip_set_interface(const char *ifname)
{
}
+3 -3
View File
@@ -45,13 +45,13 @@ extern "C" {
uint32_t object_instance,
char *new_name);
char *Binary_Output_Description(
const char *Binary_Output_Description(
uint32_t instance);
bool Binary_Output_Description_Set(
uint32_t instance,
char *new_name);
const char *new_name);
char *Binary_Output_Inactive_Text(
const char *Binary_Output_Inactive_Text(
uint32_t instance);
bool Binary_Output_Inactive_Text_Set(
uint32_t instance,
+2 -2
View File
@@ -381,7 +381,7 @@ bool Device_Object_Name(
return status;
}
bool Device_Set_Object_Name(BACNET_CHARACTER_STRING *object_name)
bool Device_Set_Object_Name(const BACNET_CHARACTER_STRING *object_name)
{
bool status = false; /*return value */
@@ -689,7 +689,7 @@ bool Device_Object_List_Identifier(
* Object.
* @return True on success or else False if not found.
*/
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
BACNET_OBJECT_TYPE *object_type,
uint32_t *object_instance)
{
+7 -7
View File
@@ -274,7 +274,7 @@ extern "C" {
uint32_t object_instance,
BACNET_CHARACTER_STRING * object_name);
bool Device_Set_Object_Name(
BACNET_CHARACTER_STRING * object_name);
const BACNET_CHARACTER_STRING * object_name);
/* Copy a child object name, given its ID. */
bool Device_Object_Name_Copy(
BACNET_OBJECT_TYPE object_type,
@@ -340,7 +340,7 @@ extern "C" {
void);
bool Device_Valid_Object_Name(
BACNET_CHARACTER_STRING * object_name,
const BACNET_CHARACTER_STRING * object_name,
BACNET_OBJECT_TYPE *object_type,
uint32_t * object_instance);
bool Device_Valid_Object_Id(
@@ -375,7 +375,7 @@ extern "C" {
uint16_t Add_Routed_Device(
uint32_t Object_Instance,
BACNET_CHARACTER_STRING * Object_Name,
const BACNET_CHARACTER_STRING * Object_Name,
const char *Description);
DEVICE_OBJECT_DATA *Get_Routed_Device_Object(
int idx);
@@ -388,14 +388,14 @@ extern "C" {
bool Routed_Device_Address_Lookup(
int idx,
uint8_t address_len,
uint8_t * mac_adress);
const uint8_t * mac_adress);
bool Routed_Device_GetNext(
BACNET_ADDRESS * dest,
int *DNET_list,
const BACNET_ADDRESS * dest,
const int *DNET_list,
int *cursor);
bool Routed_Device_Is_Valid_Network(
uint16_t dest_net,
int *DNET_list);
const int *DNET_list);
uint32_t Routed_Device_Index_To_Instance(
unsigned index);
+1 -1
View File
@@ -69,7 +69,7 @@ void arcnet_cleanup(void)
return;
}
static int arcnet_bind(char *interface_name)
static int arcnet_bind(const char *interface_name)
{
int sock_fd = -1; /* return value */
struct ifreq ifr;
+1 -1
View File
@@ -100,7 +100,7 @@ extern int bip_get_local_netmask(
BACNET_STACK_EXPORT
extern int bip_get_local_address_ioctl(
char *ifname,
const char *ifname,
struct in_addr *addr,
int request);
+11 -8
View File
@@ -178,7 +178,7 @@ void bip_get_broadcast_address(BACNET_ADDRESS *dest)
*
* @param addr - network IPv4 address
*/
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
bool bip_set_addr(const BACNET_IP_ADDRESS *addr)
{
/* not something we do within this driver */
(void)addr;
@@ -205,7 +205,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
* @param addr - network IPv4 address
* @return true if the address was set
*/
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
bool bip_set_broadcast_addr(const BACNET_IP_ADDRESS *addr)
{
/* not something we do within this driver */
(void)addr;
@@ -273,7 +273,8 @@ uint8_t bip_get_subnet_prefix(void)
* @return Upon successful completion, returns the number of bytes sent.
* Otherwise, -1 shall be returned and errno set to indicate the error.
*/
int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
int bip_send_mpdu(
const BACNET_IP_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
{
struct sockaddr_in bip_dest = { 0 };
@@ -292,7 +293,7 @@ int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
/* Send the packet */
debug_print_ipv4(
"Sending MPDU->", &bip_dest.sin_addr, bip_dest.sin_port, mtu_len);
return sendto(BIP_Socket, (char *)mtu, mtu_len, 0,
return sendto(BIP_Socket, (const char *)mtu, mtu_len, 0,
(struct sockaddr *)&bip_dest, sizeof(struct sockaddr));
}
@@ -465,7 +466,8 @@ bool bip_get_addr_by_name(const char *host_name, BACNET_IP_ADDRESS *addr)
* @param request - the ioctl() request
* @return 0 on success, else the error from the ioctl() call.
*/
static int get_local_ifr_ioctl(char *ifname, struct ifreq *ifr, int request)
static int get_local_ifr_ioctl(
const char *ifname, struct ifreq *ifr, int request)
{
int fd;
int rv; /* return value */
@@ -491,7 +493,8 @@ static int get_local_ifr_ioctl(char *ifname, struct ifreq *ifr, int request)
* @param request - the ioctl() request
* @return 0 on success, else the error from the ioctl() call.
*/
int bip_get_local_address_ioctl(char *ifname, struct in_addr *addr, int request)
int bip_get_local_address_ioctl(
const char *ifname, struct in_addr *addr, int request)
{
struct ifreq ifr = { 0 };
struct sockaddr_in *tcpip_address;
@@ -746,7 +749,7 @@ int bip_set_broadcast_binding(
* @param ifname [in] The named interface to use for the network layer.
* Eg, for Linux, ifname is eth0, ath0, arc0, and others.
*/
void bip_set_interface(char *ifname)
void bip_set_interface(const char *ifname)
{
struct in_addr local_address;
struct in_addr netmask;
@@ -804,7 +807,7 @@ void bip_set_interface(char *ifname)
}
}
static int createSocket(struct sockaddr_in *sin)
static int createSocket(const struct sockaddr_in *sin)
{
int status = 0; /* return from socket lib calls */
int sockopt = 0;
+5 -4
View File
@@ -188,7 +188,7 @@ void bip6_get_my_address(BACNET_ADDRESS *addr)
*
* @param addr - network IPv6 address
*/
bool bip6_set_addr(BACNET_IP6_ADDRESS *addr)
bool bip6_set_addr(const BACNET_IP6_ADDRESS *addr)
{
return bvlc6_address_copy(&BIP6_Addr, addr);
}
@@ -208,7 +208,7 @@ bool bip6_get_addr(BACNET_IP6_ADDRESS *addr)
*
* @param addr - network IPv6 address
*/
bool bip6_set_broadcast_addr(BACNET_IP6_ADDRESS *addr)
bool bip6_set_broadcast_addr(const BACNET_IP6_ADDRESS *addr)
{
return bvlc6_address_copy(&BIP6_Broadcast_Addr, addr);
}
@@ -234,7 +234,8 @@ bool bip6_get_broadcast_addr(BACNET_IP6_ADDRESS *addr)
* @return Upon successful completion, returns the number of bytes sent.
* Otherwise, -1 shall be returned and errno set to indicate the error.
*/
int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
int bip6_send_mpdu(
const BACNET_IP6_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
{
struct sockaddr_in6 bvlc_dest = { 0 };
uint16_t addr16[8];
@@ -259,7 +260,7 @@ int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
bvlc_dest.sin6_scope_id = BIP6_Socket_Scope_Id;
debug_print_ipv6("Sending MPDU->", &bvlc_dest.sin6_addr);
/* Send the packet */
return sendto(BIP6_Socket, (char *)mtu, mtu_len, 0,
return sendto(BIP6_Socket, (const char *)mtu, mtu_len, 0,
(struct sockaddr *)&bvlc_dest, sizeof(bvlc_dest));
}
+5 -3
View File
@@ -398,16 +398,18 @@ uint16_t MSTP_Get_Send(struct mstp_port_struct_t *mstp_port, unsigned timeout)
* @param nbytes - number of bytes of data to send
*/
void MSTP_Send_Frame(
struct mstp_port_struct_t *mstp_port, uint8_t *buffer, uint16_t nbytes)
struct mstp_port_struct_t *mstp_port,
const uint8_t *buffer,
uint16_t nbytes)
{
RS485_Send_Frame(mstp_port, buffer, nbytes);
}
static bool dlmstp_compare_data_expecting_reply(
uint8_t *request_pdu,
const uint8_t *request_pdu,
uint16_t request_pdu_len,
uint8_t src_address,
uint8_t *reply_pdu,
const uint8_t *reply_pdu,
uint16_t reply_pdu_len,
uint8_t dest_address)
{
+5 -3
View File
@@ -379,16 +379,18 @@ uint16_t MSTP_Get_Send(struct mstp_port_struct_t *mstp_port, unsigned timeout)
* @param nbytes - number of bytes of data to send
*/
void MSTP_Send_Frame(
struct mstp_port_struct_t *mstp_port, uint8_t *buffer, uint16_t nbytes)
struct mstp_port_struct_t *mstp_port,
const uint8_t *buffer,
uint16_t nbytes)
{
RS485_Send_Frame(mstp_port, buffer, nbytes);
}
static bool dlmstp_compare_data_expecting_reply(
uint8_t *request_pdu,
const uint8_t *request_pdu,
uint16_t request_pdu_len,
uint8_t src_address,
uint8_t *reply_pdu,
const uint8_t *reply_pdu,
uint16_t reply_pdu_len,
uint8_t dest_address)
{
+3 -3
View File
@@ -64,7 +64,7 @@ int setNonblocking(
#endif
/* opens an 802.2 socket to receive and send packets */
static int ethernet_bind(struct sockaddr *eth_addr, char *interface_name)
static int ethernet_bind(struct sockaddr *eth_addr, const char *interface_name)
{
int sock_fd = -1; /* return value */
#if 0
@@ -339,7 +339,7 @@ uint16_t ethernet_receive(BACNET_ADDRESS *src, /* source address */
return pdu_len;
}
void ethernet_set_my_address(BACNET_ADDRESS *my_address)
void ethernet_set_my_address(const BACNET_ADDRESS *my_address)
{
int i = 0;
@@ -387,7 +387,7 @@ void ethernet_get_broadcast_address(BACNET_ADDRESS *dest)
return;
}
void ethernet_debug_address(const char *info, BACNET_ADDRESS *dest)
void ethernet_debug_address(const char *info, const BACNET_ADDRESS *dest)
{
int i = 0; /* counter */
+2 -2
View File
@@ -84,7 +84,7 @@ uint16_t MSTP_Get_Send(
*/
void MSTP_Send_Frame(
struct mstp_port_struct_t *mstp_port,
uint8_t * buffer,
const uint8_t * buffer,
uint16_t nbytes)
{
(void)mstp_port;
@@ -141,7 +141,7 @@ static int network_init(const char *name, int protocol)
}
static void snap_received_packet(
struct mstp_port_struct_t *mstp_port, int sockfd)
const struct mstp_port_struct_t *mstp_port, int sockfd)
{
uint16_t mtu_len = 0; /* number of octets of packet saved in file */
unsigned i = 0; /* counter */
+2 -2
View File
@@ -355,14 +355,14 @@ bool RS485_Set_Baud_Rate(uint32_t baud)
*****************************************************************************/
void RS485_Send_Frame(
struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes)
{ /* number of bytes of data (up to 501) */
uint32_t turnaround_time = Tturnaround * 1000;
uint32_t baud;
ssize_t written = 0;
int greska;
SHARED_MSTP_DATA *poSharedData = NULL;
const SHARED_MSTP_DATA *poSharedData = NULL;
if (mstp_port) {
poSharedData = (SHARED_MSTP_DATA *)mstp_port->UserData;
+1 -1
View File
@@ -29,7 +29,7 @@ extern "C" {
BACNET_STACK_EXPORT
void RS485_Send_Frame(
struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
const uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes); /* number of bytes of data (up to 501) */
BACNET_STACK_EXPORT
+5 -5
View File
@@ -67,7 +67,7 @@ uint32_t bip_stats_drop(void)
* @param addr - network IPv4 address
* @return true if the address is set
*/
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
bool bip_set_addr(const BACNET_IP_ADDRESS *addr)
{
return bvlc_address_copy(&BIP_Address, addr);
}
@@ -87,7 +87,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
* @param network IPv4 broadcast address
* @return true if the broadcast address is retrieved
*/
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
bool bip_set_broadcast_addr(const BACNET_IP_ADDRESS *addr)
{
return bvlc_address_copy(&BIP_Broadcast_Address, addr);
}
@@ -137,7 +137,7 @@ uint16_t bip_get_port(void)
* @param address - IPv4 address from LwIP
* @param mac - IP address from BACnet/IP
*/
static void bip_mac_to_addr(ip4_addr_t *address, uint8_t *mac)
static void bip_mac_to_addr(ip4_addr_t *address, const uint8_t *mac)
{
if (mac && address) {
address->addr = ((u32_t)((((uint32_t)mac[0]) << 24) & 0xff000000));
@@ -153,7 +153,7 @@ static void bip_mac_to_addr(ip4_addr_t *address, uint8_t *mac)
* @param address - IPv4 address from LwIP
* @param port - IPv4 UDP port number
*/
static int bip_decode_bip_address(BACNET_IP_ADDRESS *baddr,
static int bip_decode_bip_address(const BACNET_IP_ADDRESS *baddr,
ip_addr_t *address,
uint16_t *port)
{
@@ -215,7 +215,7 @@ static int bip_encode_bip_address(BACNET_IP_ADDRESS *baddr,
* @return number of bytes sent, or 0 on failure.
*/
int bip_send_mpdu(
BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
const BACNET_IP_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
{
struct pbuf *pkt = NULL;
/* addr and port in host format */
+3 -3
View File
@@ -118,7 +118,7 @@
x++; \
}
bool MSTP_Line_Active(volatile struct mstp_port_struct_t *mstp_port)
bool MSTP_Line_Active(const volatile struct mstp_port_struct_t *mstp_port)
{
return (mstp_port->EventCount > Nmin_octets);
}
@@ -128,7 +128,7 @@ unsigned MSTP_Create_Frame(uint8_t *buffer, /* where frame is loaded */
uint8_t frame_type, /* type of frame to send - see defines */
uint8_t destination, /* destination address */
uint8_t source, /* source address */
uint8_t *data, /* any data to be sent - may be null */
const uint8_t *data, /* any data to be sent - may be null */
unsigned data_len)
{ /* number of bytes of data (up to 501) */
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
@@ -181,7 +181,7 @@ void MSTP_Create_And_Send_Frame(
uint8_t frame_type, /* type of frame to send - see defines */
uint8_t destination, /* destination address */
uint8_t source, /* source address */
uint8_t *data, /* any data to be sent - may be null */
const uint8_t *data, /* any data to be sent - may be null */
unsigned data_len)
{ /* number of bytes of data (up to 501) */
uint8_t buffer[DLMSTP_MPDU_MAX] = { 0 }; /* buffer for sending */
+2 -2
View File
@@ -142,7 +142,7 @@ extern "C" {
/* returns true if line is active */
bool MSTP_Line_Active(
volatile struct mstp_port_struct_t *mstp_port);
const volatile struct mstp_port_struct_t *mstp_port);
unsigned MSTP_Create_Frame(
uint8_t * buffer, /* where frame is loaded */
@@ -150,7 +150,7 @@ extern "C" {
uint8_t frame_type, /* type of frame to send - see defines */
uint8_t destination, /* destination address */
uint8_t source, /* source address */
uint8_t * data, /* any data to be sent - may be null */
const uint8_t * data, /* any data to be sent - may be null */
unsigned data_len); /* number of bytes of data (up to 501) */
+1 -1
View File
@@ -42,7 +42,7 @@ volatile uint8_t RS485_Tx_Buffer[NEXT_POWER_OF_2(DLMSTP_MPDU_MAX)];
*****************************************************************************/
void RS485_Send_Frame(
volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes)
{ /* number of bytes of data (up to 501) */
uint16_t i = 0; /* loop counter */
+1 -1
View File
@@ -28,7 +28,7 @@ extern "C" {
void RS485_Send_Frame(
volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
const uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes); /* number of bytes of data (up to 501) */
/* returns true if there is more data waiting */
+5 -5
View File
@@ -118,17 +118,17 @@
x++; \
}
bool MSTP_Line_Active(volatile struct mstp_port_struct_t *mstp_port)
bool MSTP_Line_Active(const volatile struct mstp_port_struct_t *mstp_port)
{
return (mstp_port->EventCount > Nmin_octets);
}
unsigned MSTP_Create_Frame(uint8_t *buffer, /* where frame is loaded */
unsigned buffer_len, /* amount of space available */
uint8_t frame_type, /* type of frame to send - see defines */
uint8_t frame_type, /* type of frame to send - see defines */
uint8_t destination, /* destination address */
uint8_t source, /* source address */
uint8_t *data, /* any data to be sent - may be null */
uint8_t source, /* source address */
const uint8_t *data, /* any data to be sent - may be null */
unsigned data_len)
{ /* number of bytes of data (up to 501) */
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
@@ -181,7 +181,7 @@ void MSTP_Create_And_Send_Frame(
uint8_t frame_type, /* type of frame to send - see defines */
uint8_t destination, /* destination address */
uint8_t source, /* source address */
uint8_t *data, /* any data to be sent - may be null */
const uint8_t *data, /* any data to be sent - may be null */
unsigned data_len)
{ /* number of bytes of data (up to 501) */
uint8_t buffer[DLMSTP_MPDU_MAX] = { 0 }; /* buffer for sending */
+3 -3
View File
@@ -142,15 +142,15 @@ extern "C" {
/* returns true if line is active */
bool MSTP_Line_Active(
volatile struct mstp_port_struct_t *mstp_port);
const volatile struct mstp_port_struct_t *mstp_port);
unsigned MSTP_Create_Frame(
uint8_t * buffer, /* where frame is loaded */
unsigned buffer_len, /* amount of space available */
uint8_t frame_type, /* type of frame to send - see defines */
uint8_t destination, /* destination address */
uint8_t source, /* source address */
uint8_t * data, /* any data to be sent - may be null */
uint8_t source, /* source address */
const uint8_t * data, /* any data to be sent - may be null */
unsigned data_len); /* number of bytes of data (up to 501) */
+1 -1
View File
@@ -42,7 +42,7 @@ volatile uint8_t RS485_Tx_Buffer[NEXT_POWER_OF_2(DLMSTP_MPDU_MAX)];
*****************************************************************************/
void RS485_Send_Frame(
volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes)
{ /* number of bytes of data (up to 501) */
uint16_t i = 0; /* loop counter */
+2 -2
View File
@@ -28,8 +28,8 @@ extern "C" {
void RS485_Send_Frame(
volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes); /* number of bytes of data (up to 501) */
const uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes); /* number of bytes of data (up to 501) */
/* returns true if there is more data waiting */
bool RS485_Check_UART_Data(
+3 -2
View File
@@ -107,11 +107,12 @@ static struct my_object_functions *Device_Objects_Find_Functions(
}
static int Read_Property_Common(
struct my_object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
const struct my_object_functions *pObject,
BACNET_READ_PROPERTY_DATA *rpdata)
{
int apdu_len = BACNET_STATUS_ERROR;
BACNET_CHARACTER_STRING char_string;
char *pString = "";
const char *pString = "";
uint8_t *apdu = NULL;
#if (BACNET_PROTOCOL_REVISION >= 14)
struct special_property_list_t property_list;
+1 -1
View File
@@ -174,7 +174,7 @@ uint16_t ethernet_receive(BACNET_ADDRESS *src, /* source address */
return pdu_len;
}
void ethernet_set_my_address(BACNET_ADDRESS *my_address)
void ethernet_set_my_address(const BACNET_ADDRESS *my_address)
{
int i = 0;
+4 -3
View File
@@ -103,7 +103,8 @@ static struct my_object_functions *Device_Objects_Find_Functions(
}
static int Read_Property_Common(
struct my_object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
const struct my_object_functions *pObject,
BACNET_READ_PROPERTY_DATA *rpdata)
{
int apdu_len = BACNET_STATUS_ERROR;
BACNET_CHARACTER_STRING char_string;
@@ -308,7 +309,7 @@ bool Device_Object_Name(
return status;
}
bool Device_Set_Object_Name(BACNET_CHARACTER_STRING *object_name)
bool Device_Set_Object_Name(const BACNET_CHARACTER_STRING *object_name)
{
bool status = false; /*return value */
@@ -588,7 +589,7 @@ int Device_Object_List_Element_Encode(
return apdu_len;
}
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
BACNET_OBJECT_TYPE *object_type,
uint32_t *object_instance)
{
+1 -1
View File
@@ -294,7 +294,7 @@ bool Network_Port_MAC_Address(
* @return true if object-name was set
*/
bool Network_Port_MAC_Address_Set(
uint32_t object_instance, uint8_t *mac_src, uint8_t mac_len)
uint32_t object_instance, const uint8_t *mac_src, uint8_t mac_len)
{
if (mac_len == 1) {
Object_List[0].MAC_Address[0] = mac_src[0];
+1 -1
View File
@@ -152,7 +152,7 @@ bool rs485_frame_sent(void)
* @param nbytes - number of bytes to transmit
* @return true if added to queue
*/
void rs485_bytes_send(uint8_t *buffer, /* data to send */
void rs485_bytes_send(const uint8_t *buffer, /* data to send */
uint16_t nbytes)
{ /* number of bytes of data */
uint8_t tx_byte;
+1 -1
View File
@@ -30,7 +30,7 @@ extern "C" {
bool rs485_receive_error(
void);
void rs485_bytes_send(
uint8_t * buffer,
const uint8_t * buffer,
uint16_t nbytes);
uint32_t rs485_baud_rate(
+5 -4
View File
@@ -345,7 +345,7 @@ bool Device_Object_Name(
return status;
}
bool Device_Set_Object_Name(BACNET_CHARACTER_STRING *object_name)
bool Device_Set_Object_Name(const BACNET_CHARACTER_STRING *object_name)
{
bool status = false; /*return value */
@@ -478,7 +478,7 @@ void Device_UUID_Init(void)
* @param new_uuid [in] The new UUID to set
* @param length [in] The length of the new UUID
*/
void Device_UUID_Set(uint8_t *new_uuid, size_t length)
void Device_UUID_Set(const uint8_t *new_uuid, size_t length)
{
if (new_uuid && (length == sizeof(Device_UUID))) {
memcpy(Device_UUID, new_uuid, sizeof(Device_UUID));
@@ -603,7 +603,7 @@ int Device_Object_List_Element_Encode(
* Object.
* @return True on success or else False if not found.
*/
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
BACNET_OBJECT_TYPE *object_type,
uint32_t *object_instance)
{
@@ -842,7 +842,8 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
* @return The length of the APDU on success, else BACNET_STATUS_ERROR
*/
static int Read_Property_Common(
struct my_object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
const struct my_object_functions *pObject,
BACNET_READ_PROPERTY_DATA *rpdata)
{
int apdu_len = BACNET_STATUS_ERROR;
BACNET_CHARACTER_STRING char_string;
+1 -1
View File
@@ -299,7 +299,7 @@ bool Network_Port_MAC_Address(
* @return true if object-name was set
*/
bool Network_Port_MAC_Address_Set(
uint32_t object_instance, uint8_t *mac_src, uint8_t mac_len)
uint32_t object_instance, const uint8_t *mac_src, uint8_t mac_len)
{
if (mac_len == 1) {
Object_List[0].MAC_Address[0] = mac_src[0];
+1 -1
View File
@@ -209,7 +209,7 @@ bool rs485_byte_available(uint8_t *data_register)
* @param nbytes - number of bytes to transmit
* @return true if added to queue
*/
void rs485_bytes_send(uint8_t *buffer, uint16_t nbytes)
void rs485_bytes_send(const uint8_t *buffer, uint16_t nbytes)
{
if (buffer && (nbytes > 0)) {
if (FIFO_Add(&Transmit_Queue, buffer, nbytes)) {
+1 -1
View File
@@ -20,7 +20,7 @@ bool rs485_rts_enabled(void);
bool rs485_byte_available(uint8_t *data_register);
bool rs485_receive_error(void);
void rs485_bytes_send(uint8_t *buffer, uint16_t nbytes);
void rs485_bytes_send(const uint8_t *buffer, uint16_t nbytes);
uint32_t rs485_baud_rate(void);
bool rs485_baud_rate_set(uint32_t baud);
+7 -6
View File
@@ -317,7 +317,7 @@ void bip_get_broadcast_address(BACNET_ADDRESS *dest)
*
* @param addr - network IPv4 address
*/
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
bool bip_set_addr(const BACNET_IP_ADDRESS *addr)
{
(void)addr;
/* not something we do here within this application */
@@ -344,7 +344,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
* @param addr - network IPv4 address
* @return true if the address was set
*/
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
bool bip_set_broadcast_addr(const BACNET_IP_ADDRESS *addr)
{
(void)addr;
/* not something we do within this application */
@@ -412,7 +412,8 @@ uint8_t bip_get_subnet_prefix(void)
* @return Upon successful completion, returns the number of bytes sent.
* Otherwise, -1 shall be returned and errno set to indicate the error.
*/
int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
int bip_send_mpdu(
const BACNET_IP_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
{
struct sockaddr_in bip_dest = { 0 };
int rv = 0;
@@ -432,7 +433,7 @@ int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
/* Send the packet */
debug_print_ipv4(
"Sending MPDU->", &bip_dest.sin_addr, bip_dest.sin_port, mtu_len);
rv = sendto(BIP_Socket, (char *)mtu, mtu_len, 0,
rv = sendto(BIP_Socket, (const char *)mtu, mtu_len, 0,
(struct sockaddr *)&bip_dest, sizeof(struct sockaddr));
if (rv == SOCKET_ERROR) {
print_last_error("sendto");
@@ -737,7 +738,7 @@ static void set_broadcast_address(uint32_t net_address)
* @param ifname [in] The named interface to use for the network layer.
* Eg, for Windows, ifname is the dotted ip address of the interface
*/
void bip_set_interface(char *ifname)
void bip_set_interface(const char *ifname)
{
/* setup local address */
if (BIP_Address.s_addr == 0) {
@@ -754,7 +755,7 @@ void bip_set_interface(char *ifname)
}
}
static SOCKET createSocket(struct sockaddr_in *sin)
static SOCKET createSocket(const struct sockaddr_in *sin)
{
int rv = 0; /* return from socket lib calls */
int value = 1;
+9 -9
View File
@@ -290,7 +290,7 @@ void bip6_get_my_address(BACNET_ADDRESS *addr)
*
* @param addr - network IPv6 address
*/
bool bip6_set_addr(BACNET_IP6_ADDRESS *addr)
bool bip6_set_addr(const BACNET_IP6_ADDRESS *addr)
{
return bvlc6_address_copy(&BIP6_Addr, addr);
}
@@ -312,7 +312,7 @@ bool bip6_get_addr(BACNET_IP6_ADDRESS *addr)
*
* @return true if the BACnet/IPv6 address matches our own address
*/
bool bip6_address_match_self(BACNET_IP6_ADDRESS *addr)
bool bip6_address_match_self(const BACNET_IP6_ADDRESS *addr)
{
return !bvlc6_address_different(addr, &BIP6_Addr);
}
@@ -322,7 +322,7 @@ bool bip6_address_match_self(BACNET_IP6_ADDRESS *addr)
*
* @param addr - network IPv6 address
*/
bool bip6_set_broadcast_addr(BACNET_IP6_ADDRESS *addr)
bool bip6_set_broadcast_addr(const BACNET_IP6_ADDRESS *addr)
{
return bvlc6_address_copy(&BIP6_Broadcast_Addr, addr);
}
@@ -348,7 +348,7 @@ bool bip6_get_broadcast_addr(BACNET_IP6_ADDRESS *addr)
* @return Upon successful completion, returns the number of bytes sent.
* Otherwise, -1 shall be returned and errno set to indicate the error.
*/
int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
int bip6_send_mpdu(const BACNET_IP6_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
{
struct sockaddr_in6 bvlc_dest = { 0 };
uint16_t addr16[8];
@@ -375,8 +375,8 @@ int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
debug_print_ipv6("Sending MPDU->", &bvlc_dest.sin6_addr);
/* Send the packet */
return sendto(
BIP6_Socket, (char *)mtu, mtu_len, 0, (struct sockaddr *)&bvlc_dest,
sizeof(bvlc_dest));
BIP6_Socket, (const char *)mtu, mtu_len, 0,
(const struct sockaddr *)&bvlc_dest, sizeof(bvlc_dest));
}
/**
@@ -392,9 +392,9 @@ int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
* Otherwise, -1 shall be returned and errno set to indicate the error.
*/
int bip6_send_pdu(
BACNET_ADDRESS *dest,
BACNET_NPDU_DATA *npdu_data,
uint8_t *pdu,
const BACNET_ADDRESS *dest,
const BACNET_NPDU_DATA *npdu_data,
const uint8_t *pdu,
unsigned pdu_len)
{
return bvlc6_send_pdu(dest, npdu_data, pdu, pdu_len);
+1 -2
View File
@@ -101,8 +101,7 @@ int gettimeofday(struct timeval *tp, void *tzp)
* @param utc - True for UTC sync, False for Local time
* @return True if time is set
*/
void datetime_timesync(
BACNET_DATE *bdate, BACNET_TIME *btime, bool utc)
void datetime_timesync(BACNET_DATE *bdate, BACNET_TIME *btime, bool utc)
{
(void)bdate;
(void)btime;
+4 -4
View File
@@ -291,18 +291,18 @@ uint16_t MSTP_Get_Send(
*/
void MSTP_Send_Frame(
struct mstp_port_struct_t *mstp_port,
uint8_t * buffer,
const uint8_t * buffer,
uint16_t nbytes)
{
RS485_Send_Frame(mstp_port, buffer, nbytes);
}
bool dlmstp_compare_data_expecting_reply(uint8_t *request_pdu,
bool dlmstp_compare_data_expecting_reply(const uint8_t *request_pdu,
uint16_t request_pdu_len,
uint8_t src_address,
uint8_t *reply_pdu,
const uint8_t *reply_pdu,
uint16_t reply_pdu_len,
BACNET_ADDRESS *dest_address)
const BACNET_ADDRESS *dest_address)
{
uint16_t offset;
/* One way to check the message is to compare NPDU
+4 -4
View File
@@ -277,18 +277,18 @@ uint16_t MSTP_Get_Send(
*/
void MSTP_Send_Frame(
struct mstp_port_struct_t *mstp_port,
uint8_t * buffer,
const uint8_t * buffer,
uint16_t nbytes)
{
RS485_Send_Frame(mstp_port, buffer, nbytes);
}
static bool dlmstp_compare_data_expecting_reply(uint8_t *request_pdu,
static bool dlmstp_compare_data_expecting_reply(const uint8_t *request_pdu,
uint16_t request_pdu_len,
uint8_t src_address,
uint8_t *reply_pdu,
const uint8_t *reply_pdu,
uint16_t reply_pdu_len,
BACNET_ADDRESS *dest_address)
const BACNET_ADDRESS *dest_address)
{
uint16_t offset;
/* One way to check the message is to compare NPDU
+2 -2
View File
@@ -352,7 +352,7 @@ uint16_t ethernet_receive(
return pdu_len;
}
void ethernet_set_my_address(BACNET_ADDRESS *my_address)
void ethernet_set_my_address(const BACNET_ADDRESS *my_address)
{
int i = 0;
@@ -400,7 +400,7 @@ void ethernet_get_broadcast_address(BACNET_ADDRESS *dest)
return;
}
void ethernet_debug_address(const char *info, BACNET_ADDRESS *dest)
void ethernet_debug_address(const char *info, const BACNET_ADDRESS *dest)
{
int i = 0; /* counter */
char msg[200];
+1 -1
View File
@@ -397,7 +397,7 @@ bool RS485_Set_Baud_Rate(uint32_t baud)
/* Transmits a Frame on the wire */
void RS485_Send_Frame(
struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes)
{ /* number of bytes of data (up to 501) */
DWORD dwWritten = 0;
+2 -2
View File
@@ -30,8 +30,8 @@ extern "C" {
BACNET_STACK_EXPORT
void RS485_Send_Frame(
struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes); /* number of bytes of data (up to 501) */
const uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes); /* number of bytes of data (up to 501) */
BACNET_STACK_EXPORT
void RS485_Check_UART_Data(
+11 -9
View File
@@ -21,7 +21,7 @@
* RETURN: true if valid
* NOTES: none
**************************************************************************/
static bool bacnet_name_isvalid(uint8_t encoding, uint8_t length, char *str)
static bool bacnet_name_isvalid(uint8_t encoding, uint8_t length, const char *str)
{
bool valid = false;
@@ -82,7 +82,7 @@ int bacnet_name_copy(uint16_t offset, uint8_t *dest, uint8_t dest_len)
uint8_t bacnet_name_encode(uint8_t *buffer,
uint8_t buffer_len,
uint8_t encoding,
char *str,
const char *str,
uint8_t str_len)
{
unsigned len = 0;
@@ -110,7 +110,7 @@ uint8_t bacnet_name_encode(uint8_t *buffer,
* NOTES: none
**************************************************************************/
bool bacnet_name_save(
uint16_t offset, uint8_t encoding, char *str, uint8_t str_len)
uint16_t offset, uint8_t encoding, const char *str, uint8_t str_len)
{
uint8_t buffer[NVM_NAME_SIZE] = { 0 };
uint8_t length = 0;
@@ -127,11 +127,11 @@ bool bacnet_name_save(
return false;
}
bool bacnet_name_set(uint16_t offset, BACNET_CHARACTER_STRING *char_string)
bool bacnet_name_set(uint16_t offset, const BACNET_CHARACTER_STRING *char_string)
{
uint8_t encoding = 0;
uint8_t length = 0;
char *str = NULL;
const char *str = NULL;
length = characterstring_length(char_string);
encoding = characterstring_encoding(char_string);
@@ -142,7 +142,7 @@ bool bacnet_name_set(uint16_t offset, BACNET_CHARACTER_STRING *char_string)
bool bacnet_name_write_unique(uint16_t offset,
int object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING *char_string,
const BACNET_CHARACTER_STRING *char_string,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
{
@@ -192,7 +192,7 @@ bool bacnet_name_write_unique(uint16_t offset,
/* no required minumum length or duplicate checking */
bool bacnet_name_write(uint16_t offset,
BACNET_CHARACTER_STRING *char_string,
const BACNET_CHARACTER_STRING *char_string,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
{
@@ -221,14 +221,16 @@ bool bacnet_name_write(uint16_t offset,
return status;
}
void bacnet_name_init(uint16_t offset, char *default_string)
void bacnet_name_init(uint16_t offset, const char *default_string)
{
(void)bacnet_name_save(
offset, CHARACTER_UTF8, default_string, strlen(default_string));
}
void bacnet_name(
uint16_t offset, BACNET_CHARACTER_STRING *char_string, char *default_string)
uint16_t offset,
BACNET_CHARACTER_STRING *char_string,
const char *default_string)
{
uint8_t encoding = 0;
uint8_t length = 0;
+7 -7
View File
@@ -21,36 +21,36 @@ extern "C" {
uint8_t dest_len);
bool bacnet_name_set(
uint16_t eeprom_offset,
BACNET_CHARACTER_STRING * char_string);
const BACNET_CHARACTER_STRING * char_string);
void bacnet_name_init(
uint16_t eeprom_offset,
char *default_string);
const char *default_string);
uint8_t bacnet_name_encode(
uint8_t *buffer,
uint8_t buffer_len,
uint8_t encoding,
char *str,
const char *str,
uint8_t str_len);
bool bacnet_name_save(
uint16_t offset,
uint8_t encoding,
char *str,
const char *str,
uint8_t str_len);
void bacnet_name(
uint16_t eeprom_offset,
BACNET_CHARACTER_STRING * char_string,
char *default_string);
const char *default_string);
bool bacnet_name_write_unique(
uint16_t offset,
int object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING * char_string,
const BACNET_CHARACTER_STRING * char_string,
BACNET_ERROR_CLASS * error_class,
BACNET_ERROR_CODE * error_code);
/* no required minumum length or duplicate checking */
bool bacnet_name_write(
uint16_t offset,
BACNET_CHARACTER_STRING * char_string,
const BACNET_CHARACTER_STRING * char_string,
BACNET_ERROR_CLASS * error_class,
BACNET_ERROR_CODE * error_code);
+1 -1
View File
@@ -526,7 +526,7 @@ int Device_Object_List_Element_Encode(
return apdu_len;
}
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
BACNET_OBJECT_TYPE *object_type,
uint32_t *object_instance)
{
+1 -1
View File
@@ -288,7 +288,7 @@ bool Network_Port_MAC_Address(
* @return true if object-name was set
*/
bool Network_Port_MAC_Address_Set(
uint32_t object_instance, uint8_t *mac_src, uint8_t mac_len)
uint32_t object_instance, const uint8_t *mac_src, uint8_t mac_len)
{
if (mac_len == 1) {
Object_List[0].MAC_Address[0] = mac_src[0];
+1 -1
View File
@@ -147,7 +147,7 @@ bool rs485_receive_error(void)
* @param buffer - array of one or more bytes to transmit
* @param nbytes - number of bytes to transmit
*/
void rs485_bytes_send(uint8_t *buffer, uint16_t nbytes)
void rs485_bytes_send(const uint8_t *buffer, uint16_t nbytes)
{
bool status = false;
bool start_required = false;
+1 -1
View File
@@ -20,7 +20,7 @@ bool rs485_rts_enabled(void);
bool rs485_byte_available(uint8_t *data_register);
bool rs485_receive_error(void);
void rs485_bytes_send(uint8_t *buffer, uint16_t nbytes);
void rs485_bytes_send(const uint8_t *buffer, uint16_t nbytes);
uint32_t rs485_baud_rate(void);
bool rs485_baud_rate_set(uint32_t baud);
+1 -1
View File
@@ -71,7 +71,7 @@ extern "C" {
BACNET_STACK_EXPORT
void bacnet_ethernet_set_my_address(
BACNET_ADDRESS * my_address);
const BACNET_ADDRESS * my_address);
BACNET_STACK_EXPORT
void bacnet_ethernet_get_my_address(
BACNET_ADDRESS * my_address);
+7 -6
View File
@@ -150,7 +150,7 @@ void bip_get_broadcast_address(BACNET_ADDRESS *dest)
* @param addr - network IPv4 address
* @return true if the address was set
*/
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
bool bip_set_addr(const BACNET_IP_ADDRESS *addr)
{
if (addr) {
memcpy(&BIP_Address.s_addr, &addr->address[0], IP_ADDRESS_MAX);
@@ -180,7 +180,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
* @param addr - network IPv4 address
* @return true if the address was set
*/
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
bool bip_set_broadcast_addr(const BACNET_IP_ADDRESS *addr)
{
if (addr) {
memcpy(&BIP_Broadcast_Addr.s_addr, &addr->address[0], IP_ADDRESS_MAX);
@@ -249,7 +249,8 @@ uint8_t bip_get_subnet_prefix(void)
* @return Upon successful completion, returns the number of bytes sent.
* Otherwise, -1 shall be returned and errno set to indicate the error.
*/
int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
int bip_send_mpdu(
const BACNET_IP_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
{
struct sockaddr_in bip_dest = { 0 };
@@ -267,7 +268,7 @@ int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
/* Send the packet */
debug_print_ipv4(
"Sending MPDU->", &bip_dest.sin_addr, bip_dest.sin_port, mtu_len);
return zsock_sendto(BIP_Socket, (char *)mtu, mtu_len, 0,
return zsock_sendto(BIP_Socket, (const char *)mtu, mtu_len, 0,
(struct sockaddr *)&bip_dest, sizeof(struct sockaddr));
}
@@ -404,7 +405,7 @@ int bip_send_pdu(BACNET_ADDRESS *dest,
* @param ifname [in] The named interface to use for the network layer.
* Eg, for Linux, ifname is eth0, ath0, arc0, and others.
*/
void bip_set_interface(char *ifname)
void bip_set_interface(const char *ifname)
{
struct net_if *iface = 0;
int index = -1;
@@ -492,7 +493,7 @@ void bip_set_interface(char *ifname)
}
}
static int createSocket(struct sockaddr_in *sin)
static int createSocket(const struct sockaddr_in *sin)
{
int sock_fd = -1;
const int sockopt = 1;
+9 -7
View File
@@ -51,7 +51,7 @@ static char ipv6_addr_str[] = "";
* @param a - IPv6 address
* @return Pointer to global string
*/
static char *inet6_ntoa(struct in6_addr *a)
static char *inet6_ntoa(const struct in6_addr *a)
{
#if CONFIG_BACNETSTACK_LOG_LEVEL
uint8_t x = 0;
@@ -226,7 +226,7 @@ void bip6_get_my_address(BACNET_ADDRESS *addr)
*
* @param addr - network IPv6 address
*/
bool bip6_set_addr(BACNET_IP6_ADDRESS *addr)
bool bip6_set_addr(const BACNET_IP6_ADDRESS *addr)
{
return bvlc6_address_copy(&BIP6_Addr, addr);
}
@@ -246,7 +246,7 @@ bool bip6_get_addr(BACNET_IP6_ADDRESS *addr)
*
* @param addr - network IPv6 address
*/
bool bip6_set_broadcast_addr(BACNET_IP6_ADDRESS *addr)
bool bip6_set_broadcast_addr(const BACNET_IP6_ADDRESS *addr)
{
return bvlc6_address_copy(&BIP6_Broadcast_Addr, addr);
}
@@ -272,7 +272,8 @@ bool bip6_get_broadcast_addr(BACNET_IP6_ADDRESS *addr)
* @return Upon successful completion, returns the number of bytes sent.
* Otherwise, -1 shall be returned and errno set to indicate the error.
*/
int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
int bip6_send_mpdu(
const BACNET_IP6_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
{
struct sockaddr_in6 bvlc_dest = { 0 };
uint16_t addr16[8];
@@ -302,8 +303,8 @@ int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
LOG_DBG("BIP6: Sending MPDU to %s", ipv6_addr_str);
/* Send the packet */
return zsock_sendto(
BIP6_Socket, (char *)mtu, mtu_len, 0, (struct sockaddr *)&bvlc_dest,
sizeof(bvlc_dest));
BIP6_Socket, (const char *)mtu, mtu_len, 0,
(struct sockaddr *)&bvlc_dest, sizeof(bvlc_dest));
}
/**
@@ -333,7 +334,8 @@ int bip6_send_pdu(
* @param n - size of the buffer
* @param addr - BACnet/IPv6 address
*/
static int bvlc6_snprintf_addr(char *s, size_t n, BACNET_IP6_ADDRESS *addr)
static int bvlc6_snprintf_addr(
char *s, size_t n, const BACNET_IP6_ADDRESS *addr)
{
uint16_t addr16[8];
+2 -2
View File
@@ -32,8 +32,8 @@ extern "C" {
BACNET_STACK_EXPORT
void RS485_Send_Frame(
volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes); /* number of bytes of data (up to 501) */
const uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes); /* number of bytes of data (up to 501) */
BACNET_STACK_EXPORT
void RS485_Check_UART_Data(