[LWIP]
[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 } Send;
76 struct {
77 err_t Error;
78 } Connect;
79 struct {
80 err_t Error;
81 } Shutdown;
82 struct {
83 err_t Error;
84 } Close;
85 } Output;
86 };
87
88 NTSTATUS LibTCPGetDataFromConnectionQueue(PCONNECTION_ENDPOINT Connection, PUCHAR RecvBuffer, UINT RecvLen, UINT *Received);
89
90 /* External TCP event handlers */
91 extern void TCPConnectEventHandler(void *arg, const err_t err);
92 extern void TCPAcceptEventHandler(void *arg, PTCP_PCB newpcb);
93 extern void TCPSendEventHandler(void *arg, const u16_t space);
94 extern void TCPFinEventHandler(void *arg, const err_t err);
95 extern void TCPRecvEventHandler(void *arg);
96
97 /* TCP functions */
98 PTCP_PCB LibTCPSocket(void *arg);
99 err_t LibTCPBind(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port);
100 PTCP_PCB LibTCPListen(PCONNECTION_ENDPOINT Connection, const u8_t backlog);
101 err_t LibTCPSend(PCONNECTION_ENDPOINT Connection, void *const dataptr, const u16_t len, const int safe);
102 err_t LibTCPConnect(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port);
103 err_t LibTCPShutdown(PCONNECTION_ENDPOINT Connection, const int shut_rx, const int shut_tx);
104 err_t LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe, const int callback);
105
106 err_t LibTCPGetPeerName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port);
107 err_t LibTCPGetHostName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port);
108 void LibTCPAccept(PTCP_PCB pcb, struct tcp_pcb *listen_pcb, void *arg);
109
110 /* IP functions */
111 void LibIPInsertPacket(void *ifarg, const void *const data, const u32_t size);
112 void LibIPInitialize(void);
113 void LibIPShutdown(void);
114
115 #endif