2008-12-09 21:36:07 +00:00
|
|
|
/* ipxwrapper - Library header
|
2011-04-24 23:40:52 +00:00
|
|
|
* Copyright (C) 2008-2011 Daniel Collins <solemnwarning@solemnwarning.net>
|
2008-12-09 21:36:07 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., 51
|
|
|
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IPXWRAPPER_H
|
|
|
|
#define IPXWRAPPER_H
|
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <iphlpapi.h>
|
2011-08-28 15:56:05 +00:00
|
|
|
#include <wsipx.h>
|
2008-12-09 21:36:07 +00:00
|
|
|
#include <stdint.h>
|
2011-04-24 01:23:10 +00:00
|
|
|
#include <stdio.h>
|
2008-12-09 21:36:07 +00:00
|
|
|
|
2011-04-24 23:40:52 +00:00
|
|
|
#include "config.h"
|
2011-09-07 20:03:16 +00:00
|
|
|
#include "router.h"
|
2011-04-23 23:42:14 +00:00
|
|
|
|
2008-12-09 21:36:07 +00:00
|
|
|
/* Maximum UDP data size is 65467, we use a smaller value to ensure we have
|
|
|
|
* plenty of space to play with for headers, etc
|
|
|
|
*/
|
|
|
|
#define MAX_PACKET_SIZE 63487
|
|
|
|
#define PACKET_BUF_SIZE 65536
|
|
|
|
|
|
|
|
#define IPX_FILTER (int)(1<<0)
|
|
|
|
#define IPX_BOUND (int)(1<<1)
|
|
|
|
#define IPX_BROADCAST (int)(1<<2)
|
|
|
|
#define IPX_SEND (int)(1<<3)
|
|
|
|
#define IPX_RECV (int)(1<<4)
|
2011-09-08 18:28:01 +00:00
|
|
|
#define IPX_REUSE (int)(1<<6)
|
2008-12-09 21:36:07 +00:00
|
|
|
|
|
|
|
#define RETURN(...) \
|
2011-09-08 00:20:34 +00:00
|
|
|
unlock_sockets();\
|
2008-12-09 21:36:07 +00:00
|
|
|
return __VA_ARGS__;
|
|
|
|
|
|
|
|
#define RETURN_WSA(errnum, ...) \
|
2011-09-08 00:20:34 +00:00
|
|
|
unlock_sockets();\
|
2008-12-09 21:36:07 +00:00
|
|
|
WSASetLastError(errnum);\
|
|
|
|
return __VA_ARGS__;
|
|
|
|
|
|
|
|
typedef struct ipx_socket ipx_socket;
|
|
|
|
typedef struct ipx_packet ipx_packet;
|
|
|
|
typedef struct ipx_host ipx_host;
|
|
|
|
|
|
|
|
struct ipx_socket {
|
|
|
|
SOCKET fd;
|
|
|
|
|
|
|
|
int flags;
|
|
|
|
uint8_t s_ptype;
|
2011-04-24 17:40:25 +00:00
|
|
|
uint8_t f_ptype; /* Undefined when IPX_FILTER isn't set */
|
2008-12-09 21:36:07 +00:00
|
|
|
|
2011-04-24 01:23:10 +00:00
|
|
|
/* The following values are undefined when IPX_BOUND is not set */
|
2011-09-07 20:03:16 +00:00
|
|
|
struct sockaddr_ipx addr;
|
|
|
|
uint32_t nic_bcast;
|
2008-12-09 21:36:07 +00:00
|
|
|
|
2011-08-28 15:56:05 +00:00
|
|
|
/* Extra bind address, only used for receiving packets.
|
|
|
|
* Only defined when IPX_EX_BOUND is set.
|
|
|
|
*/
|
2011-08-29 13:15:10 +00:00
|
|
|
struct ipx_interface *ex_nic;
|
2011-08-28 15:56:05 +00:00
|
|
|
uint16_t ex_socket;
|
|
|
|
|
2008-12-09 21:36:07 +00:00
|
|
|
ipx_socket *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ipx_packet {
|
|
|
|
uint8_t ptype;
|
|
|
|
|
|
|
|
unsigned char dest_net[4];
|
|
|
|
unsigned char dest_node[6];
|
|
|
|
uint16_t dest_socket;
|
|
|
|
|
|
|
|
unsigned char src_net[4];
|
|
|
|
unsigned char src_node[6];
|
|
|
|
uint16_t src_socket;
|
|
|
|
|
|
|
|
uint16_t size;
|
|
|
|
char data[1];
|
|
|
|
} __attribute__((__packed__));
|
|
|
|
|
|
|
|
struct ipx_host {
|
2011-04-23 23:42:14 +00:00
|
|
|
unsigned char ipx_net[4];
|
|
|
|
unsigned char ipx_node[6];
|
|
|
|
|
2008-12-09 21:36:07 +00:00
|
|
|
uint32_t ipaddr;
|
2011-04-23 23:42:14 +00:00
|
|
|
time_t last_packet;
|
2008-12-09 21:36:07 +00:00
|
|
|
|
|
|
|
ipx_host *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern ipx_socket *sockets;
|
|
|
|
extern ipx_host *hosts;
|
2011-09-09 19:03:19 +00:00
|
|
|
extern SOCKET send_fd;
|
2011-04-24 18:44:31 +00:00
|
|
|
extern struct reg_global global_conf;
|
2011-09-09 18:36:52 +00:00
|
|
|
extern struct rclient g_rclient;
|
2008-12-09 21:36:07 +00:00
|
|
|
|
|
|
|
extern HMODULE winsock2_dll;
|
|
|
|
extern HMODULE mswsock_dll;
|
|
|
|
extern HMODULE wsock32_dll;
|
|
|
|
|
|
|
|
ipx_socket *get_socket(SOCKET fd);
|
2011-09-08 00:20:34 +00:00
|
|
|
void lock_sockets(void);
|
|
|
|
void unlock_sockets(void);
|
2011-04-23 23:42:14 +00:00
|
|
|
ipx_host *find_host(const unsigned char *net, const unsigned char *node);
|
2011-08-29 13:41:10 +00:00
|
|
|
void add_host(const unsigned char *net, const unsigned char *node, uint32_t ipaddr);
|
2008-12-09 21:36:07 +00:00
|
|
|
|
2011-07-13 22:56:19 +00:00
|
|
|
void log_open();
|
|
|
|
void log_close();
|
|
|
|
|
2009-01-25 17:06:29 +00:00
|
|
|
INT APIENTRY r_EnumProtocolsA(LPINT,LPVOID,LPDWORD);
|
|
|
|
INT APIENTRY r_EnumProtocolsW(LPINT,LPVOID,LPDWORD);
|
|
|
|
int PASCAL FAR r_WSARecvEx(SOCKET,char*,int,int*);
|
|
|
|
int WSAAPI r_bind(SOCKET,const struct sockaddr*,int);
|
|
|
|
int WSAAPI r_closesocket(SOCKET);
|
|
|
|
int WSAAPI r_getsockname(SOCKET,struct sockaddr*,int*);
|
|
|
|
int WSAAPI r_getsockopt(SOCKET,int,int,char*,int*);
|
|
|
|
int WSAAPI r_recv(SOCKET,char*,int,int);
|
|
|
|
int WSAAPI r_recvfrom(SOCKET,char*,int,int,struct sockaddr*,int*);
|
|
|
|
int WSAAPI r_sendto(SOCKET,const char*,int,int,const struct sockaddr*,int);
|
|
|
|
int WSAAPI r_setsockopt(SOCKET,int,int,const char*,int);
|
|
|
|
int WSAAPI r_shutdown(SOCKET,int);
|
|
|
|
SOCKET WSAAPI r_socket(int,int,int);
|
2010-01-09 16:20:18 +00:00
|
|
|
int PASCAL r_ioctlsocket(SOCKET fd, long cmd, u_long *argp);
|
2009-01-25 17:06:29 +00:00
|
|
|
|
2008-12-09 21:36:07 +00:00
|
|
|
#endif /* !IPXWRAPPER_H */
|