[TCPIP]
[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 LIST_ENTRY ListEntry;
19 } QUEUE_ENTRY, *PQUEUE_ENTRY;
20
21 struct lwip_callback_msg
22 {
23 /* Synchronization */
24 KEVENT Event;
25
26 /* Input */
27 union {
28 struct {
29 PVOID Arg;
30 } Socket;
31 struct {
32 PCONNECTION_ENDPOINT Connection;
33 struct ip_addr *IpAddress;
34 u16_t Port;
35 } Bind;
36 struct {
37 PCONNECTION_ENDPOINT Connection;
38 u8_t Backlog;
39 } Listen;
40 struct {
41 PCONNECTION_ENDPOINT Connection;
42 void *Data;
43 u16_t DataLength;
44 } Send;
45 struct {
46 PCONNECTION_ENDPOINT Connection;
47 struct ip_addr *IpAddress;
48 u16_t Port;
49 } Connect;
50 struct {
51 PCONNECTION_ENDPOINT Connection;
52 int shut_rx;
53 int shut_tx;
54 } Shutdown;
55 struct {
56 PCONNECTION_ENDPOINT Connection;
57 int Callback;
58 } Close;
59 } Input;
60
61 /* Output */
62 union {
63 struct {
64 struct tcp_pcb *NewPcb;
65 } Socket;
66 struct {
67 err_t Error;
68 } Bind;
69 struct {
70 struct tcp_pcb *NewPcb;
71 } Listen;
72 struct {
73 err_t Error;
74 } Send;
75 struct {
76 err_t Error;
77 } Connect;
78 struct {
79 err_t Error;
80 } Shutdown;
81 struct {
82 err_t Error;
83 } Close;
84 } Output;
85 };
86
87 NTSTATUS LibTCPGetDataFromConnectionQueue(PCONNECTION_ENDPOINT Connection, PUCHAR RecvBuffer, UINT RecvLen, UINT *Received);
88
89 /* External TCP event handlers */
90 extern void TCPConnectEventHandler(void *arg, const err_t err);
91 extern void TCPAcceptEventHandler(void *arg, PTCP_PCB newpcb);
92 extern void TCPSendEventHandler(void *arg, const u16_t space);
93 extern void TCPFinEventHandler(void *arg, const err_t err);
94 extern u32_t TCPRecvEventHandler(void *arg, struct pbuf *p);
95
96 /* TCP functions */
97 PTCP_PCB LibTCPSocket(void *arg);
98 err_t LibTCPBind(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port);
99 PTCP_PCB LibTCPListen(PCONNECTION_ENDPOINT Connection, const u8_t backlog);
100 err_t LibTCPSend(PCONNECTION_ENDPOINT Connection, void *const dataptr, const u16_t len, const int safe);
101 err_t LibTCPConnect(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port);
102 err_t LibTCPShutdown(PCONNECTION_ENDPOINT Connection, const int shut_rx, const int shut_tx);
103 err_t LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe, const int callback);
104
105 err_t LibTCPGetPeerName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port);
106 err_t LibTCPGetHostName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port);
107 void LibTCPAccept(PTCP_PCB pcb, struct tcp_pcb *listen_pcb, void *arg);
108
109 /* IP functions */
110 void LibIPInsertPacket(void *ifarg, const void *const data, const u32_t size);
111 void LibIPInitialize(void);
112 void LibIPShutdown(void);
113
114 #endif