Whamcloud - gitweb
b=17167 libcfs: ensure all libcfs exported symbols to have cfs_ prefix
[fs/lustre-release.git] / libcfs / include / libcfs / winnt / winnt-tcpip.h
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=4:tabstop=4:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef __LIBCFS_WINNT_TCPIP_H__
38 #define __LIBCFS_WINNT_TCPIP_H__
39
40 #ifndef __LIBCFS_LIBCFS_H__
41 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
42 #endif
43
44
45 #ifdef __KERNEL__
46
47 //
48 //  ks definitions
49 //
50
51 // iovec is defined in libcfs: winnt_prim.h 
52 // lnetkiov_t is defined in lnet/types.h
53
54 typedef struct socket ks_tconn_t, cfs_socket_t;
55
56 // completion notification callback routine
57
58 typedef VOID (*ks_schedule_cb)(struct socket*, int);
59
60 #define SOCK_TEST_NOSPACE(s)   (1)
61
62 //
63 // tdinal definitions
64 //
65
66
67 #if DBG
68 #define KsPrint(X)     KsPrintf X
69 #else
70 #define KsPrint(X)
71 #endif
72
73
74 //
75 // Socket Addresses Related ...
76 //
77
78 #define     INADDR_ANY          (ULONG)0x00000000
79 #define     INADDR_LOOPBACK     (ULONG)0x7f000001
80 #define     INADDR_BROADCAST    (ULONG)0xffffffff
81 #define     INADDR_NONE         (ULONG)0xffffffff
82
83 /*
84  *  TCP / IP options
85  */
86
87 #define     SOL_TCP             6
88 #define     SOL_UD              17
89
90
91 #define TL_INSTANCE             0
92
93 #define TCP_SOCKET_NODELAY      1 //  disabling "Nagle"
94 #define TCP_SOCKET_KEEPALIVE    2
95 #define TCP_SOCKET_OOBINLINE    3
96 #define TCP_SOCKET_BSDURGENT    4
97 #define TCP_SOCKET_ATMARK       5
98 #define TCP_SOCKET_WINDOW       6
99
100
101 /* Flags we can use with send/ and recv. 
102    Added those for 1003.1g not all are supported yet
103  */
104  
105 #define MSG_OOB         1
106 #define MSG_PEEK        2
107 #define MSG_DONTROUTE   4
108 #define MSG_TRYHARD     4       /* Synonym for MSG_DONTROUTE for DECnet */
109 #define MSG_CTRUNC      8
110 #define MSG_PROBE       0x10    /* Do not send. Only probe path f.e. for MTU */
111 #define MSG_TRUNC       0x20
112 #define MSG_DONTWAIT    0x40    /* Nonblocking io                */
113 #define MSG_EOR         0x80    /* End of record */
114 #define MSG_WAITALL     0x100   /* Wait for a full request */
115 #define MSG_FIN         0x200
116 #define MSG_SYN         0x400
117 #define MSG_CONFIRM     0x800   /* Confirm path validity */
118 #define MSG_RST         0x1000
119 #define MSG_ERRQUEUE    0x2000  /* Fetch message from error queue */
120 #define MSG_NOSIGNAL    0x4000  /* Do not generate SIGPIPE */
121 #define MSG_MORE        0x8000  /* Sender will send more */
122
123 #define MSG_EOF         MSG_FIN
124
125
126 //
127 // Maximum TRANSPORT_ADDRESS Length
128 //
129 // it must >= FIELD_OFFSET(TRANSPORT_ADDRESS, Address->Address)
130 //            + TDI_ADDRESS_LENGTH_IP
131 //
132 // I define it a little large and 16 bytes aligned to avoid possible overflow.
133 //
134
135 #define MAX_ADDRESS_LENGTH              (0x30)
136
137
138 //
139 // Maximum Listers Children Sockets
140 //
141
142 #define MAX_CHILD_LISTENERS             (4)
143
144 //
145 // Maximum EA Information Length
146 //
147
148 #define EA_MAX_LENGTH                   ( sizeof(FILE_FULL_EA_INFORMATION) - 1 + \
149                                           TDI_TRANSPORT_ADDRESS_LENGTH + 1 + \
150                                           MAX_ADDRESS_LENGTH )
151
152
153 #define UDP_DEVICE_NAME L"\\Device\\Udp"
154 #define TCP_DEVICE_NAME L"\\Device\\Tcp"
155
156
157 /*
158  * TSDU definitions
159  */
160
161 #define TDINAL_TSDU_DEFAULT_SIZE  (0x10000)
162
163 #define KS_TSDU_MAGIC       'KSTD'
164
165 #define KS_TSDU_ATTACHED    0x00000001  // Attached to the socket receive tsdu list
166
167 typedef struct _KS_TSDU {
168
169     ULONG                 Magic;          /* magic */
170     ULONG                 Flags;          /* flags */
171
172     cfs_list_t            Link;           /* link list */
173
174     ULONG                 TotalLength;    /* total size of KS_TSDU */
175     ULONG                 StartOffset;    /* offset of the first Tsdu unit */
176     ULONG                 LastOffset;     /* end offset of the last Tsdu unit */
177
178 /*
179     union {
180         KS_TSDU_DAT[];
181         KS_TSDU_BUF[];
182         KS_TSDU_MDL[];
183     }
184 */
185
186 } KS_TSDU, *PKS_TSDU;
187
188 #define TSDU_TYPE_BUF   ((USHORT)0x5401)
189 #define TSDU_TYPE_DAT   ((USHORT)0x5402)
190 #define TSDU_TYPE_MDL   ((USHORT)0x5403)
191
192 #define KS_TSDU_COMM_PARTIAL         0x0001
193
194 typedef struct _KS_TSDU_BUF {
195
196     USHORT              TsduType;
197     USHORT              TsduFlags;
198
199     ULONG               DataLength;
200     ULONG               StartOffset;
201
202     PVOID               UserBuffer;
203     PMDL                Mdl;         /* mdl */
204 } KS_TSDU_BUF, *PKS_TSDU_BUF;
205
206 typedef struct _KS_TSDU_DAT {
207
208     USHORT              TsduType;
209     USHORT              TsduFlags;
210
211     ULONG               DataLength;
212     ULONG               StartOffset;
213
214     ULONG               TotalLength;
215     PMDL                Mdl;        /* mdl */
216
217     UCHAR               Data[0];
218
219 } KS_TSDU_DAT, *PKS_TSDU_DAT;
220
221 #define KS_QWORD_ALIGN(x)      (((x) + 0x07) & 0xFFFFFFF8)
222 #define KS_TSDU_STRU_SIZE(Len) (KS_QWORD_ALIGN((Len) + FIELD_OFFSET(KS_TSDU_DAT, Data[0])))
223
224 typedef struct _KS_TSDU_MDL {
225     USHORT              TsduType;      /* TSDU_TYPE_MDL */
226     USHORT              TsduFlags;     /* */
227
228     ULONG               DataLength;    /* total valid data length */
229     ULONG               BaseOffset;    /* payload offset in Tsdu */
230     ULONG               StartOffset;   /* offset in payload */
231
232     PVOID               Descriptor;    /* tdi descriptor for receiving */
233     PMDL                Mdl;
234 } KS_TSDU_MDL, *PKS_TSDU_MDL;
235
236 typedef struct ks_engine_mgr {
237     cfs_spinlock_t          lock;
238     int                     stop;
239     event_t                 exit;
240     event_t                 start;
241     cfs_list_t              list;
242 } ks_engine_mgr_t;
243
244 typedef struct ks_engine_slot {
245     ks_tconn_t *            tconn;
246     void *                  tsdumgr;
247     cfs_list_t              link;
248     int                     queued;
249     ks_engine_mgr_t *       emgr;
250 } ks_engine_slot_t;
251
252 typedef struct _KS_TSDUMGR {
253     cfs_list_t              TsduList;
254     ULONG                   NumOfTsdu;
255     ULONG                   TotalBytes;
256     KEVENT                  Event;
257     cfs_spinlock_t          Lock;
258     ks_engine_slot_t        Slot;
259     ULONG                   Payload;
260     int                     Busy:1;
261     int                     OOB:1;
262 } KS_TSDUMGR, *PKS_TSDUMGR;
263
264 #define ks_lock_tsdumgr(mgr)   cfs_spin_lock(&((mgr)->Lock))
265 #define ks_unlock_tsdumgr(mgr) cfs_spin_unlock(&((mgr)->Lock))
266
267 typedef struct _KS_CHAIN {
268     KS_TSDUMGR          Normal;      /* normal queue */
269     KS_TSDUMGR          Expedited;   /* OOB/expedited queue */
270 } KS_CHAIN, *PKS_CHAIN;
271
272
273 #define KS_CAN_SCHED(TM) ((TM)->TotalBytes >= ((TM)->Payload >> 2))
274
275 //
276 // Handler Settings Indictor 
277 //
278
279 #define TDI_EVENT_MAXIMUM_HANDLER (TDI_EVENT_ERROR_EX + 1)
280
281
282 typedef struct _KS_EVENT_HANDLERS {
283     BOOLEAN     IsActive[TDI_EVENT_MAXIMUM_HANDLER];
284     PVOID       Handler [TDI_EVENT_MAXIMUM_HANDLER];
285 } KS_EVENT_HANDLERS, *PKS_EVENT_HANDLERS;
286
287 #define SetEventHandler(ha, ht, hr) do {        \
288             ha.IsActive[ht] = TRUE;             \
289             ha.Handler[ht] = (PVOID) (hr);      \
290         } while(0)
291
292 //
293 // KSock Internal Structures
294 //
295
296 typedef struct _KS_ADDRESS {
297
298     union {
299         TRANSPORT_ADDRESS   Tdi;
300         UCHAR               Pading[MAX_ADDRESS_LENGTH];
301     };
302
303     HANDLE                  Handle;
304     PFILE_OBJECT            FileObject;
305
306 } KS_ADDRESS, *PKS_ADDRESS;
307
308 //
309 // Structures for Disconnect Workitem
310 //
311
312 typedef struct _KS_DISCONNECT_WORKITEM {
313
314     WORK_QUEUE_ITEM         WorkItem;       // Workitem to perform disconnection
315     ks_tconn_t *            tconn;          // tdi connecton
316     ULONG                   Flags;          // connection broken/discnnection flags
317     KEVENT                  Event;          // sync event
318
319 } KS_DISCONNECT_WORKITEM, *PKS_DISCONNECT_WORKITEM;
320
321
322 typedef struct _KS_CONNECTION {
323
324     HANDLE                      Handle;     // Handle of the tdi connection
325     PFILE_OBJECT                FileObject; // FileObject if the conn object
326
327     PTRANSPORT_ADDRESS          Remote;     // the ConnectionInfo of this connection
328     PTDI_CONNECTION_INFORMATION ConnectionInfo;
329
330     ULONG                       nagle;      // Tcp options 
331
332 } KS_CONNECTION, *PKS_CONNECTION;
333
334
335 //
336 // type definitions
337 //
338
339 typedef MDL                         ks_mdl_t;
340 typedef UNICODE_STRING              ks_unicode_name_t;
341 typedef WORK_QUEUE_ITEM             ks_workitem_t;
342
343
344 typedef KS_CHAIN                    ks_chain_t;
345 typedef KS_ADDRESS                  ks_tdi_addr_t;
346 typedef KS_CONNECTION               ks_tconn_info_t;
347 typedef KS_DISCONNECT_WORKITEM      ks_disconnect_t;
348
349
350 //
351 // Structures for transmission done Workitem
352 //
353
354 typedef struct ks_backlogs {
355
356         cfs_list_t           list;   /* list to link the backlog connections */
357         int                  num;    /* number of backlogs in the list */
358
359 } ks_backlogs_t;
360
361
362 typedef struct ks_daemon {
363
364     ks_tconn_t *            tconn;       /* the listener connection object */
365     unsigned short          nbacklogs;   /* number of listening backlog conns */
366     unsigned short          port;        /* listening port number */ 
367     int                     shutdown;    /* daemon threads is to exit */
368     cfs_list_t              list;        /* to be attached into ks_nal_data_t */
369
370 } ks_daemon_t;
371
372 typedef enum {
373
374     kstt_sender = 0,    // normal sending connection type, it's active connection, while
375                         // child tconn is for passive connection.
376
377     kstt_listener,      // listener daemon type, it just acts as a daemon, and it does
378                         // not have real connection. It manages children tcons to accept
379                         // or refuse the connecting request from remote peers.
380
381     kstt_child,         // accepted child connection type, it's parent must be Listener
382
383     kstt_lasttype
384
385 } ks_tconn_type_t;
386
387 typedef enum {
388
389     ksts_uninited = 0,  // tconn is just allocated (zero values), not initialized yet
390
391     ksts_inited,        // tconn structure initialized: so it now can be identified as
392                         // a sender, listener or a child
393
394     ksts_bind,          // tconn is bound: the local address object (ip/port) is created.
395                         // after being bound, we must call ksocknal_put_tconn to release
396                         // the tconn objects, it's not safe just to free the memory of tconn.
397
398     ksts_associated,    // the connection object is created and associated with the address
399                         // object. so it's ready for connection. only for child and sender.
400
401     ksts_connecting,    // only used by child tconn: in the ConnectEvent handler routine,
402                         // it indicts the child tconn is busy to be connected to the peer.
403
404     ksts_connected,     // the connection is built already: for sender and child
405
406     ksts_listening,     // listener daemon is working, only for listener tconn
407
408     ksts_disconnected,  // disconnected by user
409     ksts_aborted,       // un-exptected broken status
410
411     ksts_last           // total number of tconn statuses
412
413 } ks_tconn_state_t;
414
415 #define KS_TCONN_MAGIC              'KSTM'
416
417 #define KS_TCONN_HANDLERS_SET       0x00000001  // Conection handlers are set.
418 #define KS_TCONN_DISCONNECT_BUSY    0x00010000  // Disconnect Workitem is queued ...
419 #define KS_TCONN_DESTROY_BUSY       0x00020000  // Destory Workitem is queued ...
420
421 #define KS_TCONN_DAEMON_STARTED     0x00100000  // indict the daemon is started,
422                                                 // only valid for listener
423 struct socket {
424
425         ulong                       kstc_magic;      /* Magic & Flags */
426         ulong                       kstc_flags;
427
428         cfs_spinlock_t              kstc_lock;       /* serialise lock*/
429         void *                      kstc_conn;       /* ks_conn_t */
430
431         ks_tconn_type_t             kstc_type;           /* tdi connection Type */
432         ks_tconn_state_t            kstc_state;      /* tdi connection state flag */
433
434         ks_unicode_name_t           kstc_dev;        /* tcp transport device name */
435
436         ks_tdi_addr_t               kstc_addr;       /* local address handlers / Objects */
437
438         cfs_atomic_t                kstc_refcount;   /* reference count of ks_tconn_t */
439
440         cfs_list_t                  kstc_list;       /* linked to global ksocknal_data */
441
442         union {
443
444             struct {
445                 int                 nbacklog;         /* total number of backlog tdi connections */
446                 ks_backlogs_t       kstc_listening;   /* listeing backlog child connections */
447                 ks_backlogs_t       kstc_accepted;    /* connected backlog child connections */
448                 event_t             kstc_accept_event;   /* Signaled by AcceptedHander, 
449                                                             ksocknal_wait_accpeted_conns waits on */
450                 event_t             kstc_destroy_event;  /* Signaled when accepted child is released */
451             } listener; 
452
453             struct  {
454                 ks_tconn_info_t       kstc_info;      /* Connection Info if Connected */
455                 ks_chain_t            kstc_recv;      /* tsdu engine for data receiving */
456                 ks_chain_t            kstc_send;      /* tsdu engine for data sending */
457
458                 int                   kstc_queued;    /* Attached to Parent->ChildList ... */
459                 int                   kstc_queueno;   /* 0: Attached to Listening list 
460                                                        1: Attached to Accepted list */
461
462                 int                   kstc_busy;      /* referred by ConnectEventCallback ? */
463                 int                   kstc_accepted;  /* the connection is built ready ? */
464
465                 cfs_list_t            kstc_link;      /* linked to parent tdi connection */
466                 ks_tconn_t   *        kstc_parent;    /* pointers to it's listener parent */
467             } child;
468
469             struct {
470                 ks_tconn_info_t     kstc_info;      /* Connection Info if Connected */
471                 ks_chain_t          kstc_recv;      /* tsdu engine for data receiving */
472                 ks_chain_t          kstc_send;      /* tsdu engine for data sending */
473             } sender; 
474         };
475
476         ulong                       kstc_snd_wnd;   /* Sending window size */
477         ulong                       kstc_rcv_wnd;   /* Recving window size */
478
479         ks_workitem_t               kstc_destroy;    /* tconn destruction workitem */
480         ks_disconnect_t             kstc_disconnect; /* connection disconnect workitem */
481
482         ks_schedule_cb              kstc_sched_cb;   /* notification callback routine of completion */
483 };
484
485 static inline int
486 libcfs_sock_error(struct socket *sock)
487 {
488         return (sock->kstc_state >= ksts_disconnected) ? ECONNRESET : 0;
489 }
490
491
492 static inline int
493 libcfs_sock_wmem_queued(struct socket *sock)
494 {
495         return 0;
496 }
497
498 #define TDINAL_WINDOW_DEFAULT_SIZE  (0x100000)
499 #define TDINAL_MAX_TSDU_QUEUE_SIZE  (0x200000)
500
501 struct _KS_UDP_COMPLETION_CONTEXT;
502 struct _KS_TCP_COMPLETION_CONTEXT;
503
504
505 typedef
506 NTSTATUS
507 (*PKS_UDP_COMPLETION_ROUTINE) (
508     IN PIRP     Irp,
509     IN struct _KS_UDP_COMPLETION_CONTEXT
510                 *UdpContext
511     );
512
513
514 typedef
515 NTSTATUS
516 (*PKS_TCP_COMPLETION_ROUTINE) (
517     IN PIRP     Irp,
518     IN struct _KS_TCP_COMPLETION_CONTEXT
519                 *TcpContext
520     );
521
522 //
523 // Udp Irp Completion Context
524 //
525
526 typedef struct _KS_UDP_COMPLETION_CONTEXT {
527
528     PKEVENT                             Event;
529     union {
530         PFILE_OBJECT                    AddressObject;
531         ks_tconn_t *                    tconn;
532     };
533
534     PKS_UDP_COMPLETION_ROUTINE          CompletionRoutine;
535     PVOID                               CompletionContext;
536
537 } KS_UDP_COMPLETION_CONTEXT, *PKS_UDP_COMPLETION_CONTEXT;
538
539
540 //
541 // Tcp Irp Completion Context (used by tcp data recv/send)
542 //
543
544 #define KS_TCP_CONTEXT_MAGIC 'CCTK'
545
546 typedef struct _KS_TCP_COMPLETION_CONTEXT {
547     PKEVENT                             Event;      // Event to be waited on by Irp caller ...
548     ks_tconn_t *                        tconn;      // the tdi connection
549     PKS_TCP_COMPLETION_ROUTINE          CompletionRoutine;
550     PVOID                               CompletionContext;
551     PKS_TSDUMGR                         TsduMgr;    // Tsdu buffer manager
552     ULONG                               Length;     // Payload length in KsTsdu queue
553     PCHAR                               Buffer;     // User allocated buffer
554     ULONG                               Magic;      // Magic key
555 } KS_TCP_COMPLETION_CONTEXT, *PKS_TCP_COMPLETION_CONTEXT;
556
557 typedef KS_TCP_COMPLETION_CONTEXT  ks_tdi_tx_t, ks_tdi_rx_t;
558
559
560 /*
561  * tdi extensions
562  */
563
564 #define IOCTL_TCP_QUERY_INFORMATION_EX        \
565                         CTL_CODE(FILE_DEVICE_NETWORK, 0, METHOD_NEITHER, FILE_ANY_ACCESS)
566 #define IOCTL_TCP_SET_INFORMATION_EX        \
567                         CTL_CODE(FILE_DEVICE_NETWORK, 1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
568
569
570 #define TcpBuildSetInformationEx(Irp, DevObj, FileObj, CompRoutine, Contxt, Buffer, BufferLen)\
571     {                                                                        \
572         PIO_STACK_LOCATION _IRPSP;                                           \
573         if ( CompRoutine != NULL) {                                          \
574             IoSetCompletionRoutine( Irp, CompRoutine, Contxt, TRUE, TRUE, TRUE);\
575         } else {                                                             \
576             IoSetCompletionRoutine( Irp, NULL, NULL, FALSE, FALSE, FALSE);   \
577         }                                                                    \
578         _IRPSP = IoGetNextIrpStackLocation (Irp);                            \
579         _IRPSP->MajorFunction = IRP_MJ_DEVICE_CONTROL;                       \
580         _IRPSP->DeviceObject = DevObj;                                       \
581         _IRPSP->FileObject = FileObj;                                        \
582         _IRPSP->Parameters.DeviceIoControl.OutputBufferLength = 0;           \
583         _IRPSP->Parameters.DeviceIoControl.InputBufferLength = BufferLen;    \
584         _IRPSP->Parameters.DeviceIoControl.IoControlCode = IOCTL_TCP_SET_INFORMATION_EX;  \
585         Irp->AssociatedIrp.SystemBuffer = Buffer;                            \
586     }
587
588
589 #define TcpBuildQueryInformationEx(Irp, DevObj, FileObj, CompRoutine, Contxt, InBuffer, InLength, OutBuffer, OutLength)\
590     {                                                                        \
591         PIO_STACK_LOCATION _IRPSP;                                           \
592         if ( CompRoutine != NULL) {                                          \
593             IoSetCompletionRoutine( Irp, CompRoutine, Contxt, TRUE, TRUE, TRUE);\
594         } else {                                                             \
595             IoSetCompletionRoutine( Irp, NULL, NULL, FALSE, FALSE, FALSE);   \
596         }                                                                    \
597         _IRPSP = IoGetNextIrpStackLocation (Irp);                            \
598         _IRPSP->MajorFunction = IRP_MJ_DEVICE_CONTROL;                       \
599         _IRPSP->DeviceObject = DevObj;                                       \
600         _IRPSP->FileObject = FileObj;                                        \
601         _IRPSP->Parameters.DeviceIoControl.OutputBufferLength = OutLength;           \
602         _IRPSP->Parameters.DeviceIoControl.InputBufferLength = InLength;    \
603         _IRPSP->Parameters.DeviceIoControl.IoControlCode = IOCTL_TCP_QUERY_INFORMATION_EX;  \
604         _IRPSP->Parameters.DeviceIoControl.Type3InputBuffer = InBuffer;    \
605         Irp->UserBuffer = OutBuffer;                            \
606     }
607
608 typedef struct ks_addr_slot {
609     LIST_ENTRY      link;
610     int             up;
611     char            iface[40];
612     __u32           ip_addr;
613     __u32           netmask;
614     UNICODE_STRING  devname;
615     WCHAR           buffer[1];
616 } ks_addr_slot_t;
617
618 typedef struct {
619
620     /*
621      * Tdi client information
622      */
623
624     UNICODE_STRING        ksnd_client_name; /* tdi client module name */
625     HANDLE                ksnd_pnp_handle;  /* the handle for pnp changes */
626
627     cfs_spinlock_t        ksnd_addrs_lock;  /* serialize ip address list access */
628     LIST_ENTRY            ksnd_addrs_list;  /* list of the ip addresses */
629     int                   ksnd_naddrs;      /* number of the ip addresses */
630
631     /*
632      *  Tdilnd internal defintions
633      */
634
635     int                   ksnd_init;            /* initialisation state */
636
637     TDI_PROVIDER_INFO     ksnd_provider;        /* tdi tcp/ip provider's information */
638
639     cfs_spinlock_t        ksnd_tconn_lock;      /* tdi connections access serialise */
640
641     int                   ksnd_ntconns;         /* number of tconns attached in list */
642     cfs_list_t            ksnd_tconns;          /* tdi connections list */
643     cfs_mem_cache_t *     ksnd_tconn_slab;      /* slabs for ks_tconn_t allocations */
644     event_t               ksnd_tconn_exit;      /* exit event to be signaled by the last tconn */
645
646     cfs_spinlock_t        ksnd_tsdu_lock;       /* tsdu access serialise */
647         
648     int                   ksnd_ntsdus;          /* number of tsdu buffers allocated */
649     ulong                 ksnd_tsdu_size;       /* the size of a signel tsdu buffer */
650     cfs_mem_cache_t       *ksnd_tsdu_slab;       /* slab cache for tsdu buffer allocation */
651
652     int                   ksnd_nfreetsdus;      /* number of tsdu buffers in the freed list */
653     cfs_list_t            ksnd_freetsdus;       /* List of the freed Tsdu buffer. */
654
655     int                   ksnd_engine_nums;     /* number of tcp sending engine threads */
656     ks_engine_mgr_t       *ksnd_engine_mgr;      /* tcp sending engine structure */
657
658 } ks_tdi_data_t;
659
660 int
661 ks_init_tdi_data();
662
663 void
664 ks_fini_tdi_data();
665
666
667 int
668 ks_query_local_ipaddr(
669     ks_tconn_t *     tconn
670     );
671
672 void
673 ks_get_tconn(
674     ks_tconn_t * tconn
675     );
676
677 void
678 ks_put_tconn(
679     ks_tconn_t * tconn
680     );
681
682 void
683 ks_abort_tconn(
684   ks_tconn_t *     tconn
685     );
686 int
687 ks_disconnect_tconn(
688     ks_tconn_t *    tconn,
689     ulong           flags
690     );
691
692 void
693 ks_destroy_tconn(
694     ks_tconn_t *     tconn
695     );
696
697 NTSTATUS
698 KsLockUserBuffer (
699     IN PVOID            UserBuffer,
700     IN BOOLEAN          bPaged,
701     IN ULONG            Length,
702     IN LOCK_OPERATION   Operation,
703     OUT PMDL *          pMdl
704     );
705
706 VOID
707 KsReleaseMdl (IN PMDL   Mdl,
708               IN int    Paged );
709
710 void
711 KsQueueTdiEngine(ks_tconn_t * tconn, PKS_TSDUMGR);
712
713 void
714 KsRemoveTdiEngine(PKS_TSDUMGR);
715
716 NTSTATUS
717 ks_set_tcp_option (
718     ks_tconn_t *    tconn,
719     ULONG           ID,
720     PVOID           OptionValue,
721     ULONG           Length
722     );
723
724 int
725 ks_get_tcp_option (
726     ks_tconn_t *        tconn,
727     ULONG               ID,
728     PVOID               OptionValue,
729     PULONG              Length
730     );
731
732 #endif /* __KERNEL__ */
733 #endif /* __LIBCFS_WINNT_TCPIP_H__ */
734
735 /*
736  * Local variables:
737  * c-indentation-style: "K&R"
738  * c-basic-offset: 8
739  * tab-width: 8
740  * fill-column: 80
741  * scroll-step: 1
742  * End:
743  */