50ca32822226149026443904be6968fec6e5cd7d
[reactos.git] / reactos / drivers / lib / oskittcp / include / oskittcp.h
1 #ifndef OSKITTCP_H
2 #define OSKITTCP_H
3
4 #ifdef linux
5 #include <netinet/in.h>
6 #endif
7
8 #ifndef _MSC_VER
9 #include <roscfg.h>
10 #endif/*_MSC_VER*/
11 #ifdef KERNEL
12 #include <sys/param.h>
13 #include <sys/systm.h>
14 #include <sys/malloc.h>
15 #include <sys/mbuf.h>
16 #include <sys/protosw.h>
17 #include <sys/socket.h>
18 #include <sys/socketvar.h>
19 #include <sys/errno.h>
20 #include <sys/queue.h>
21 #include <sys/kernel.h>
22
23 #include <net/if.h>
24 #include <net/route.h>
25
26 #include <netinet/in.h>
27 #include <netinet/in_systm.h>
28 #include <netinet/ip.h>
29 #include <netinet/in_pcb.h>
30 #include <netinet/ip_var.h>
31 #include <netinet/tcp.h>
32 #include <netinet/tcp_fsm.h>
33 #include <netinet/tcp_seq.h>
34 #include <netinet/tcp_timer.h>
35 #include <netinet/tcp_var.h>
36 #include <netinet/tcpip.h>
37
38 struct connect_args {
39 int s;
40 caddr_t name;
41 int namelen;
42 };
43 #endif
44
45 #include <oskittypes.h>
46
47 #define IPHDR_SIZE 20
48 #define SEL_CONNECT 1
49 #define SEL_FIN 2
50 #define SEL_RST 4
51 #define SEL_ABRT 8
52 #define SEL_READ 16
53 #define SEL_WRITE 32
54 #define SEL_ACCEPT 64
55 #define SEL_OOB 128
56 #define SEL_ERROR 256
57 #define SEL_FINOUT 512
58
59 typedef int (*OSKITTCP_SOCKET_STATE)
60 ( void *ClientData,
61 void *WhichSocket,
62 void *WhichConnection,
63 OSK_UINT NewState );
64
65 typedef int (*OSKITTCP_SEND_PACKET)
66 ( void *ClientData,
67 OSK_PCHAR Data,
68 OSK_UINT Len );
69
70 typedef struct ifaddr *(*OSKITTCP_FIND_INTERFACE)
71 ( void *ClientData,
72 OSK_UINT AddrType,
73 OSK_UINT FindType,
74 struct sockaddr *ReqAddr );
75
76 typedef void *(*OSKITTCP_MALLOC)
77 ( void *ClientData,
78 OSK_UINT Bytes,
79 OSK_PCHAR File,
80 OSK_UINT Line );
81
82 typedef void (*OSKITTCP_FREE)
83 ( void *ClientData,
84 void *data,
85 OSK_PCHAR File,
86 OSK_UINT Line );
87
88 typedef int (*OSKITTCP_SLEEP)
89 ( void *ClientData, void *token, int priority, char *msg, int tmio );
90
91 typedef void (*OSKITTCP_WAKEUP)( void *ClientData, void *token );
92
93 typedef struct _OSKITTCP_EVENT_HANDLERS {
94 void *ClientData;
95 OSKITTCP_SOCKET_STATE SocketState;
96 OSKITTCP_SEND_PACKET PacketSend;
97 OSKITTCP_FIND_INTERFACE FindInterface;
98 OSKITTCP_MALLOC TCPMalloc;
99 OSKITTCP_FREE TCPFree;
100 OSKITTCP_SLEEP Sleep;
101 OSKITTCP_WAKEUP Wakeup;
102 } OSKITTCP_EVENT_HANDLERS, *POSKITTCP_EVENT_HANDLERS;
103
104 extern OSKITTCP_EVENT_HANDLERS OtcpEvent;
105
106 extern void InitOskitTCP();
107 extern void DeinitOskitTCP();
108 extern void TimerOskitTCP();
109 extern void OskitDumpBuffer( OSK_PCHAR Data, OSK_UINT Len );
110 extern int OskitTCPShutdown( void *socket, int disconn_type );
111 extern int OskitTCPSocket( void *Connection, void **ConnectionContext,
112 int Af, int Type, int Proto );
113 extern void RegisterOskitTCPEventHandlers
114 ( POSKITTCP_EVENT_HANDLERS EventHandlers );
115 extern void OskitTCPReceiveDatagram( OSK_PCHAR Data, OSK_UINT Len,
116 OSK_UINT IpHeaderLen );
117 extern int OskitTCPReceive( void *socket,
118 void *Addr,
119 OSK_PCHAR Data,
120 OSK_UINT Len,
121 OSK_UINT *OutLen,
122 OSK_UINT Flags );
123 extern int OskitTCPSend( void *socket,
124 OSK_PCHAR Data,
125 OSK_UINT Len,
126 OSK_UINT *OutLen,
127 OSK_UINT Flags );
128
129 extern int OskitTCPConnect( void *socket, void *connection,
130 void *nam, OSK_UINT namelen );
131 extern int OskitTCPClose( void *socket );
132
133 extern int OskitTCPBind( void *socket, void *connection,
134 void *nam, OSK_UINT namelen );
135
136 extern int OskitTCPAccept( void *socket, void **new_socket,
137 void *addr_out,
138 OSK_UINT addr_len,
139 OSK_UINT *out_addr_len,
140 OSK_UINT finish_accept );
141
142 extern int OskitTCPListen( void *socket, int backlog );
143
144 extern int OskitTCPRecv( void *connection,
145 OSK_PCHAR Data,
146 OSK_UINT Len,
147 OSK_UINT *OutLen,
148 OSK_UINT Flags );
149
150 void OskitTCPGetAddress( void *socket,
151 OSK_UINT *LocalAddress,
152 OSK_UI16 *LocalPort,
153 OSK_UINT *RemoteAddress,
154 OSK_UI16 *RemotePort );
155
156 #undef errno
157
158 void *fbsd_malloc( unsigned int bytes, ... );
159 void fbsd_free( void *data, ... );
160 #if 0
161 #define malloc(x) fbsd_malloc(x,__FILE__,__LINE__)
162 #define free(x) fbsd_free(x,__FILE__,__LINE__)
163 #endif
164 #define kern_malloc(x,y,z) kern_malloc_needs_definition(x,y,z)
165 #define kern_free(x,y,z) kern_free_needs_definition(x,w,z)
166
167 /* Error codes */
168 #include <oskiterrno.h>
169
170 #define SOCK_MAXADDRLEN 255
171
172 #define OSK_MSG_OOB 0x01
173 #define OSK_MSG_PEEK 0x02
174 #define OSK_MSG_DONTWAIT 0x80
175
176 #endif/*OSKITTCP_H*/