Skip to content

Commit 1292ce0

Browse files
committed
minor fixes for wolfSentry integration
1 parent 6627967 commit 1292ce0

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/wolfip.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,14 +980,16 @@ static int wolfIP_filter_notify_socket_event(
980980
meta.src_ip = ee32(local_ip);
981981
meta.dst_ip = ee32(remote_ip);
982982
if (ts) {
983-
meta.ip_proto = (uint8_t)ts->proto;
984983
if (ts->proto == WI_IPPROTO_TCP) {
984+
meta.ip_proto = WOLFIP_FILTER_PROTO_TCP;
985985
meta.l4.tcp.src_port = ee16(local_port);
986986
meta.l4.tcp.dst_port = ee16(remote_port);
987987
} else if (ts->proto == WI_IPPROTO_UDP) {
988+
meta.ip_proto = WOLFIP_FILTER_PROTO_UDP;
988989
meta.l4.udp.src_port = ee16(local_port);
989990
meta.l4.udp.dst_port = ee16(remote_port);
990-
}
991+
} else
992+
meta.ip_proto = 0;
991993
}
992994

993995
return wolfIP_filter_dispatch(reason, s, if_idx, NULL, 0, &meta);

wolfip.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static inline uint32_t atou(const char *s)
165165
{
166166
uint32_t ret = 0;
167167
while (*s >= '0' && *s <= '9') {
168-
ret = ret * 10 + (*s - '0');
168+
ret = (ret * 10u) + (uint32_t)(*s - '0');
169169
s++;
170170
}
171171
return ret;
@@ -191,9 +191,9 @@ static inline void iptoa(ip4 ip, char *buf)
191191
buf[0] = 0;
192192
for (i = 0; i < 4; i++) {
193193
uint8_t x = (ip >> (24 - i * 8)) & 0xFF;
194-
if (x > 99) buf[j++] = x / 100 + '0';
195-
if (x > 9) buf[j++] = (x / 10) % 10 + '0';
196-
buf[j++] = x % 10 + '0';
194+
if (x > 99) buf[j++] = (char)(x / 100 + '0');
195+
if (x > 9) buf[j++] = (char)(((x / 10) % 10) + '0');
196+
buf[j++] = (char)((x % 10) + '0');
197197
if (i < 3) buf[j++] = '.';
198198
}
199199
buf[j] = 0;

0 commit comments

Comments
 (0)