Annotation of ntddk/src/network/tdi/event.c, revision 1.1.1.1

1.1       root        1: /*++
                      2: 
                      3: Copyright (c) 1989-1993  Microsoft Corporation
                      4: 
                      5: Module Name:
                      6: 
                      7:     event.c
                      8: 
                      9: Abstract:
                     10: 
                     11:     This module contains code which performs the following TDI services:
                     12: 
                     13:         o   TdiSetEventHandler
                     14: 
                     15: Environment:
                     16: 
                     17:     Kernel mode
                     18: 
                     19: Revision History:
                     20: 
                     21: --*/
                     22: 
                     23: #include "st.h"
                     24: 
                     25: 
                     26: NTSTATUS
                     27: StTdiSetEventHandler(
                     28:     IN PIRP Irp
                     29:     )
                     30: 
                     31: /*++
                     32: 
                     33: Routine Description:
                     34: 
                     35:     This routine performs the TdiSetEventHandler request for the
                     36:     transport provider.  The caller (request dispatcher) verifies
                     37:     that this routine will not be executed on behalf of a user-mode
                     38:     client, as this request enables direct callouts at DISPATCH_LEVEL.
                     39: 
                     40: Arguments:
                     41: 
                     42:     Irp - Pointer to the IRP for this request
                     43: 
                     44: Return Value:
                     45: 
                     46:     NTSTATUS - status of operation.
                     47: 
                     48: --*/
                     49: 
                     50: {
                     51:     NTSTATUS rc=STATUS_SUCCESS;
                     52:     KIRQL oldirql;
                     53:     PTDI_REQUEST_KERNEL_SET_EVENT parameters;
                     54:     PIO_STACK_LOCATION irpSp;
                     55:     PTP_ADDRESS address;
                     56:     PTP_ADDRESS_FILE addressFile;
                     57:     NTSTATUS status;
                     58: 
                     59:     //
                     60:     // Get the Address this is associated with; if there is none, get out.
                     61:     //
                     62: 
                     63:     irpSp = IoGetCurrentIrpStackLocation (Irp);
                     64: 
                     65:     addressFile  = irpSp->FileObject->FsContext;
                     66:     status = StVerifyAddressObject (addressFile);
                     67:     if (!NT_SUCCESS (status)) {
                     68:         return status;
                     69:     }
                     70: 
                     71:     address = addressFile->Address;
                     72: 
                     73:     ACQUIRE_SPIN_LOCK (&address->SpinLock, &oldirql);
                     74: 
                     75:     parameters = (PTDI_REQUEST_KERNEL_SET_EVENT)&irpSp->Parameters;
                     76: 
                     77:     switch (parameters->EventType) {
                     78: 
                     79:     case TDI_EVENT_RECEIVE:
                     80: 
                     81:         if (parameters->EventHandler == NULL) {
                     82:             addressFile->ReceiveHandler =
                     83:                 (PTDI_IND_RECEIVE)TdiDefaultReceiveHandler;
                     84:             addressFile->ReceiveHandlerContext = NULL;
                     85:             addressFile->RegisteredReceiveHandler = FALSE;
                     86:         } else {
                     87:             addressFile->ReceiveHandler =
                     88:                 (PTDI_IND_RECEIVE)parameters->EventHandler;
                     89:             addressFile->ReceiveHandlerContext = parameters->EventContext;
                     90:             addressFile->RegisteredReceiveHandler = TRUE;
                     91:         }
                     92: 
                     93:         break;
                     94: 
                     95:     case TDI_EVENT_RECEIVE_EXPEDITED:
                     96: 
                     97:         if (parameters->EventHandler == NULL) {
                     98:             addressFile->ExpeditedDataHandler =
                     99:                 (PTDI_IND_RECEIVE_EXPEDITED)TdiDefaultRcvExpeditedHandler;
                    100:             addressFile->ExpeditedDataHandlerContext = NULL;
                    101:             addressFile->RegisteredExpeditedDataHandler = FALSE;
                    102:         } else {
                    103:             addressFile->ExpeditedDataHandler =
                    104:                 (PTDI_IND_RECEIVE_EXPEDITED)parameters->EventHandler;
                    105:             addressFile->ExpeditedDataHandlerContext = parameters->EventContext;
                    106:             addressFile->RegisteredExpeditedDataHandler = TRUE;
                    107:         }
                    108: 
                    109:         break;
                    110: 
                    111:     case TDI_EVENT_RECEIVE_DATAGRAM:
                    112: 
                    113:         if (parameters->EventHandler == NULL) {
                    114:             addressFile->ReceiveDatagramHandler =
                    115:                 (PTDI_IND_RECEIVE_DATAGRAM)TdiDefaultRcvDatagramHandler;
                    116:             addressFile->ReceiveDatagramHandlerContext = NULL;
                    117:             addressFile->RegisteredReceiveDatagramHandler = FALSE;
                    118:         } else {
                    119:             addressFile->ReceiveDatagramHandler =
                    120:                 (PTDI_IND_RECEIVE_DATAGRAM)parameters->EventHandler;
                    121:             addressFile->ReceiveDatagramHandlerContext = parameters->EventContext;
                    122:             addressFile->RegisteredReceiveDatagramHandler = TRUE;
                    123:         }
                    124: 
                    125:         break;
                    126: 
                    127:     case TDI_EVENT_ERROR:
                    128: 
                    129:         if (parameters->EventHandler == NULL) {
                    130:             addressFile->ErrorHandler =
                    131:                 (PTDI_IND_ERROR)TdiDefaultErrorHandler;
                    132:             addressFile->ErrorHandlerContext = NULL;
                    133:             addressFile->RegisteredErrorHandler = FALSE;
                    134:         } else {
                    135:             addressFile->ErrorHandler =
                    136:                 (PTDI_IND_ERROR)parameters->EventHandler;
                    137:             addressFile->ErrorHandlerContext = parameters->EventContext;
                    138:             addressFile->RegisteredErrorHandler = TRUE;
                    139:         }
                    140: 
                    141:         break;
                    142: 
                    143:     case TDI_EVENT_DISCONNECT:
                    144: 
                    145:         if (parameters->EventHandler == NULL) {
                    146:             addressFile->DisconnectHandler =
                    147:                 (PTDI_IND_DISCONNECT)TdiDefaultDisconnectHandler;
                    148:             addressFile->DisconnectHandlerContext = NULL;
                    149:             addressFile->RegisteredDisconnectHandler = FALSE;
                    150:         } else {
                    151:             addressFile->DisconnectHandler =
                    152:                 (PTDI_IND_DISCONNECT)parameters->EventHandler;
                    153:             addressFile->DisconnectHandlerContext = parameters->EventContext;
                    154:             addressFile->RegisteredDisconnectHandler = TRUE;
                    155:         }
                    156: 
                    157:         break;
                    158: 
                    159:     case TDI_EVENT_CONNECT:
                    160: 
                    161:         if (parameters->EventHandler == NULL) {
                    162:             addressFile->ConnectionHandler =
                    163:                 (PTDI_IND_CONNECT)TdiDefaultConnectHandler;
                    164:             addressFile->ConnectionHandlerContext = NULL;
                    165:             addressFile->RegisteredConnectionHandler = FALSE;
                    166:         } else {
                    167:             addressFile->ConnectionHandler =
                    168:                 (PTDI_IND_CONNECT)parameters->EventHandler;
                    169:             addressFile->ConnectionHandlerContext = parameters->EventContext;
                    170:             addressFile->RegisteredConnectionHandler = TRUE;
                    171:         }
                    172:             break;
                    173: 
                    174:     default:
                    175: 
                    176:         rc = STATUS_INVALID_PARAMETER;
                    177: 
                    178:     } /* switch */
                    179: 
                    180:     RELEASE_SPIN_LOCK (&address->SpinLock, oldirql);
                    181: 
                    182:     StDereferenceAddress ("Set event handler", address);
                    183: 
                    184:     return rc;
                    185: } /* TdiSetEventHandler */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.