Revert r64621.
[reactos.git] / reactos / lib / drivers / lwip / src / include / rosip.h
1 #ifndef _ROS_IP_H_
2 #define _ROS_IP_H_
3
4 #include "lwip/tcp.h"
5 #include "lwip/pbuf.h"
6 #include "lwip/ip_addr.h"
7 #include "tcpip.h"
8
9 #ifndef LWIP_TAG
10 #define LWIP_TAG 'PIwl'
11 #endif
12
13 typedef struct tcp_pcb* PTCP_PCB;
14
15 typedef struct _QUEUE_ENTRY
16 {
17 struct pbuf *p;
18 ULONG Offset;
19 LIST_ENTRY ListEntry;
20 } QUEUE_ENTRY, *PQUEUE_ENTRY;
21
22 struct lwip_callback_msg
23 {
24 /* Synchronization */
25 KEVENT Event;
26
27 /* Input */
28 union {
29 struct {
30 PVOID Arg;
31 } Socket;
32 struct {
33 PCONNECTION_ENDPOINT Connection;
34 struct ip_addr *IpAddress;
35 u16_t Port;
36 } Bind;
37 struct {
38 PCONNECTION_ENDPOINT Connection;
39 u8_t Backlog;
40 } Listen;
41 struct {
42 PCONNECTION_ENDPOINT Connection;
43 void *Data;
44 u16_t DataLength;
45 } Send;
46 struct {
47 PCONNECTION_ENDPOINT Connection;
48 struct ip_addr *IpAddress;
49 u16_t Port;
50 } Connect;
51 struct {
52 PCONNECTION_ENDPOINT Connection;
53 int shut_rx;
54 int shut_tx;
55 } Shutdown;
56 struct {
57 PCONNECTION_ENDPOINT Connection;
58 int Callback;
59 } Close;
60 } Input;
61
62 /* Output */
63 union {
64 struct {
65 struct tcp_pcb *NewPcb;
66 } Socket;
67 struct {
68 err_t Error;
69 } Bind;
70 struct {
71 struct tcp_pcb *NewPcb;
72 } Listen;
73 struct {
74 err_t Error;
75 u32_t Information;
76 } Send;
77 struct {
78 err_t Error;
79 } Connect;
80 struct {
81 err_t Error;
82 } Shutdown;
83 struct {
84 err_t Error;
85 } Close;
86 } Output;
87 };
88
89 NTSTATUS LibTCPGetDataFromConnectionQueue(PCONNECTION_ENDPOINT Connection, PUCHAR RecvBuffer, UINT RecvLen, UINT *Received);
90
91 /* External TCP event handlers */
92 extern void TCPConnectEventHandler(void *arg, const err_t err);
93 extern void TCPAcceptEventHandler(void *arg, PTCP_PCB newpcb);
94 extern void TCPSendEventHandler(void *arg, const u16_t space);
95 extern void TCPFinEventHandler(void *arg, const err_t err);
96 extern void TCPRecvEventHandler(void *arg);
97
98 /* TCP functions */
99 PTCP_PCB LibTCPSocket(void *arg);
100 err_t LibTCPBind(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port);
101 PTCP_PCB LibTCPListen(PCONNECTION_ENDPOINT Connection, const u8_t backlog);
102 err_t LibTCPSend(PCONNECTION_ENDPOINT Connection, void *const dataptr, const u16_t len, u32_t *sent, const int safe);
103 err_t LibTCPConnect(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port);
104 err_t LibTCPShutdown(PCONNECTION_ENDPOINT Connection, const int shut_rx, const int shut_tx);
105 err_t LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe, const int callback);
106
107 err_t LibTCPGetPeerName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port);
108 err_t LibTCPGetHostName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port);
109 void LibTCPAccept(PTCP_PCB pcb, struct tcp_pcb *listen_pcb, void *arg);
110
111 /* IP functions */
112 void LibIPInsertPacket(void *ifarg, const void *const data, const u32_t size);
113 void LibIPInitialize(void);
114 void LibIPShutdown(void);
115
116 #endif