forked from pgul/binkd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiphdr.h
150 lines (127 loc) · 3.28 KB
/
iphdr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* iphdr.h -- TCP/IP interface
*
* iphdr.h is a part of binkd project
*
* Copyright (C) 1996 Dima Maloff, 5047/13
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See COPYING.
*/
#ifndef _iphdrs_h
#define _iphdrs_h
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include "sys.h" /* Get system i/o headers */
#ifdef IBMTCPIP
#include <errno.h>
#undef ENAMETOOLONG
#undef ENOTEMPTY
#define BSD_SELECT
#define __off_t
#define __size_t
#include <types.h>
#include <utils.h>
#include <unistd.h>
#include <sys/select.h>
#endif
#if !defined(WIN32)
#if defined(IBMTCPIPDOS)
#include <sys/tcptypes.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h> /* One of these two should have
* MAXHOSTNAMELEN */
#endif
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#if !defined(WIN32)
#include <sys/socket.h>
#endif
/* Some systems have MAXHOSTNAMELEN = 64 */
#ifdef NI_MAXHOST
#define BINKD_FQDNLEN NI_MAXHOST /* max length for getnameinfo */
#else
#define BINKD_FQDNLEN 255 /* max FQDN size */
#endif
#ifdef NI_MAXSERV
#define MAXSERVNAME NI_MAXSERV /* max length for getnameinfo */
#else
#define MAXSERVNAME 80 /* max id len in /etc/services */
#endif
#define MAXPORTSTRLEN 32
#ifndef HAVE_SOCKLEN_T
typedef int socklen_t;
#endif
#if defined(IBMTCPIP)
const char *tcperr (void);
#define ReleaseErrorList()
#define TCPERR() tcperr()
#define TCPERRNO (sock_errno())
#include <nerrno.h>
#define TCPERR_WOULDBLOCK EWOULDBLOCK
#define TCPERR_AGAIN EAGAIN
#define sock_deinit()
#ifndef MAXSOCKETS
#define MAXSOCKETS 2048
#endif
#elif defined(IBMTCPIPDOS)
const char *tcperr (void);
#define ReleaseErrorList()
#define TCPERR() tcperr()
#define TCPERRNO (tcperrno)
#include <sys/errno.h>
#undef ENAMETOOLONG
#undef ENOTEMPTY
#define TCPERR_WOULDBLOCK EWOULDBLOCK
#define TCPERR_AGAIN EAGAIN
#define sock_deinit()
#elif defined(WIN32)
const char *w32err (int);
void ReleaseErrorList(void);
#include <errno.h>
#define TCPERR() w32err(h_errno)
#define TCPERRNO (h_errno)
#define TCPERR_WOULDBLOCK WSAEWOULDBLOCK
#define TCPERR_AGAIN WSAEWOULDBLOCK
#include "nt/WSock.h"
#define sock_init() WinsockIni()
#define sock_deinit() WinsockClean()
#define soclose(h) closesocket(h)
/* w9x_workaround_sleep: 1000000 = 1 sec, 10000 = 10 ms */
#define w9x_workaround_sleep 10000
#else
#include <errno.h>
#define ReleaseErrorList()
#define TCPERR() strerror(errno)
#define TCPERRNO errno
#define TCPERR_WOULDBLOCK EWOULDBLOCK
#define TCPERR_AGAIN EAGAIN
#define sock_init() 0
#define sock_deinit()
#define soclose(h) close(h)
#endif
#if !defined(WIN32)
typedef int SOCKET;
#define INVALID_SOCKET (-1)
#define SOCKET_ERROR (-1)
#endif
#ifndef INADDR_NONE
#define INADDR_NONE -1
#endif
/* OS/2 doesn't support IPv6, we are trying to detect availability of
* some structures based on this define
*/
#ifdef OS2
#undef AF_INET6
#endif
#endif