corrected defects
This commit is contained in:
@@ -118,7 +118,7 @@ static int ethernet_bind(struct sockaddr *eth_addr, char *interface_name)
|
||||
strerror(errno));
|
||||
fprintf(stderr,
|
||||
"You might need to add the following to modules.conf\n"
|
||||
"(or in modutils/alias on Debian with update-modules):\n"
|
||||
"(or in /etc/modutils/alias on Debian with update-modules):\n"
|
||||
"alias net-pf-17 af_packet\n"
|
||||
"Also, add af_packet to /etc/modules.\n"
|
||||
"Then follow it by:\n"
|
||||
@@ -141,7 +141,7 @@ static int ethernet_bind(struct sockaddr *eth_addr, char *interface_name)
|
||||
strerror(errno));
|
||||
fprintf(stderr,
|
||||
"You might need to add the following to modules.conf\n"
|
||||
"(or in modutils/alias on Debian with update-modules):\n"
|
||||
"(or in /etc/modutils/alias on Debian with update-modules):\n"
|
||||
"alias net-pf-17 af_packet\n"
|
||||
"Also, add af_packet to /etc/modules.\n"
|
||||
"Then follow it by:\n"
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// buffers used for transmit and receive
|
||||
static uint8_t Tx_Buf[MAX_MPDU] = {0};
|
||||
static uint8_t Rx_Buf[MAX_MPDU] = {0};
|
||||
static uint8_t Temp_Buf[MAX_MPDU] = {0};
|
||||
static uint8_t Temp_Buf[MAX_APDU] = {0};
|
||||
|
||||
// flag to send an I-Am
|
||||
bool I_Am_Request = true;
|
||||
@@ -66,17 +66,15 @@ void Send_IAm(void)
|
||||
{
|
||||
int pdu_len = 0;
|
||||
BACNET_ADDRESS dest;
|
||||
BACNET_ADDRESS src;
|
||||
|
||||
// I-Am is a global broadcast
|
||||
ethernet_set_broadcast_address(&dest);
|
||||
ethernet_get_my_address(&src);
|
||||
|
||||
// encode the NPDU portion of the packet
|
||||
pdu_len = npdu_encode_apdu(
|
||||
&Tx_Buf[0],
|
||||
&dest,
|
||||
&src,
|
||||
NULL,
|
||||
false, // true for confirmed messages
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
@@ -135,6 +133,7 @@ void ReadPropertyHandler(
|
||||
uint32_t object_instance;
|
||||
BACNET_PROPERTY_ID object_property;
|
||||
int32_t array_index;
|
||||
BACNET_ADDRESS my_address;
|
||||
|
||||
fprintf(stderr,"Received Read-Property Request!\n");
|
||||
len = rp_decode_service_request(
|
||||
@@ -144,11 +143,20 @@ void ReadPropertyHandler(
|
||||
&object_instance,
|
||||
&object_property,
|
||||
&array_index);
|
||||
// prepare a reply
|
||||
ethernet_get_my_address(&my_address);
|
||||
// encode the NPDU portion of the packet
|
||||
pdu_len = npdu_encode_apdu(
|
||||
&Tx_Buf[0],
|
||||
src,
|
||||
&my_address,
|
||||
false, // true for confirmed messages
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
// bad encoding - send an abort
|
||||
if (len == -1)
|
||||
{
|
||||
pdu_len = abort_encode_apdu(
|
||||
&Tx_Buf[0],
|
||||
pdu_len += abort_encode_apdu(
|
||||
&Tx_Buf[pdu_len],
|
||||
service_data->invoke_id,
|
||||
ABORT_REASON_OTHER);
|
||||
(void)ethernet_send_pdu(
|
||||
@@ -159,8 +167,8 @@ void ReadPropertyHandler(
|
||||
}
|
||||
else if (service_data->segmented_message)
|
||||
{
|
||||
pdu_len = abort_encode_apdu(
|
||||
&Tx_Buf[0],
|
||||
pdu_len += abort_encode_apdu(
|
||||
&Tx_Buf[pdu_len],
|
||||
service_data->invoke_id,
|
||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED);
|
||||
(void)ethernet_send_pdu(
|
||||
@@ -181,6 +189,7 @@ void ReadPropertyHandler(
|
||||
array_index);
|
||||
if (len > 0)
|
||||
{
|
||||
// encode the APDU portion of the packet
|
||||
rp_data.object_type = object_type;
|
||||
rp_data.object_instance = object_instance;
|
||||
rp_data.object_property = object_property;
|
||||
@@ -188,8 +197,8 @@ void ReadPropertyHandler(
|
||||
rp_data.application_data = &Temp_Buf[0];
|
||||
rp_data.application_data_len = len;
|
||||
// FIXME: probably need a length limitation sent with encode
|
||||
pdu_len = rp_ack_encode_apdu(
|
||||
&Tx_Buf[0],
|
||||
pdu_len += rp_ack_encode_apdu(
|
||||
&Tx_Buf[pdu_len],
|
||||
service_data->invoke_id,
|
||||
&rp_data);
|
||||
(void)ethernet_send_pdu(
|
||||
@@ -200,8 +209,8 @@ void ReadPropertyHandler(
|
||||
}
|
||||
else
|
||||
{
|
||||
pdu_len = bacerror_encode_apdu(
|
||||
&Tx_Buf[0],
|
||||
pdu_len += bacerror_encode_apdu(
|
||||
&Tx_Buf[pdu_len],
|
||||
service_data->invoke_id,
|
||||
SERVICE_CONFIRMED_READ_PROPERTY,
|
||||
ERROR_CLASS_PROPERTY,
|
||||
@@ -214,8 +223,8 @@ void ReadPropertyHandler(
|
||||
}
|
||||
break;
|
||||
default:
|
||||
pdu_len = bacerror_encode_apdu(
|
||||
&Tx_Buf[0],
|
||||
pdu_len += bacerror_encode_apdu(
|
||||
&Tx_Buf[pdu_len],
|
||||
service_data->invoke_id,
|
||||
SERVICE_CONFIRMED_READ_PROPERTY,
|
||||
ERROR_CLASS_OBJECT,
|
||||
|
||||
Reference in New Issue
Block a user