1
0
mirror of https://github.com/solemnwarning/ipxwrapper synced 2024-12-30 16:45:37 +01:00

Use appropriate MTU for packet size limits.

This commit is contained in:
Daniel Collins 2014-04-14 22:45:38 +01:00
parent c69aac3586
commit 7c19414c37
3 changed files with 14 additions and 4 deletions

View File

@ -414,7 +414,7 @@ static void _init_pcap_interfaces(void)
}
char errbuf[PCAP_ERRBUF_SIZE];
pcap_t *pcap = pcap_open(i->name, 1500 /* TODO */, PCAP_OPENFLAG_MAX_RESPONSIVENESS, 0, NULL, errbuf);
pcap_t *pcap = pcap_open(i->name, ETHERNET_MTU, PCAP_OPENFLAG_MAX_RESPONSIVENESS, 0, NULL, errbuf);
if(!pcap)
{
log_printf(LOG_ERROR, "Could not open WinPcap interface '%s': %s", i->name, errbuf);

View File

@ -29,6 +29,9 @@
extern "C" {
#endif
/* TODO: Dynamic MTU, per interface. */
#define ETHERNET_MTU 1500
#define WILDCARD_IFACE_HWADDR addr48_in((unsigned char[]){0x00,0x00,0x00,0x00,0x00,0x00})
typedef struct ipx_interface_ip ipx_interface_ip_t;

View File

@ -72,6 +72,13 @@ static size_t strsize(void *str, bool unicode)
: strlen(str) + 1;
}
static int _max_ipx_payload(void)
{
return ipx_use_pcap
? (ETHERNET_MTU - sizeof(real_ipx_packet_t))
: MAX_DATA_SIZE;
}
#define PUSH_NAME(name) \
{ \
int i = 0; \
@ -921,7 +928,7 @@ int WSAAPI getsockopt(SOCKET fd, int level, int optname, char FAR *optval, int F
}
else if(optname == IPX_MAXSIZE)
{
RETURN_INT_OPT(MAX_DATA_SIZE);
RETURN_INT_OPT(_max_ipx_payload());
}
else if(optname == IPX_ADDRESS)
{
@ -944,7 +951,7 @@ int WSAAPI getsockopt(SOCKET fd, int level, int optname, char FAR *optval, int F
ipxdata->wan = FALSE;
ipxdata->status = FALSE;
ipxdata->maxpkt = MAX_DATA_SIZE;
ipxdata->maxpkt = _max_ipx_payload();
ipxdata->linkspeed = 100000; /* 10MBps */
free_ipx_interface(nic);
@ -1406,7 +1413,7 @@ int WSAAPI sendto(SOCKET fd, const char *buf, int len, int flags, const struct s
}
}
if(len > MAX_DATA_SIZE)
if(len > _max_ipx_payload())
{
WSASetLastError(WSAEMSGSIZE);