?? ipsecmsgcserver.c
字號:
/* ipsecMsgCServer.c - WindNet IPsec and IKE: Generic Message Channel Server Operations *//* * Copyright (c) 2000-2005 Wind River Systems, Inc. * * The right to copy, distribute, modify or otherwise make use * of this software may be licensed only pursuant to the terms * of an applicable Wind River license agreement. *//*modification history------------------------------------------01f,12dec05,djp removed compiler warnings01e,26oct05,djp Moved generic portions to common directory01d,28sep05,ewh Resolved SPR11246501c,11apr05,djp Added support for boolean array get/set (logger operations)01b,09mar05,djp Added stats code01a,28feb05,djp Fixed compiler warnings*//************************************************************************//* This file contains operations for the IPsec server message channel */#include <vxWorks.h>#include <errnoLib.h>#include "../msgCLib/msgCLib.h"#include "../common/wrSecMsgChannel.h"#include "../common/wrSecMsgCServer.h"#include "ipsecMsgChannel.h"#include "ipsecMsgCServer.h"#include "ipsec_print_routines.h"#include <wrn/ipsec/ipsecStats.h>/* External functions */STATUS ipsecAttachIfHandler(char* configString);STATUS ipsecDetachIfHandler(char* configString);STATUS ipsecDFBitHandler(char* configString);STATUS ipsecSetPMTUAgeHandler(char* configString);STATUS ipsecMonHandler(char* configString);STATUS ipsecDebugHandler(char* configString);void ipsecShowVerHandler(void);STATUS ipsecShowHandler(void);STATUS ipsecShowIfHandler(void);#ifdef INCLUDE_COUNTERS_IPSEC/********************************************************************************* ipsecMsgCServerValidateStatsRequest - validate a stats request.** This routine validates a stats request and if successful attaches to the* associated shared memory. <configString> specifies the address of a * configuration string that will be filled in with the shared memory contents* if successful** RETURNS* TRUE if the validation is successful. FALSE otherwise. If TRUE, the calling* function will be responsible for detaching the shared memory.** NOMANUAL*/BOOL ipsecMsgCServerValidateStatsRequest ( IPSEC_STATS_OPERATION* request, char** configString ) { if ((request->request.subType != IPSEC_STATS) || (request->request.msg.msgLen < sizeof(IPSEC_STATS_OPERATION))) { request->request.retCode = ERROR; return FALSE; } else { /* Attach to the configuration data and call the applicable TSI * configuration request. */ if(request->shMemValid) { *configString = shMemAttach(&request->shMem); if (*configString == NULL) { request->request.retCode = ERROR; return FALSE; } } } return TRUE; } /******************************************************************************** handleStatsRequest() - process IPSEC Statistics Request ** This routine is responsible for processing statistics get requests received* via the message queue.** NOMANUAL*/LOCAL void handleStatsRequest ( IPSEC_STATS_OPERATION* msg ) { char* configString = NULL; STATUS retCode = OK; /* Validate message. In case of an error the status code in the request * message will be updated. */ if (ipsecMsgCServerValidateStatsRequest(msg, &configString) == FALSE) { ipsec_printf(IPSEC_ERROR_PRINTF, "Invalid IPsec Statistics request\n"); msg->request.retCode = ERROR; return; } /* Process the request. */ switch (msg->opCode) {#ifdef INCLUDE_COUNTERS_NETWORK_INTERFACE case IPSEC_IF_STATS_GET: retCode = ipsecIfStatsGetHandler(configString, &msg->params.netIfParams); break;#endif #ifdef INCLUDE_COUNTERS_POLICIES case IPSEC_POLICY_STATS_GET: retCode = ipsecPolicyStatsGetHandler (configString, &msg->params.policyParams.inboundStats, &msg->params.policyParams.outboundStats); break;#endif #ifdef INCLUDE_COUNTERS_PROTECTION_SUITES case PROTECTION_SUITE_STATS_GET: retCode = protectionSuiteStatsGetHandler (configString, &msg->params.psCountParams.psCounts); break; case PROTECTION_SUITE_STATS_GET_BY_SPI: retCode = protectionSuiteStatsGetBySPIHandler (msg->params.psCountParams.spi, &msg->params.psCountParams.psCounts); break;#endif default: retCode = ERROR; break; } msg->request.retCode = retCode; }#endif/********************************************************************************* handleTSIConfigRequest() - Process a IPSEC TSI Configuration Request.** This routine provides the entry point for the server side request handlers* for IPSEC TSI Configuration operations. These requests take a configuration * string as a parameter.* * This routine calls the appropriate handler (based on the operation code)* and after processing fills in the return code with the result from the* operation.** NOMANUAL*/LOCAL void handleTSIConfigRequest(TSI_CONFIG_OPERATION* request) { char* configString = NULL; STATUS retCode = OK; /* Validate message. In case of an error the status code in the request * message will be updated. */ if (wrSecMsgCServerValidateConfigRequest(request, &configString) == FALSE) { ipsec_printf(IPSEC_ERROR_PRINTF, "Invalid IPsec Configuration request\n"); request->request.retCode = ERROR; return; } /* Process the request. */ switch (request->opCode) { case IPSEC_ATTACH_IF: retCode = ipsecAttachIfHandler(configString); break; case IPSEC_DETACH_IF: retCode = ipsecDetachIfHandler(configString); break; case IPSEC_DFBIT: retCode = ipsecDFBitHandler(configString); break; case IPSEC_SET_PMTU_AGE: retCode = ipsecSetPMTUAgeHandler(configString); break; case IPSEC_MON: retCode = ipsecMonHandler(configString); break; case IPSEC_DEBUG: retCode = ipsecDebugHandler(configString); break; default: retCode = ERROR; } /* Release the shared data and fill in the return code */ shMemDetach(&request->shMem); request->request.retCode = retCode; }/********************************************************************************* handleTSINoParamsRequest() - Process a null parameter IPSEC TSI Request.** This routine provides the entry point for the server side request handlers* for IPSEC TSI operations that do not require a configuration * string as a parameter.* * This routine calls the appropriate handler (based on the operation code)* and after processing fills in the return code with the result from the* operation.** NOMANUAL*/LOCAL void handleTSINoParamsRequest(TSI_NO_PARAMS_OPERATION* request) { STATUS retCode = OK; if (wrSecMsgCServerValidateNoParamRequest(request) == FALSE) { ipsec_printf(IPSEC_ERROR_PRINTF, "Invalid IPSEC request\n"); retCode = ERROR; } else { /* Call the applicable TSI request based on the request subtype */ switch (request->opCode) { case IPSEC_SHOW_VER: ipsecShowVerHandler(); retCode = OK; break; case IPSEC_SHOW: retCode = ipsecShowHandler(); break; case IPSEC_SHOW_IF: retCode = ipsecShowIfHandler(); break; default: retCode = ERROR; } } /* Fill in the return code */ request->request.retCode = retCode; }/********************************************************************************* handleTSIBoolGetSet() - Process a TSI BOOL get/set request.** This routine provides the entry point for the server side request handlers* for IPsec TSI operations associated with get/set of a boolean * parameter. * * This routine calls the appropriate handler (based on the operation code)* and after processing fills in the return code with the result from the* operation.** NOMANUAL*/LOCAL void handleTSIBoolGetSet(TSI_BOOL_GET_SET_OPERATION* request) { if (wrSecMsgCServerValidateBoolRequest(request) == FALSE) { ipsec_printf(IPSEC_ERROR_PRINTF, "Invalid IPsec request\n"); request->request.retCode = ERROR; return; } /* Call the applicable TSI request based on the message fields */ switch (request->param) {#ifdef INCLUDE_LOGGING_IPSEC case IPSEC_LOGGER_EVENT_ENABLED: if (request->doSet) { ipsecLoggerLogEventEnabledSetHandler(request->index, request->value); } else { request->value = ipsecLoggerIsLogEventEnabled(request->index); } request->request.retCode = OK; break;#endif default: ipsec_printf(IPSEC_ERROR_PRINTF, "Invalid IPsec client request\n"); request->request.retCode = ERROR; } }/******************************************************************************** ipsecMsgCServerHandleRequest() - handles IPSEC requests** This routine is responsible for processing IPSEC API messages ** NOMANUAL*/void ipsecMsgCServerHandleRequest ( WRSEC_REQUEST* msg /* Request to be processed */ ) { switch (msg->subType) { case TSI_CONFIG: handleTSIConfigRequest((TSI_CONFIG_OPERATION *) msg); msgCReply(msgCMsgSenderGet((MSG_CH_MSG *) msg, NULL), (MSG_CH_MSG *) msg, msg->msg.msgLen, NO_WAIT, NULL); break; case TSI_NO_PARAMS: handleTSINoParamsRequest((TSI_NO_PARAMS_OPERATION *) msg); msgCReply(msgCMsgSenderGet((MSG_CH_MSG *) msg, NULL), (MSG_CH_MSG *) msg, msg->msg.msgLen, NO_WAIT, NULL); break; case TSI_BOOL_GET_SET: handleTSIBoolGetSet((TSI_BOOL_GET_SET_OPERATION *) msg); msgCReply(msgCMsgSenderGet((MSG_CH_MSG *) msg, NULL), (MSG_CH_MSG *) msg, msg->msg.msgLen, NO_WAIT, NULL); break;#ifdef INCLUDE_COUNTERS_IPSEC case IPSEC_STATS: handleStatsRequest((IPSEC_STATS_OPERATION *) msg); msgCReply(msgCMsgSenderGet((MSG_CH_MSG *) msg, NULL), (MSG_CH_MSG *) msg, msg->msg.msgLen, NO_WAIT, NULL); break;#endif default: wrSecMsgCServerHandleUnknownRequest(msg); } }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -