mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-12 02:23:47 +08:00
minor: coding style fixes
This commit is contained in:
@@ -126,10 +126,10 @@ const struct snmp_obj_id* snmp_get_device_enterprise_oid(void)
|
||||
u8_t
|
||||
snmp_oid_to_ip4(const u32_t *oid, ip4_addr_t *ip)
|
||||
{
|
||||
if((oid[0] > 0xFF) ||
|
||||
(oid[1] > 0xFF) ||
|
||||
(oid[2] > 0xFF) ||
|
||||
(oid[3] > 0xFF)) {
|
||||
if ((oid[0] > 0xFF) ||
|
||||
(oid[1] > 0xFF) ||
|
||||
(oid[2] > 0xFF) ||
|
||||
(oid[3] > 0xFF)) {
|
||||
ip4_addr_copy(*ip, *IP4_ADDR_ANY);
|
||||
return 0;
|
||||
}
|
||||
@@ -162,22 +162,22 @@ snmp_ip4_to_oid(const ip4_addr_t *ip, u32_t *oid)
|
||||
u8_t
|
||||
snmp_oid_to_ip6(const u32_t *oid, ip6_addr_t *ip)
|
||||
{
|
||||
if((oid[0] > 0xFF) ||
|
||||
(oid[1] > 0xFF) ||
|
||||
(oid[2] > 0xFF) ||
|
||||
(oid[3] > 0xFF) ||
|
||||
(oid[4] > 0xFF) ||
|
||||
(oid[5] > 0xFF) ||
|
||||
(oid[6] > 0xFF) ||
|
||||
(oid[7] > 0xFF) ||
|
||||
(oid[8] > 0xFF) ||
|
||||
(oid[9] > 0xFF) ||
|
||||
(oid[10] > 0xFF) ||
|
||||
(oid[11] > 0xFF) ||
|
||||
(oid[12] > 0xFF) ||
|
||||
(oid[13] > 0xFF) ||
|
||||
(oid[14] > 0xFF) ||
|
||||
(oid[15] > 0xFF)) {
|
||||
if ((oid[0] > 0xFF) ||
|
||||
(oid[1] > 0xFF) ||
|
||||
(oid[2] > 0xFF) ||
|
||||
(oid[3] > 0xFF) ||
|
||||
(oid[4] > 0xFF) ||
|
||||
(oid[5] > 0xFF) ||
|
||||
(oid[6] > 0xFF) ||
|
||||
(oid[7] > 0xFF) ||
|
||||
(oid[8] > 0xFF) ||
|
||||
(oid[9] > 0xFF) ||
|
||||
(oid[10] > 0xFF) ||
|
||||
(oid[11] > 0xFF) ||
|
||||
(oid[12] > 0xFF) ||
|
||||
(oid[13] > 0xFF) ||
|
||||
(oid[14] > 0xFF) ||
|
||||
(oid[15] > 0xFF)) {
|
||||
ip6_addr_set_any(ip);
|
||||
return 0;
|
||||
}
|
||||
@@ -245,11 +245,11 @@ snmp_ip_port_to_oid(const ip_addr_t *ip, u16_t port, u32_t *oid)
|
||||
u8_t
|
||||
snmp_ip_to_oid(const ip_addr_t *ip, u32_t *oid)
|
||||
{
|
||||
if(IP_IS_ANY_TYPE_VAL(*ip)) {
|
||||
if (IP_IS_ANY_TYPE_VAL(*ip)) {
|
||||
oid[0] = 0; /* any */
|
||||
oid[1] = 0; /* no IP OIDs follow */
|
||||
return 2;
|
||||
} else if(IP_IS_V6(ip)) {
|
||||
} else if (IP_IS_V6(ip)) {
|
||||
#if LWIP_IPV6
|
||||
oid[0] = 2; /* ipv6 */
|
||||
oid[1] = 16; /* 16 InetAddressIPv6 OIDs follow */
|
||||
@@ -281,16 +281,16 @@ u8_t
|
||||
snmp_oid_to_ip(const u32_t *oid, u8_t oid_len, ip_addr_t *ip)
|
||||
{
|
||||
/* InetAddressType */
|
||||
if(oid_len < 1) {
|
||||
if (oid_len < 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (oid[0] == 0) { /* any */
|
||||
/* 1x InetAddressType, 1x OID len */
|
||||
if(oid_len < 2) {
|
||||
if (oid_len < 2) {
|
||||
return 0;
|
||||
}
|
||||
if(oid[1] != 0) {
|
||||
if (oid[1] != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -301,17 +301,17 @@ snmp_oid_to_ip(const u32_t *oid, u8_t oid_len, ip_addr_t *ip)
|
||||
} else if (oid[0] == 1) { /* ipv4 */
|
||||
#if LWIP_IPV4
|
||||
/* 1x InetAddressType, 1x OID len, 4x InetAddressIPv4 */
|
||||
if(oid_len < 6) {
|
||||
if (oid_len < 6) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 4x ipv4 OID */
|
||||
if(oid[1] != 4) {
|
||||
if (oid[1] != 4) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
IP_SET_TYPE(ip, IPADDR_TYPE_V4);
|
||||
if(!snmp_oid_to_ip4(&oid[2], ip_2_ip4(ip))) {
|
||||
if (!snmp_oid_to_ip4(&oid[2], ip_2_ip4(ip))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -319,20 +319,20 @@ snmp_oid_to_ip(const u32_t *oid, u8_t oid_len, ip_addr_t *ip)
|
||||
#else /* LWIP_IPV4 */
|
||||
return 0;
|
||||
#endif /* LWIP_IPV4 */
|
||||
} else if(oid[0] == 2) { /* ipv6 */
|
||||
} else if (oid[0] == 2) { /* ipv6 */
|
||||
#if LWIP_IPV6
|
||||
/* 1x InetAddressType, 1x OID len, 16x InetAddressIPv6 */
|
||||
if(oid_len < 18) {
|
||||
if (oid_len < 18) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 16x ipv6 OID */
|
||||
if(oid[1] != 16) {
|
||||
if (oid[1] != 16) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
IP_SET_TYPE(ip, IPADDR_TYPE_V6);
|
||||
if(!snmp_oid_to_ip6(&oid[2], ip_2_ip6(ip))) {
|
||||
if (!snmp_oid_to_ip6(&oid[2], ip_2_ip6(ip))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -360,15 +360,15 @@ snmp_oid_to_ip_port(const u32_t *oid, u8_t oid_len, ip_addr_t *ip, u16_t *port)
|
||||
|
||||
/* InetAddressType + InetAddress */
|
||||
idx += snmp_oid_to_ip(&oid[idx], oid_len-idx, ip);
|
||||
if(idx == 0) {
|
||||
if (idx == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* InetPortNumber */
|
||||
if(oid_len < (idx+1)) {
|
||||
if (oid_len < (idx+1)) {
|
||||
return 0;
|
||||
}
|
||||
if(oid[idx] > 0xffff) {
|
||||
if (oid[idx] > 0xffff) {
|
||||
return 0;
|
||||
}
|
||||
*port = (u16_t)oid[idx];
|
||||
@@ -446,7 +446,7 @@ snmp_oid_append(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len)
|
||||
{
|
||||
LWIP_ASSERT("offset + oid_len <= LWIP_SNMP_OBJ_ID_LEN", (target->len + oid_len) <= SNMP_MAX_OBJ_ID_LEN);
|
||||
|
||||
if(oid_len > 0) {
|
||||
if (oid_len > 0) {
|
||||
MEMCPY(&target->id[target->len], oid, oid_len * sizeof(u32_t));
|
||||
target->len += oid_len;
|
||||
}
|
||||
@@ -521,7 +521,7 @@ netif_to_num(const struct netif *netif)
|
||||
while (netif_iterator != NULL) {
|
||||
result++;
|
||||
|
||||
if(netif_iterator == netif) {
|
||||
if (netif_iterator == netif) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -647,11 +647,11 @@ snmp_get_node_instance_from_oid(const u32_t *oid, u8_t oid_len, struct snmp_node
|
||||
node_instance);
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
if(result == SNMP_ERR_NOERROR) {
|
||||
if(((node_instance->access & SNMP_NODE_INSTANCE_ACCESS_READ) != 0) && (node_instance->get_value == NULL)) {
|
||||
if (result == SNMP_ERR_NOERROR) {
|
||||
if (((node_instance->access & SNMP_NODE_INSTANCE_ACCESS_READ) != 0) && (node_instance->get_value == NULL)) {
|
||||
LWIP_DEBUGF(SNMP_DEBUG, ("SNMP inconsistent access: node is readable but no get_value function is specified\n"));
|
||||
}
|
||||
if(((node_instance->access & SNMP_NODE_INSTANCE_ACCESS_WRITE) != 0) && (node_instance->set_value == NULL)) {
|
||||
if (((node_instance->access & SNMP_NODE_INSTANCE_ACCESS_WRITE) != 0) && (node_instance->set_value == NULL)) {
|
||||
LWIP_DEBUGF(SNMP_DEBUG, ("SNMP inconsistent access: node is writable but no set_value and/or set_test function is specified\n"));
|
||||
}
|
||||
}
|
||||
@@ -722,10 +722,10 @@ snmp_get_next_node_instance_from_oid(const u32_t *oid, u8_t oid_len, snmp_valida
|
||||
|
||||
if (result == SNMP_ERR_NOERROR) {
|
||||
#ifdef LWIP_DEBUG
|
||||
if(((node_instance->access & SNMP_NODE_INSTANCE_ACCESS_READ) != 0) && (node_instance->get_value == NULL)) {
|
||||
if (((node_instance->access & SNMP_NODE_INSTANCE_ACCESS_READ) != 0) && (node_instance->get_value == NULL)) {
|
||||
LWIP_DEBUGF(SNMP_DEBUG, ("SNMP inconsistent access: node is readable but no get_value function is specified\n"));
|
||||
}
|
||||
if(((node_instance->access & SNMP_NODE_INSTANCE_ACCESS_WRITE) != 0) && (node_instance->set_value == NULL)) {
|
||||
if (((node_instance->access & SNMP_NODE_INSTANCE_ACCESS_WRITE) != 0) && (node_instance->set_value == NULL)) {
|
||||
LWIP_DEBUGF(SNMP_DEBUG, ("SNMP inconsistent access: node is writable but no set_value function is specified\n"));
|
||||
}
|
||||
#endif
|
||||
@@ -1031,11 +1031,11 @@ snmp_oid_in_range(const u32_t *oid_in, u8_t oid_len, const struct snmp_oid_range
|
||||
{
|
||||
u8_t i;
|
||||
|
||||
if(oid_len != oid_ranges_len) {
|
||||
if (oid_len != oid_ranges_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(i = 0; i < oid_ranges_len; i++) {
|
||||
for (i = 0; i < oid_ranges_len; i++) {
|
||||
if ((oid_in[i] < oid_ranges[i].min) || (oid_in[i] > oid_ranges[i].max)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ interfaces_Table_get_cell_instance(const u32_t* column, const u32_t* row_oid, u8
|
||||
LWIP_UNUSED_ARG(column);
|
||||
|
||||
/* check if incoming OID length and if values are in plausible range */
|
||||
if(!snmp_oid_in_range(row_oid, row_oid_len, interfaces_Table_oid_ranges, LWIP_ARRAYSIZE(interfaces_Table_oid_ranges))) {
|
||||
if (!snmp_oid_in_range(row_oid, row_oid_len, interfaces_Table_oid_ranges, LWIP_ARRAYSIZE(interfaces_Table_oid_ranges))) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ interfaces_Table_get_cell_instance(const u32_t* column, const u32_t* row_oid, u8
|
||||
/* find netif with index */
|
||||
netif = netif_list;
|
||||
while (netif != NULL) {
|
||||
if(netif_to_num(netif) == ifIndex) {
|
||||
if (netif_to_num(netif) == ifIndex) {
|
||||
/* store netif pointer for subsequent operations (get/test/set) */
|
||||
cell_instance->reference.ptr = netif;
|
||||
return SNMP_ERR_NOERROR;
|
||||
@@ -148,7 +148,7 @@ interfaces_Table_get_next_cell_instance(const u32_t* column, struct snmp_obj_id*
|
||||
}
|
||||
|
||||
/* did we find a next one? */
|
||||
if(state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
|
||||
/* store netif pointer for subsequent operations (get/test/set) */
|
||||
cell_instance->reference.ptr = /* (struct netif*) */state.reference;
|
||||
|
||||
@@ -254,7 +254,7 @@ ip_AddrTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row_
|
||||
struct netif *netif;
|
||||
|
||||
/* check if incoming OID length and if values are in plausible range */
|
||||
if(!snmp_oid_in_range(row_oid, row_oid_len, ip_AddrTable_oid_ranges, LWIP_ARRAYSIZE(ip_AddrTable_oid_ranges))) {
|
||||
if (!snmp_oid_in_range(row_oid, row_oid_len, ip_AddrTable_oid_ranges, LWIP_ARRAYSIZE(ip_AddrTable_oid_ranges))) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ ip_AddrTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row_
|
||||
/* find netif with requested ip */
|
||||
netif = netif_list;
|
||||
while (netif != NULL) {
|
||||
if(ip4_addr_cmp(&ip, netif_ip4_addr(netif))) {
|
||||
if (ip4_addr_cmp(&ip, netif_ip4_addr(netif))) {
|
||||
/* fill in object properties */
|
||||
return ip_AddrTable_get_cell_value_core(netif, column, value, value_len);
|
||||
}
|
||||
@@ -299,7 +299,7 @@ ip_AddrTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_o
|
||||
}
|
||||
|
||||
/* did we find a next one? */
|
||||
if(state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
|
||||
/* fill in object properties */
|
||||
return ip_AddrTable_get_cell_value_core((struct netif*)state.reference, column, value, value_len);
|
||||
@@ -405,7 +405,7 @@ ip_RouteTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row
|
||||
struct netif *netif;
|
||||
|
||||
/* check if incoming OID length and if values are in plausible range */
|
||||
if(!snmp_oid_in_range(row_oid, row_oid_len, ip_RouteTable_oid_ranges, LWIP_ARRAYSIZE(ip_RouteTable_oid_ranges))) {
|
||||
if (!snmp_oid_in_range(row_oid, row_oid_len, ip_RouteTable_oid_ranges, LWIP_ARRAYSIZE(ip_RouteTable_oid_ranges))) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ ip_RouteTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row
|
||||
snmp_oid_to_ip4(&row_oid[0], &test_ip); /* we know it succeeds because of oid_in_range check above */
|
||||
|
||||
/* default route is on default netif */
|
||||
if(ip4_addr_isany_val(test_ip) && (netif_default != NULL)) {
|
||||
if (ip4_addr_isany_val(test_ip) && (netif_default != NULL)) {
|
||||
/* fill in object properties */
|
||||
return ip_RouteTable_get_cell_value_core(netif_default, 1, column, value, value_len);
|
||||
}
|
||||
@@ -424,7 +424,7 @@ ip_RouteTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row
|
||||
ip4_addr_t dst;
|
||||
ip4_addr_get_network(&dst, netif_ip4_addr(netif), netif_ip4_netmask(netif));
|
||||
|
||||
if(ip4_addr_cmp(&dst, &test_ip)) {
|
||||
if (ip4_addr_cmp(&dst, &test_ip)) {
|
||||
/* fill in object properties */
|
||||
return ip_RouteTable_get_cell_value_core(netif, 0, column, value, value_len);
|
||||
}
|
||||
@@ -448,7 +448,7 @@ ip_RouteTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_
|
||||
snmp_next_oid_init(&state, row_oid->id, row_oid->len, result_temp, LWIP_ARRAYSIZE(ip_RouteTable_oid_ranges));
|
||||
|
||||
/* check default route */
|
||||
if(netif_default != NULL) {
|
||||
if (netif_default != NULL) {
|
||||
snmp_ip4_to_oid(IP4_ADDR_ANY, &test_oid[0]);
|
||||
snmp_next_oid_check(&state, test_oid, LWIP_ARRAYSIZE(ip_RouteTable_oid_ranges), netif_default);
|
||||
}
|
||||
@@ -469,7 +469,7 @@ ip_RouteTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_
|
||||
}
|
||||
|
||||
/* did we find a next one? */
|
||||
if(state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
ip4_addr_t dst;
|
||||
snmp_oid_to_ip4(&result_temp[0], &dst);
|
||||
snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
|
||||
@@ -531,7 +531,7 @@ ip_NetToMediaTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_
|
||||
u8_t i;
|
||||
|
||||
/* check if incoming OID length and if values are in plausible range */
|
||||
if(!snmp_oid_in_range(row_oid, row_oid_len, ip_NetToMediaTable_oid_ranges, LWIP_ARRAYSIZE(ip_NetToMediaTable_oid_ranges))) {
|
||||
if (!snmp_oid_in_range(row_oid, row_oid_len, ip_NetToMediaTable_oid_ranges, LWIP_ARRAYSIZE(ip_NetToMediaTable_oid_ranges))) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
@@ -545,8 +545,8 @@ ip_NetToMediaTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_
|
||||
struct netif *netif;
|
||||
struct eth_addr *ethaddr;
|
||||
|
||||
if(etharp_get_entry(i, &ip, &netif, ðaddr)) {
|
||||
if((netif_index == netif_to_num(netif)) && ip4_addr_cmp(&ip_in, ip)) {
|
||||
if (etharp_get_entry(i, &ip, &netif, ðaddr)) {
|
||||
if ((netif_index == netif_to_num(netif)) && ip4_addr_cmp(&ip_in, ip)) {
|
||||
/* fill in object properties */
|
||||
return ip_NetToMediaTable_get_cell_value_core(i, column, value, value_len);
|
||||
}
|
||||
@@ -573,7 +573,7 @@ ip_NetToMediaTable_get_next_cell_instance_and_value(const u32_t* column, struct
|
||||
struct netif *netif;
|
||||
struct eth_addr *ethaddr;
|
||||
|
||||
if(etharp_get_entry(i, &ip, &netif, ðaddr)) {
|
||||
if (etharp_get_entry(i, &ip, &netif, ðaddr)) {
|
||||
u32_t test_oid[LWIP_ARRAYSIZE(ip_NetToMediaTable_oid_ranges)];
|
||||
|
||||
test_oid[0] = netif_to_num(netif);
|
||||
@@ -585,7 +585,7 @@ ip_NetToMediaTable_get_next_cell_instance_and_value(const u32_t* column, struct
|
||||
}
|
||||
|
||||
/* did we find a next one? */
|
||||
if(state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
|
||||
/* fill in object properties */
|
||||
return ip_NetToMediaTable_get_cell_value_core((u8_t)(size_t)state.reference, column, value, value_len);
|
||||
|
||||
@@ -171,14 +171,14 @@ tcp_ConnTable_get_cell_value_core(struct tcp_pcb *pcb, const u32_t* column, unio
|
||||
value->u32 = pcb->local_port;
|
||||
break;
|
||||
case 4: /* tcpConnRemAddress */
|
||||
if(pcb->state == LISTEN) {
|
||||
if (pcb->state == LISTEN) {
|
||||
value->u32 = IP4_ADDR_ANY->addr;
|
||||
} else {
|
||||
value->u32 = ip_2_ip4(&pcb->remote_ip)->addr;
|
||||
}
|
||||
break;
|
||||
case 5: /* tcpConnRemPort */
|
||||
if(pcb->state == LISTEN) {
|
||||
if (pcb->state == LISTEN) {
|
||||
value->u32 = 0;
|
||||
} else {
|
||||
value->u32 = pcb->remote_port;
|
||||
@@ -203,7 +203,7 @@ tcp_ConnTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row
|
||||
struct tcp_pcb *pcb;
|
||||
|
||||
/* check if incoming OID length and if values are in plausible range */
|
||||
if(!snmp_oid_in_range(row_oid, row_oid_len, tcp_ConnTable_oid_ranges, LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges))) {
|
||||
if (!snmp_oid_in_range(row_oid, row_oid_len, tcp_ConnTable_oid_ranges, LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges))) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
@@ -219,17 +219,17 @@ tcp_ConnTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row
|
||||
|
||||
while (pcb != NULL) {
|
||||
/* do local IP and local port match? */
|
||||
if(IP_IS_V4_VAL(pcb->local_ip) &&
|
||||
if (IP_IS_V4_VAL(pcb->local_ip) &&
|
||||
ip4_addr_cmp(&local_ip, ip_2_ip4(&pcb->local_ip)) && (local_port == pcb->local_port)) {
|
||||
|
||||
/* PCBs in state LISTEN are not connected and have no remote_ip or remote_port */
|
||||
if(pcb->state == LISTEN) {
|
||||
if(ip4_addr_cmp(&remote_ip, IP4_ADDR_ANY) && (remote_port == 0)) {
|
||||
if (pcb->state == LISTEN) {
|
||||
if (ip4_addr_cmp(&remote_ip, IP4_ADDR_ANY) && (remote_port == 0)) {
|
||||
/* fill in object properties */
|
||||
return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len);
|
||||
}
|
||||
} else {
|
||||
if(IP_IS_V4_VAL(pcb->remote_ip) &&
|
||||
if (IP_IS_V4_VAL(pcb->remote_ip) &&
|
||||
ip4_addr_cmp(&remote_ip, ip_2_ip4(&pcb->remote_ip)) && (remote_port == pcb->remote_port)) {
|
||||
/* fill in object properties */
|
||||
return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len);
|
||||
@@ -262,16 +262,16 @@ tcp_ConnTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_
|
||||
while (pcb != NULL) {
|
||||
u32_t test_oid[LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges)];
|
||||
|
||||
if(IP_IS_V4_VAL(pcb->local_ip)) {
|
||||
if (IP_IS_V4_VAL(pcb->local_ip)) {
|
||||
snmp_ip4_to_oid(ip_2_ip4(&pcb->local_ip), &test_oid[0]);
|
||||
test_oid[4] = pcb->local_port;
|
||||
|
||||
/* PCBs in state LISTEN are not connected and have no remote_ip or remote_port */
|
||||
if(pcb->state == LISTEN) {
|
||||
if (pcb->state == LISTEN) {
|
||||
snmp_ip4_to_oid(IP4_ADDR_ANY, &test_oid[5]);
|
||||
test_oid[9] = 0;
|
||||
} else {
|
||||
if(IP_IS_V6_VAL(pcb->remote_ip)) { /* should never happen */
|
||||
if (IP_IS_V6_VAL(pcb->remote_ip)) { /* should never happen */
|
||||
continue;
|
||||
}
|
||||
snmp_ip4_to_oid(ip_2_ip4(&pcb->remote_ip), &test_oid[5]);
|
||||
@@ -287,7 +287,7 @@ tcp_ConnTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_
|
||||
}
|
||||
|
||||
/* did we find a next one? */
|
||||
if(state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
|
||||
/* fill in object properties */
|
||||
return tcp_ConnTable_get_cell_value_core((struct tcp_pcb*)state.reference, column, value, value_len);
|
||||
@@ -333,13 +333,13 @@ tcp_ConnectionTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8
|
||||
|
||||
/* tcpConnectionLocalAddressType + tcpConnectionLocalAddress + tcpConnectionLocalPort */
|
||||
idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len-idx, &local_ip, &local_port);
|
||||
if(idx == 0) {
|
||||
if (idx == 0) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
/* tcpConnectionRemAddressType + tcpConnectionRemAddress + tcpConnectionRemPort */
|
||||
idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len-idx, &remote_ip, &remote_port);
|
||||
if(idx == 0) {
|
||||
if (idx == 0) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ tcp_ConnectionTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8
|
||||
pcb = *tcp_pcb_nonlisten_lists[i];
|
||||
|
||||
while (pcb != NULL) {
|
||||
if(ip_addr_cmp(&local_ip, &pcb->local_ip) &&
|
||||
if (ip_addr_cmp(&local_ip, &pcb->local_ip) &&
|
||||
(local_port == pcb->local_port) &&
|
||||
ip_addr_cmp(&remote_ip, &pcb->remote_ip) &&
|
||||
(remote_port == pcb->remote_port)) {
|
||||
@@ -401,7 +401,7 @@ tcp_ConnectionTable_get_next_cell_instance_and_value(const u32_t* column, struct
|
||||
}
|
||||
|
||||
/* did we find a next one? */
|
||||
if(state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
|
||||
/* fill in object properties */
|
||||
return tcp_ConnectionTable_get_cell_value_core(column, (struct tcp_pcb*)state.reference, value);
|
||||
@@ -440,14 +440,14 @@ tcp_ListenerTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t
|
||||
|
||||
/* tcpListenerLocalAddressType + tcpListenerLocalAddress + tcpListenerLocalPort */
|
||||
idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len-idx, &local_ip, &local_port);
|
||||
if(idx == 0) {
|
||||
if (idx == 0) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
/* find tcp_pcb with requested ip and port*/
|
||||
pcb = tcp_listen_pcbs.listen_pcbs;
|
||||
while (pcb != NULL) {
|
||||
if(ip_addr_cmp(&local_ip, &pcb->local_ip) &&
|
||||
if (ip_addr_cmp(&local_ip, &pcb->local_ip) &&
|
||||
(local_port == pcb->local_port)) {
|
||||
/* fill in object properties */
|
||||
return tcp_ListenerTable_get_cell_value_core(column, value);
|
||||
@@ -488,7 +488,7 @@ tcp_ListenerTable_get_next_cell_instance_and_value(const u32_t* column, struct s
|
||||
}
|
||||
|
||||
/* did we find a next one? */
|
||||
if(state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
|
||||
/* fill in object properties */
|
||||
return tcp_ListenerTable_get_cell_value_core(column, value);
|
||||
|
||||
@@ -118,28 +118,28 @@ udp_endpointTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t
|
||||
|
||||
/* udpEndpointLocalAddressType + udpEndpointLocalAddress + udpEndpointLocalPort */
|
||||
idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len-idx, &local_ip, &local_port);
|
||||
if(idx == 0) {
|
||||
if (idx == 0) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
/* udpEndpointRemoteAddressType + udpEndpointRemoteAddress + udpEndpointRemotePort */
|
||||
idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len-idx, &remote_ip, &remote_port);
|
||||
if(idx == 0) {
|
||||
if (idx == 0) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
/* udpEndpointInstance */
|
||||
if(row_oid_len < (idx+1)) {
|
||||
if (row_oid_len < (idx+1)) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
if(row_oid[idx] != 0) {
|
||||
if (row_oid[idx] != 0) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
/* find udp_pcb with requested ip and port*/
|
||||
pcb = udp_pcbs;
|
||||
while (pcb != NULL) {
|
||||
if(ip_addr_cmp(&local_ip, &pcb->local_ip) &&
|
||||
if (ip_addr_cmp(&local_ip, &pcb->local_ip) &&
|
||||
(local_port == pcb->local_port) &&
|
||||
ip_addr_cmp(&remote_ip, &pcb->remote_ip) &&
|
||||
(remote_port == pcb->remote_port)) {
|
||||
@@ -191,7 +191,7 @@ udp_endpointTable_get_next_cell_instance_and_value(const u32_t* column, struct s
|
||||
}
|
||||
|
||||
/* did we find a next one? */
|
||||
if(state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
|
||||
/* fill in object properties */
|
||||
return udp_endpointTable_get_cell_value_core(column, value);
|
||||
@@ -243,7 +243,7 @@ udp_Table_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row_oid
|
||||
struct udp_pcb *pcb;
|
||||
|
||||
/* check if incoming OID length and if values are in plausible range */
|
||||
if(!snmp_oid_in_range(row_oid, row_oid_len, udp_Table_oid_ranges, LWIP_ARRAYSIZE(udp_Table_oid_ranges))) {
|
||||
if (!snmp_oid_in_range(row_oid, row_oid_len, udp_Table_oid_ranges, LWIP_ARRAYSIZE(udp_Table_oid_ranges))) {
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
@@ -254,8 +254,8 @@ udp_Table_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row_oid
|
||||
/* find udp_pcb with requested ip and port*/
|
||||
pcb = udp_pcbs;
|
||||
while (pcb != NULL) {
|
||||
if(IP_IS_V4_VAL(pcb->local_ip)) {
|
||||
if(ip4_addr_cmp(&ip, ip_2_ip4(&pcb->local_ip)) && (port == pcb->local_port)) {
|
||||
if (IP_IS_V4_VAL(pcb->local_ip)) {
|
||||
if (ip4_addr_cmp(&ip, ip_2_ip4(&pcb->local_ip)) && (port == pcb->local_port)) {
|
||||
/* fill in object properties */
|
||||
return udp_Table_get_cell_value_core(pcb, column, value, value_len);
|
||||
}
|
||||
@@ -282,7 +282,7 @@ udp_Table_get_next_cell_instance_and_value(const u32_t* column, struct snmp_obj_
|
||||
while (pcb != NULL) {
|
||||
u32_t test_oid[LWIP_ARRAYSIZE(udp_Table_oid_ranges)];
|
||||
|
||||
if(IP_IS_V4_VAL(pcb->local_ip)) {
|
||||
if (IP_IS_V4_VAL(pcb->local_ip)) {
|
||||
snmp_ip4_to_oid(ip_2_ip4(&pcb->local_ip), &test_oid[0]);
|
||||
test_oid[4] = pcb->local_port;
|
||||
|
||||
@@ -294,7 +294,7 @@ udp_Table_get_next_cell_instance_and_value(const u32_t* column, struct snmp_obj_
|
||||
}
|
||||
|
||||
/* did we find a next one? */
|
||||
if(state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
|
||||
snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
|
||||
/* fill in object properties */
|
||||
return udp_Table_get_cell_value_core((struct udp_pcb*)state.reference, column, value, value_len);
|
||||
|
||||
@@ -70,7 +70,7 @@ snmp_netconn_thread(void *arg)
|
||||
snmp_receive(conn, buf->p, &buf->addr, buf->port);
|
||||
}
|
||||
|
||||
if(buf != NULL) {
|
||||
if (buf != NULL) {
|
||||
netbuf_delete(buf);
|
||||
}
|
||||
} while(1);
|
||||
@@ -100,7 +100,7 @@ snmp_get_local_ip_for_dst(void* handle, const ip_addr_t *dst, ip_addr_t *result)
|
||||
|
||||
ip_route_get_local_ip(&conn->pcb.udp->local_ip, dst, dst_if, dst_ip);
|
||||
|
||||
if((dst_if != NULL) && (dst_ip != NULL)) {
|
||||
if ((dst_if != NULL) && (dst_ip != NULL)) {
|
||||
ip_addr_copy(*result, *dst_ip);
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
@@ -60,7 +60,7 @@ snmp_pbuf_stream_read(struct snmp_pbuf_stream* pbuf_stream, u8_t* data)
|
||||
return ERR_BUF;
|
||||
}
|
||||
|
||||
if(pbuf_copy_partial(pbuf_stream->pbuf, data, 1, pbuf_stream->offset) == 0) {
|
||||
if (pbuf_copy_partial(pbuf_stream->pbuf, data, 1, pbuf_stream->offset) == 0) {
|
||||
return ERR_BUF;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ snmp_pbuf_stream_writebuf(struct snmp_pbuf_stream* pbuf_stream, const void* buf,
|
||||
return ERR_BUF;
|
||||
}
|
||||
|
||||
if(pbuf_take_at(pbuf_stream->pbuf, buf, buf_len, pbuf_stream->offset) != ERR_OK) {
|
||||
if (pbuf_take_at(pbuf_stream->pbuf, buf, buf_len, pbuf_stream->offset) != ERR_OK) {
|
||||
return ERR_BUF;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ snmp_get_local_ip_for_dst(void* handle, const ip_addr_t *dst, ip_addr_t *result)
|
||||
|
||||
ip_route_get_local_ip(&udp_pcb->local_ip, dst, dst_if, dst_ip);
|
||||
|
||||
if((dst_if != NULL) && (dst_ip != NULL)) {
|
||||
if ((dst_if != NULL) && (dst_ip != NULL)) {
|
||||
ip_addr_copy(*result, *dst_ip);
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
@@ -130,7 +130,7 @@ threadsync_release_instance(struct snmp_node_instance *instance)
|
||||
{
|
||||
struct threadsync_data *call_data = (struct threadsync_data*)instance->reference.ptr;
|
||||
|
||||
if(call_data->proxy_instance.release_instance != NULL) {
|
||||
if (call_data->proxy_instance.release_instance != NULL) {
|
||||
call_synced_function(call_data, threadsync_release_instance_synced);
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ do_sync(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* ins
|
||||
const struct snmp_threadsync_node *threadsync_node = (const struct snmp_threadsync_node*)(const void*)instance->node;
|
||||
struct threadsync_data *call_data = &threadsync_node->instance->data;
|
||||
|
||||
if(threadsync_node->node.node.oid != threadsync_node->target->node.oid) {
|
||||
if (threadsync_node->node.node.oid != threadsync_node->target->node.oid) {
|
||||
LWIP_DEBUGF(SNMP_DEBUG, ("Sync node OID does not match target node OID"));
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ do_sync(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* ins
|
||||
call_data->arg2.root_oid_len = root_oid_len;
|
||||
call_synced_function(call_data, fn);
|
||||
|
||||
if(call_data->retval.u8 == SNMP_ERR_NOERROR) {
|
||||
if (call_data->retval.u8 == SNMP_ERR_NOERROR) {
|
||||
instance->access = call_data->proxy_instance.access;
|
||||
instance->asn1_type = call_data->proxy_instance.asn1_type;
|
||||
instance->release_instance = threadsync_release_instance;
|
||||
|
||||
@@ -362,7 +362,7 @@ snmp_trap_header_sum(struct snmp_msg_trap *trap, u16_t vb_len)
|
||||
snmp_asn1_enc_length_cnt(len, &lenlen);
|
||||
tot_len += 1 + len + lenlen;
|
||||
|
||||
if(IP_IS_V6_VAL(trap->sip)) {
|
||||
if (IP_IS_V6_VAL(trap->sip)) {
|
||||
#if LWIP_IPV6
|
||||
len = sizeof(ip_2_ip6(&trap->sip)->addr);
|
||||
#endif
|
||||
@@ -400,19 +400,19 @@ snmp_trap_header_sum(struct snmp_msg_trap *trap, u16_t vb_len)
|
||||
static void
|
||||
snmp_trap_varbind_enc(struct snmp_msg_trap *trap, struct snmp_pbuf_stream *pbuf_stream, struct snmp_varbind *varbinds)
|
||||
{
|
||||
struct snmp_asn1_tlv tlv;
|
||||
struct snmp_varbind *varbind;
|
||||
struct snmp_asn1_tlv tlv;
|
||||
struct snmp_varbind *varbind;
|
||||
|
||||
varbind = varbinds;
|
||||
varbind = varbinds;
|
||||
|
||||
SNMP_ASN1_SET_TLV_PARAMS(tlv, SNMP_ASN1_TYPE_SEQUENCE, 0, trap->vbseqlen);
|
||||
snmp_ans1_enc_tlv(pbuf_stream, &tlv);
|
||||
SNMP_ASN1_SET_TLV_PARAMS(tlv, SNMP_ASN1_TYPE_SEQUENCE, 0, trap->vbseqlen);
|
||||
snmp_ans1_enc_tlv(pbuf_stream, &tlv);
|
||||
|
||||
while(varbind != NULL) {
|
||||
snmp_append_outbound_varbind(pbuf_stream, varbind);
|
||||
while (varbind != NULL) {
|
||||
snmp_append_outbound_varbind(pbuf_stream, varbind);
|
||||
|
||||
varbind = varbind->next;
|
||||
}
|
||||
varbind = varbind->next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,7 +449,7 @@ snmp_trap_header_enc(struct snmp_msg_trap *trap, struct snmp_pbuf_stream *pbuf_s
|
||||
snmp_asn1_enc_oid(pbuf_stream, trap->enterprise->id, trap->enterprise->len);
|
||||
|
||||
/* IP addr */
|
||||
if(IP_IS_V6_VAL(trap->sip)) {
|
||||
if (IP_IS_V6_VAL(trap->sip)) {
|
||||
#if LWIP_IPV6
|
||||
SNMP_ASN1_SET_TLV_PARAMS(tlv, SNMP_ASN1_TYPE_IPADDR, 0, sizeof(ip_2_ip6(&trap->sip)->addr));
|
||||
snmp_ans1_enc_tlv(pbuf_stream, &tlv);
|
||||
|
||||
Reference in New Issue
Block a user