|
33 | 33 | #include <wolfsentry/wolfsentry_netxduo.h> |
34 | 34 | #include <string.h> |
35 | 35 |
|
36 | | -/* Network byte order conversion functions */ |
37 | | -#ifndef ntohs |
38 | | -#define ntohs(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) |
39 | | -#endif |
40 | | -#ifndef ntohl |
41 | | -#define ntohl(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24)) |
42 | | -#endif |
43 | 36 |
|
44 | 37 | /* Constants for address conversion */ |
45 | 38 | #define MAX_UINT32_DECIMAL_LEN 12 /* Max for 32-bit: 4294967295 (10 digits) + null + extra */ |
@@ -666,7 +659,8 @@ static int parse_ip_packet(unsigned char *packet_data, unsigned long data_length |
666 | 659 | struct netx_udp_header *udp; |
667 | 660 | unsigned long ip_addr; |
668 | 661 |
|
669 | | - if (!packet_data || !local_addr || !remote_addr || !local_port || !remote_port || !protocol) { |
| 662 | + if (!packet_data || !local_addr || !remote_addr || !local_port || |
| 663 | + !remote_port || !protocol) { |
670 | 664 | return -1; |
671 | 665 | } |
672 | 666 |
|
@@ -720,7 +714,7 @@ static int parse_ip_packet(unsigned char *packet_data, unsigned long data_length |
720 | 714 |
|
721 | 715 | /* Extract port numbers for TCP and UDP */ |
722 | 716 | if (*protocol == IPPROTO_TCP || *protocol == IPPROTO_UDP) { |
723 | | - unsigned int ip_header_len = ip->ihl; |
| 717 | + unsigned int ip_header_len = ip->ihl * 4; /* number of 32-bits */ |
724 | 718 |
|
725 | 719 | if (data_length < ip_header_len + sizeof(struct netx_tcp_header)) { |
726 | 720 | return -1; |
@@ -832,7 +826,9 @@ int wolfsentry_netx_ip_packet_filter(struct wolfsentry_context* ctx, unsigned ch |
832 | 826 | } |
833 | 827 |
|
834 | 828 | /* Set route flags for inbound packet */ |
835 | | - route_flags = WOLFSENTRY_ROUTE_FLAG_DIRECTION_IN; |
| 829 | + route_flags = WOLFSENTRY_ROUTE_FLAG_DIRECTION_IN | |
| 830 | + WOLFSENTRY_ROUTE_FLAG_SA_REMOTE_ADDR_WILDCARD | |
| 831 | + WOLFSENTRY_ROUTE_FLAG_SA_REMOTE_PORT_WILDCARD; |
836 | 832 |
|
837 | 833 | /* Initialize action results */ |
838 | 834 | action_results = WOLFSENTRY_ACTION_RES_NONE; |
|
0 commit comments