make pretty

This commit is contained in:
Steve Karg
2022-09-10 10:32:50 -05:00
parent 7cdab61d72
commit cc4911a185
123 changed files with 1387 additions and 1604 deletions
+7 -6
View File
@@ -90,7 +90,7 @@ void *dl_ip_thread(void *pArgs)
&address.mac[0], &msg_data->dest.adr[0], MAX_MAC_LEN);
dl_ip_send(
&ip_data, &address, msg_data->pdu, msg_data->pdu_len);
&ip_data, &address, msg_data->pdu, msg_data->pdu_len);
check_data(msg_data);
@@ -181,15 +181,16 @@ bool dl_ip_init(ROUTER_PORT *port, IP_DATA *ip_data)
/* Bind to device so we don't get routing loops between our
different ports. */
status = setsockopt(ip_data->socket, SOL_SOCKET, SO_BINDTODEVICE,
port->iface, strlen(port->iface));
port->iface, strlen(port->iface));
if (status < 0) {
close(ip_data->socket);
return false;
close(ip_data->socket);
return false;
}
/* bind the socket to the local port number */
sin.sin_family = AF_INET;
/* sin.sin_addr.s_addr, ip_data->local_addr.s_addr;// = htonl(INADDR_ANY); */
/* sin.sin_addr.s_addr, ip_data->local_addr.s_addr;// =
* htonl(INADDR_ANY); */
sin.sin_addr.s_addr = htonl(INADDR_ANY);
sin.sin_port = ip_data->port;
@@ -309,7 +310,7 @@ int dl_ip_recv(
/* the signature of a BACnet/IP packet */
if (data->buff[0] != BVLL_TYPE_BACNET_IP) {
return 0;
}
}
switch (data->buff[1]) {
case BVLC_ORIGINAL_UNICAST_NPDU:
+4 -4
View File
@@ -272,7 +272,7 @@ bool read_config(char *filepath)
result = config_setting_lookup_string(port, "device", &iface);
if (result) {
current->iface =
(char *)calloc(sizeof(char), strlen(iface) + 1);
(char *)calloc(sizeof(char), strlen(iface) + 1);
strcpy(current->iface, iface);
/* check if interface is valid */
@@ -314,7 +314,7 @@ bool read_config(char *filepath)
result = config_setting_lookup_string(port, "device", &iface);
if (result) {
current->iface =
(char *)calloc(sizeof(char), strlen(iface) + 1);
(char *)calloc(sizeof(char), strlen(iface) + 1);
strcpy(current->iface, iface);
/* check if interface is valid */
@@ -569,7 +569,7 @@ bool parse_cmd(int argc, char *argv[])
current->route_info.mac[0]) {
current->params.mstp_params.max_master =
current->route_info.mac[0];
}
}
if (argv[optind + 1][0] != '-') {
current->params.mstp_params.max_frames =
@@ -781,7 +781,7 @@ uint16_t process_msg(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
if (addr.net > 0 && addr.net < BACNET_BROADCAST_NETWORK &&
data->src.net != addr.net) {
memmove(&data->src, &addr, sizeof(BACNET_ADDRESS));
}
}
/* encode both source and destination for broadcast and router-to-router
* communication */
+1 -2
View File
@@ -62,8 +62,7 @@ BACMSG *recv_from_msgbox(MSGBOX_ID src, BACMSG *msg, int flags)
{
int recv_bytes;
recv_bytes =
msgrcv(src, msg, sizeof(BACMSG) - sizeof(MSGTYPE), 0, flags);
recv_bytes = msgrcv(src, msg, sizeof(BACMSG) - sizeof(MSGTYPE), 0, flags);
if (recv_bytes > 0) {
return msg;
} else {
+2 -2
View File
@@ -85,7 +85,7 @@ void *dl_mstp_thread(void *pArgs)
if (port->params.mstp_params.stopbits == 2) {
shared_port_data.RS485MOD |= CSTOPB;
}
}
mstp_port.UserData = (void *)&shared_port_data;
dlmstp_set_baud_rate(&mstp_port, port->params.mstp_params.baudrate);
@@ -94,7 +94,7 @@ void *dl_mstp_thread(void *pArgs)
dlmstp_set_max_master(&mstp_port, port->params.mstp_params.max_master);
if (!dlmstp_init(&mstp_port, port->iface)) {
printf("MSTP %s init failed. Stop.\n", port->iface);
}
}
port->port_id = create_msgbox();
if (port->port_id == INVALID_MSGBOX_ID) {
+5 -5
View File
@@ -133,14 +133,14 @@ uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
i = data->pdu[apdu_offset + i + 3] + 4;
} else {
i = i + 4;
}
}
}
buff_len = create_network_message(
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, NULL);
} else {
buff_len = create_network_message(
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, &buff);
}
}
break;
case NETWORK_MESSAGE_INIT_RT_TABLE_ACK:
@@ -158,7 +158,7 @@ uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
i = data->pdu[apdu_offset + i + 3] + 4;
} else {
i = i + 4;
}
}
}
}
break;
@@ -207,7 +207,7 @@ uint16_t create_network_message(
if (network_message_type == NETWORK_MESSAGE_INIT_RT_TABLE) {
data_expecting_reply = true;
}
}
init_npdu(&npdu_data, network_message_type, data_expecting_reply);
*buff = (uint8_t *)malloc(128); /* resolve different length */
@@ -282,7 +282,7 @@ uint16_t create_network_message(
}
} else {
(*buff)[buff_len++] = (uint8_t)0;
}
}
break;
case NETWORK_MESSAGE_INVALID:
+2 -2
View File
@@ -53,14 +53,14 @@ ROUTER_PORT *find_dnet(uint16_t net, BACNET_ADDRESS *addr)
/* for broadcast messages no search is needed */
if (net == BACNET_BROADCAST_NETWORK) {
return port;
}
}
while (port != NULL) {
/* check if DNET is directly connected to the router */
if (net == port->route_info.net) {
return port;
/* else search router ports DNET list */
/* else search router ports DNET list */
} else if (port->route_info.dnets) {
dnet = port->route_info.dnets;
while (dnet != NULL) {