« Random (stack) walk. Continues ... wsk provider | Main | Random (stack) walk. Continues ... »

Random (stack) walk. Continues ... sockets

Under the WSK, socket is an object with some data members and some allowable dispatch functions that can be invoked for a particular instance of a socket. There are different types of sockets:Basic, Listen, Datagram, Connection oriented.Things to note is how the different types of socket have different allowable dispatch pointers. A dispatch pointer is a function or method table that consist of a set of allowable function you can invoke from an instance of a socket. This is a bit of a departure from the native socket interface at userlevel where you can invoke pretty much any functions (socket API) on any socket, but wherther it would work or not is different question.

A pointer to a socket object is returned to a WSK application when the application creates a new socket or when the application accepts an incoming connection. A WSK application passes this pointer to all WSK functions that are specific to a particular socket. The functions are in a function table called Dispatch of the wsk socket instance. An example of an invokation of an allowed function of a socket is -

Status = socket->Dispatch->WskAccept(socket, ... );//this is for incomming connection to a listen socket.

So what is a WSK application? In this terminology, a wsk application is really a wsk client application that uses the services provided by a wsk provider. In order to use the services provided by a wsk provider two essential things needs to be done: (1) Register with WSK provider, (2) Capture provider's NPI (network provider interface).

At this point I would recommend to see the WDK document on WSK, and watch for a new feature added to the wdk compiler to include empty stucture within another structure. This is a neat way to add more dispatch functions on the top of basic dispatch functions that comes with basic type of socket ...

As I mentioned that different types of socket gets different set of dispath functions, here is one example from connection oriented socket. 

1: kd> dt socketcontext

Local var @ 0x941f0d18 Type _WSKSAMPLE_SOCKET_CONTEXT*

0x84354350

+0x000 Socket : 0x8463e404 _WSK_SOCKET

+0x004 WorkQueue : 0x8ebf60c0 _WSKSAMPLE_WORK_QUEUE

+0x008 Closing : 0 ''

+0x009 Disconnecting : 0 ''

+0x00a StopListening : 0 ''

+0x00c OpContext : [2] _WSKSAMPLE_SOCKET_OP_CONTEXT

1: kd> dt _WSK_PROVIDER_CONNECTION_DISPATCH 0x84354350

echosrv!_WSK_PROVIDER_CONNECTION_DISPATCH

+0x000 WskControlSocket : 0x8463e404 long +ffffffff8463e404

+0x004 WskCloseSocket : 0x8ebf60c0 long echosrv!WskSampleWorkQueue+0

+0x008 WskBind : (null)

+0x00c WskConnect : 0x8435437c long +ffffffff8435437c

+0x010 WskGetLocalAddress : (null)

+0x014 WskGetRemoteAddress : 0x84354350 long +ffffffff84354350

+0x018 WskSend : 0x8460e130 long +ffffffff8460e130

+0x01c WskReceive : 0x84387008 long +ffffffff84387008

+0x020 WskDisconnect : 0x846d58b8 long +ffffffff846d58b8

+0x024 WskRelease : 0x00000800 long +800

 

Following typedefs are from wsk.h

The WSK_SOCKET structure defines a socket object for a socket.

typedef struct _WSK_SOCKET {

CONST VOID *Dispatch;

} WSK_SOCKET, *PWSK_SOCKET;

 

typedef struct _WSK_PROVIDER_BASIC_DISPATCH {

PFN_WSK_CONTROL_SOCKET WskControlSocket;

PFN_WSK_CLOSE_SOCKET WskCloseSocket;

} WSK_PROVIDER_BASIC_DISPATCH, *PWSK_PROVIDER_BASIC_DISPATCH;

 

The WSK_PROVIDER_CONNECTION_DISPATCH structure specifies the WSK subsystem's table of functions for a connection-oriented socket.

typedef struct _WSK_PROVIDER_CONNECTION_DISPATCH {

WSK_PROVIDER_BASIC_DISPATCH;

PFN_WSK_BIND WskBind;

PFN_WSK_CONNECT WskConnect;

PFN_WSK_GET_LOCAL_ADDRESS WskGetLocalAddress;

PFN_WSK_GET_REMOTE_ADDRESS WskGetRemoteAddress;

PFN_WSK_SEND WskSend;

PFN_WSK_RECEIVE WskReceive;

PFN_WSK_DISCONNECT WskDisconnect;

PFN_WSK_RELEASE_DATA_INDICATION_LIST WskRelease;

} WSK_PROVIDER_CONNECTION_DISPATCH, *PWSK_PROVIDER_CONNECTION_DISPATCH;

 

The WSK_PROVIDER_DATAGRAM_DISPATCH structure specifies the WSK subsystem's table of functions for a datagram socket.

typedef struct _WSK_PROVIDER_DATAGRAM_DISPATCH {

WSK_PROVIDER_BASIC_DISPATCH;

PFN_WSK_BIND WskBind;

PFN_WSK_SEND_TO WskSendTo;

PFN_WSK_RECEIVE_FROM WskReceiveFrom;

PFN_WSK_RELEASE_DATAGRAM_INDICATION_LIST WskRelease;

PFN_WSK_GET_LOCAL_ADDRESS WskGetLocalAddress;

} WSK_PROVIDER_DATAGRAM_DISPATCH, *PWSK_PROVIDER_DATAGRAM_DISPATCH;

 

typedef struct _WSK_PROVIDER_LISTEN_DISPATCH {

WSK_PROVIDER_BASIC_DISPATCH;

PFN_WSK_BIND WskBind;

PFN_WSK_ACCEPT WskAccept;

PFN_WSK_INSPECT_COMPLETE WskInspectComplete;

PFN_WSK_GET_LOCAL_ADDRESS WskGetLocalAddress;

} WSK_PROVIDER_LISTEN_DISPATCH, *PWSK_PROVIDER_LISTEN_DISPATCH;

 

Posted on Tuesday, June 9, 2009 at 06:53PM by Registered CommenterProkash Sinha | CommentsPost a Comment

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.