mirror of
https://github.com/solemnwarning/ipxwrapper
synced 2024-12-30 16:45:37 +01:00
Check packet size and cache source IP in recv_packet. Destination network number is replaced with the source IP of the packet by the router thread.
This commit is contained in:
parent
d046b6522d
commit
0b73241fe8
11
src/router.c
11
src/router.c
@ -204,7 +204,14 @@ DWORD router_main(void *arg) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_host(packet->src_net, packet->src_node, addr.sin_addr.s_addr);
|
/* Replace destination network field of packet with source IP address
|
||||||
|
* so that the client can cache it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
char dest_net[4];
|
||||||
|
|
||||||
|
memcpy(dest_net, packet->dest_net, 4);
|
||||||
|
memcpy(packet->dest_net, &(addr.sin_addr.s_addr), 4);
|
||||||
|
|
||||||
struct router_addr *ra = router->addrs;
|
struct router_addr *ra = router->addrs;
|
||||||
|
|
||||||
@ -212,7 +219,7 @@ DWORD router_main(void *arg) {
|
|||||||
if(
|
if(
|
||||||
ra->local_port &&
|
ra->local_port &&
|
||||||
(ra->filter_ptype < 0 || ra->filter_ptype == packet->ptype) &&
|
(ra->filter_ptype < 0 || ra->filter_ptype == packet->ptype) &&
|
||||||
(memcmp(packet->dest_net, ra->addr.sa_netnum, 4) == 0 || memcmp(packet->dest_net, f6, 4) == 0) &&
|
(memcmp(dest_net, ra->addr.sa_netnum, 4) == 0 || memcmp(dest_net, f6, 4) == 0) &&
|
||||||
(memcmp(packet->dest_node, ra->addr.sa_nodenum, 6) == 0 || memcmp(packet->dest_node, f6, 6) == 0) &&
|
(memcmp(packet->dest_node, ra->addr.sa_nodenum, 6) == 0 || memcmp(packet->dest_node, f6, 6) == 0) &&
|
||||||
packet->dest_socket == ra->addr.sa_socket
|
packet->dest_socket == ra->addr.sa_socket
|
||||||
) {
|
) {
|
||||||
|
@ -322,6 +322,17 @@ static int recv_packet(ipx_socket *sockptr, char *buf, int bufsize, int flags, s
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(rval < sizeof(ipx_packet) || rval != packet->size + sizeof(ipx_packet) - 1) {
|
||||||
|
log_printf("Invalid packet received on loopback port!");
|
||||||
|
|
||||||
|
free(packet);
|
||||||
|
WSASetLastError(WSAEWOULDBLOCK);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Router thread replaces destination network number with source IP address */
|
||||||
|
add_host(packet->src_net, packet->src_node, *((uint32_t*)packet->dest_net));
|
||||||
|
|
||||||
if(addr) {
|
if(addr) {
|
||||||
addr->sa_family = AF_IPX;
|
addr->sa_family = AF_IPX;
|
||||||
memcpy(addr->sa_netnum, packet->src_net, 4);
|
memcpy(addr->sa_netnum, packet->src_net, 4);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user