From b11036bc1407428b8a8824604a4bf8f8a6fd4b42 Mon Sep 17 00:00:00 2001 From: Daniel Collins Date: Sun, 24 Apr 2011 00:01:38 +0000 Subject: [PATCH] Store IPX net/node numbers in ipx_net structure during startup. --- src/ipxwrapper.c | 15 +++++++++++++-- src/ipxwrapper.h | 10 ++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ipxwrapper.c b/src/ipxwrapper.c index f90af32..f05b683 100644 --- a/src/ipxwrapper.c +++ b/src/ipxwrapper.c @@ -126,12 +126,23 @@ BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) { return FALSE; } - INIT_NIC(nnic); - nnic->ipaddr = ntohl(inet_addr(ifptr->IpAddressList.IpAddress.String)); nnic->bcast = nnic->ipaddr | ~ntohl(inet_addr(ifptr->IpAddressList.IpMask.String)); + memcpy(nnic->hwaddr, ifptr->Address, 6); + if(got_rv) { + memcpy(nnic->ipx_net, rv.ipx_net, 4); + memcpy(nnic->ipx_node, rv.ipx_node, 6); + }else{ + unsigned char net[] = {0,0,0,1}; + + memcpy(nnic->ipx_net, net, 4); + memcpy(nnic->ipx_node, nnic->hwaddr, 6); + } + + nnic->next = NULL; + if(got_rv && rv.primary) { /* Force primary flag set, insert at start of NIC list */ nnic->next = nics; diff --git a/src/ipxwrapper.h b/src/ipxwrapper.h index 136a24f..1625900 100644 --- a/src/ipxwrapper.h +++ b/src/ipxwrapper.h @@ -59,12 +59,6 @@ (ptr)->src_socket = 0;\ (ptr)->size = 0; -#define INIT_NIC(ptr) \ - (ptr)->ipaddr = 0;\ - (ptr)->bcast = 0;\ - memset((ptr)->hwaddr, 0, 6);\ - (ptr)->next = NULL; - #define INIT_HOST(ptr) \ memset((ptr)->hwaddr, 0, 6);\ (ptr)->ipaddr = 0;\ @@ -119,11 +113,15 @@ struct ipx_packet { } __attribute__((__packed__)); struct ipx_nic { + /* TODO: Remove if not needed for per-interface sockets in the future */ uint32_t ipaddr; uint32_t bcast; unsigned char hwaddr[6]; + unsigned char ipx_net[4]; + unsigned char ipx_node[6]; + ipx_nic *next; };