📄 pppradiuscomponent.c
字号:
if (phyPortInterface != NULL) { nasPort = htonl(phyPortInterface->portNumberGet(adapterState)); nasPortType = htonl(phyPortInterface->portTypeGet(adapterState)); } bzero(pap->userName, strlen(userName) + 1); bzero(pap->password, strlen(password) + 1); bcopy(userName, pap->userName, strlen(userName)); bcopy(password, pap->password, strlen(password)); pap->id = id; pap->pfw = pfw; pap->state = state; pap->pStackData = pStackData; pap->radiusCallbacks = radiusCallbacks; pap->attributeRequestHandle = attributeListHandle; pStackData->state = state; radius_add_attribute_to_list (attributeListHandle, RADIUS_USER_NAME, strlen(userName), userName); radius_add_attribute_to_list (attributeListHandle, RADIUS_USER_PASSWORD, strlen(password), password); radius_add_attribute_to_list (attributeListHandle, RADIUS_SERVICE_TYPE, 4, (BYTE *) &pStackData->serviceType); radius_add_attribute_to_list (attributeListHandle, RADIUS_FRAMED_PROTOCOL, 4, (BYTE *) &pStackData->framedProtocol); if (phyPortInterface != NULL) { radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_PORT, 4, (BYTE *) &nasPort); radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_PORT_TYPE, 4, (BYTE *) &nasPortType); } if (pStackData->nasIdentifier != NULL) radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_IDENTIFIER, strlen(pStackData->nasIdentifier), pStackData->nasIdentifier); if (pStackData->nasIPaddress != 0) radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_IP_ADDRESS, 4, (BYTE *) &pStackData->nasIPaddress); radiusClearRcvdAttr(&pStackData->rcvdAttributes); pStackData->radiusState |= RADIUS_PAP_AUTH_PENDING; ++pStackData->numberOfRadiusPendingRequest; pfwPluginObjStateRelease (state); netJobAdd((FUNCPTR) radiusSendRequest, (int) authServerHandle, (int) pap, (int) &pStackData->papRequestCallbacks, (int) RADIUS_ACCESS_REQUEST, (int) pap->attributeRequestHandle); }/******************************************************************************** accountingStart - Start accounting for the user** Send an RADIUS_ACCOUNTING_REQUEST to the RADIUS server*/LOCAL void accountingStart ( PFW_PLUGIN_OBJ_STATE * state ) { RADIUS_SERVER_HANDLE acctServerHandle; RADIUS_ATTRIBUTE_LIST_HANDLE attributeListHandle; RADIUS_RECEIVED_ATTRIBUTES * attr; ACCOUNTING_DATA * acct; PFW_OBJ * pfw; RADIUS_STACK_DATA * pStackData; PFW_PLUGIN_OBJ_STATE * adapterState; PHY_PORT_INTERFACE * phyPortInterface; UINT nasPort, nasPortType; pfw = state->pluginObj->pfwObj; pStackData = (RADIUS_STACK_DATA *) state->stackData; if (pfwPluginObjStateLock (state) == ERROR) { logMsg("accountingStart - unable to lock state\n", 0, 0, 0, 0, 0, 0 ); return; } if ((pStackData->radiusState & RADIUS_STACK_DEL_PENDING) || (pStackData->radiusState & RADIUS_ACCT_ERROR)) { pfwPluginObjStateRelease (state); return; } /* Ignore accounting request if previous request is pending */ if ((pStackData->radiusState & RADIUS_ACCT_START_PENDING) || (pStackData->radiusState & RADIUS_ACCT_STOP_PENDING) || (pStackData->radiusState & RADIUS_ACCT_STARTED) || !(pStackData->radiusFlags & RADIUS_ALLOW_ACCOUNTING)) { pfwPluginObjStateRelease (state);#ifdef PPP_DEBUG logMsg("Accounting Start Ignoring...State %x Flags %x\n", pStackData->radiusState, pStackData->radiusFlags, 0, 0, 0, 0);#endif /* PPP_DEBUG */ return; } if ((acctServerHandle = get_radius_server(&pStackData->acctServerData, RADIUS_ACCOUNTING_SERVER_TYPE)) == INVALID_HANDLE) { pfwPluginObjStateRelease (state); return; } acct = &pStackData->acctData; attr = &pStackData->rcvdAttributes; attributeListHandle = radius_create_attribute_list(); if ((attributeListHandle == INVALID_HANDLE)) { pfwPluginObjStateRelease (state); return; } phyPortInterface = (PHY_PORT_INTERFACE *) pStackData->physicalPortInterface.interfaceObj; adapterState = pStackData->physicalPortInterface.state; if (phyPortInterface != NULL) { nasPort = htonl(phyPortInterface->portNumberGet(adapterState)); nasPortType = htonl(phyPortInterface->portTypeGet(adapterState)); } acct->pfw = pfw; acct->state = state; acct->pStackData = pStackData; acct->attributeRequestHandle = attributeListHandle; pStackData->state = state; radius_add_attribute_to_list (attributeListHandle, RADIUS_ACCT_STATUS_TYPE, 4, (BYTE *) &pStackData->acctStart); radius_add_attribute_to_list (attributeListHandle, RADIUS_SERVICE_TYPE, 4, (BYTE *) &pStackData->serviceType); radius_add_attribute_to_list (attributeListHandle, RADIUS_FRAMED_PROTOCOL, 4, (BYTE *) &pStackData->framedProtocol); radius_add_attribute_to_list (attributeListHandle, RADIUS_ACCT_SESSION_ID, strlen(pStackData->sessionId), pStackData->sessionId); if (phyPortInterface != NULL) { radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_PORT, 4, (BYTE *) &nasPort); radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_PORT_TYPE, 4, (BYTE *) &nasPortType); } if (attr->userName != NULL) radius_add_attribute_to_list (attributeListHandle, RADIUS_USER_NAME, strlen(attr->userName), attr->userName); if (attr->class != NULL) radius_add_attribute_to_list (attributeListHandle, RADIUS_CLASS_ATTRIBUTE, strlen(attr->class), attr->class); if (pStackData->nasIdentifier != NULL) radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_IDENTIFIER, strlen(pStackData->nasIdentifier), pStackData->nasIdentifier); if (pStackData->nasIPaddress != 0) radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_IP_ADDRESS, 4, (BYTE *) &pStackData->nasIPaddress); pStackData->radiusState |= RADIUS_ACCT_START_PENDING; ++pStackData->numberOfRadiusPendingRequest; pfwPluginObjStateRelease (state); netJobAdd((FUNCPTR) radiusSendRequest, (int) acctServerHandle, (int) acct, (int) &pStackData->acctRequestCallbacks, (int) RADIUS_ACCOUNTING_REQUEST, (int) acct->attributeRequestHandle); }/******************************************************************************** accountingStop - Stop accounting for the user** Send an RADIUS_ACCOUNTING_REQUEST to the RADIUS server*/LOCAL void accountingStop ( PFW_PLUGIN_OBJ_STATE * state ) { RADIUS_SERVER_HANDLE acctServerHandle; RADIUS_ATTRIBUTE_LIST_HANDLE attributeListHandle; RADIUS_RECEIVED_ATTRIBUTES * attr; ACCOUNTING_DATA * acct; PFW_OBJ * pfw; RADIUS_STACK_DATA * pStackData; PFW_PLUGIN_OBJ_STATE * adapterState; PHY_PORT_INTERFACE * phyPortInterface; UINT nasPort, nasPortType; UINT inputOctets, outputOctets; UINT inputPackets, outputPackets; ADAPTER_COMPONENT_STATISTICS_INTERFACE *statisticsInterface; pfw = state->pluginObj->pfwObj; pStackData = (RADIUS_STACK_DATA *) state->stackData; if (pfwPluginObjStateLock (state) == ERROR) { logMsg("accountingStop - unable to lock state\n", 0, 0, 0, 0, 0, 0 ); return; } if (!(pStackData->radiusState & (RADIUS_ACCT_STARTED | RADIUS_ACCT_START_PENDING)) || (pStackData->radiusState & RADIUS_ACCT_ERROR) || ((pStackData->radiusState & RADIUS_ACCT_STOP_PENDING) || (pStackData->radiusState & RADIUS_ACCT_STOP_QUEUED) || !(pStackData->radiusFlags & RADIUS_ALLOW_ACCOUNTING))) { pfwPluginObjStateRelease (state);#ifdef PPP_DEBUG logMsg("Accounting Stop Ignoring...State %x Flags %x\n", pStackData->radiusState, pStackData->radiusFlags, 0, 0, 0, 0);#endif /* PPP_DEBUG */ return; } acct = &pStackData->acctData; attr = &pStackData->rcvdAttributes; attributeListHandle = radius_create_attribute_list(); if ((attributeListHandle == INVALID_HANDLE)) { pfwPluginObjStateRelease (state); return; } if ((acctServerHandle = get_radius_server(&pStackData->acctServerData, RADIUS_ACCOUNTING_SERVER_TYPE)) == INVALID_HANDLE) { pfwPluginObjStateRelease (state); return; } phyPortInterface = (PHY_PORT_INTERFACE *) pStackData->physicalPortInterface.interfaceObj; statisticsInterface = (ADAPTER_COMPONENT_STATISTICS_INTERFACE *) pStackData->adapterStatisticsInterface.interfaceObj; adapterState = pStackData->physicalPortInterface.state; if (phyPortInterface != NULL) { nasPort = htonl(phyPortInterface->portNumberGet(adapterState)); nasPortType = htonl(phyPortInterface->portTypeGet(adapterState)); } if (statisticsInterface != NULL) { (statisticsInterface->statisticsGet) (adapterState, &inputOctets, &outputOctets, &inputPackets, &outputPackets); HTONL(inputOctets); HTONL(outputOctets); HTONL(inputPackets); HTONL(outputPackets); } acct->pfw = pfw; acct->state = state; acct->pStackData = pStackData; acct->acctServerHandle = acctServerHandle; acct->attributeRequestHandle = attributeListHandle; pStackData->state = state; radius_add_attribute_to_list (attributeListHandle, RADIUS_ACCT_STATUS_TYPE, 4, (BYTE *) &pStackData->acctStop); radius_add_attribute_to_list (attributeListHandle, RADIUS_SERVICE_TYPE, 4, (BYTE *) &pStackData->serviceType); radius_add_attribute_to_list (attributeListHandle, RADIUS_FRAMED_PROTOCOL, 4, (BYTE *) &pStackData->framedProtocol); radius_add_attribute_to_list (attributeListHandle, RADIUS_ACCT_SESSION_ID, strlen(pStackData->sessionId), pStackData->sessionId); if (phyPortInterface != NULL) { radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_PORT, 4, (BYTE *) &nasPort); radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_PORT_TYPE, 4, (BYTE *) &nasPortType); } if (statisticsInterface != NULL) { radius_add_attribute_to_list (attributeListHandle, RADIUS_ACCT_INPUT_OCTETS, 4, (BYTE *) &inputOctets); radius_add_attribute_to_list (attributeListHandle, RADIUS_ACCT_OUTPUT_OCTETS, 4, (BYTE *) &outputOctets); radius_add_attribute_to_list (attributeListHandle, RADIUS_ACCT_INPUT_PACKETS, 4, (BYTE *) &inputPackets); radius_add_attribute_to_list (attributeListHandle, RADIUS_ACCT_OUTPUT_PACKETS, 4, (BYTE *) &outputPackets); } if (attr->userName != NULL) radius_add_attribute_to_list (attributeListHandle, RADIUS_USER_NAME, strlen(attr->userName), attr->userName); if (attr->class != NULL) radius_add_attribute_to_list (attributeListHandle, RADIUS_CLASS_ATTRIBUTE, strlen(attr->class), attr->class); if (pStackData->nasIdentifier != NULL) radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_IDENTIFIER, strlen(pStackData->nasIdentifier), pStackData->nasIdentifier); if (pStackData->nasIPaddress != 0) radius_add_attribute_to_list (attributeListHandle, RADIUS_NAS_IP_ADDRESS, 4, (BYTE *) &pStackData->nasIPaddress); if ((pStackData->radiusState & RADIUS_ACCT_STARTED)) { ++pStackData->numberOfRadiusPendingRequest; pStackData->radiusState &= ~RADIUS_ACCT_STARTED; pStackData->radiusState |= RADIUS_ACCT_STOP_PENDING; pfwPluginObjStateRelease (state); netJobAdd((FUNCPTR) radiusSendRequest, (int) acctServerHandle, (int) acct, (int) &pStackData->acctRequestCallbacks, (int) RADIUS_ACCOUNTING_REQUEST, (int) acct->attributeRequestHandle); } else { pStackData->radiusState |= RADIUS_ACCT_STOP_QUEUED; pfwPluginObjStateRelease (state); } }/******************************************************************************** get_radius_server - Get the configured RADIUS server**/LOCAL RADIUS_SERVER_HANDLE get_radius_server ( RADIUS_SERVER_DATA * serverData, enum RADIUS_SERVER_TYPE type ) { RADIUS_SERVER_CONFIG * serverConfig; RADIUS_SERVER_HANDLE serverHandle; RADIUS_SERVER_HANDLE newServerHandle; serverHandle = serverData->serverHandle; if ((serverData->serverFlag & RADIUS_SERVER_OTHER) && ((serverData->serverFlag & RADIUS_SERVER_TRYNEXT) || (serverHandle == INVALID_HANDLE))) { if (serverHandle != INVALID_HANDLE) { radius_free_server_handle(serverHandle); } serverConfig = &serverData->serverConfig[serverData->serverIndex++];#ifdef PPP_DEBUG logMsg("Trying %x server %s, port %x\n", (int) serverData->serverIndex, (int) serverConfig->IpAddress, (int) serverConfig->portNumber, 0, 0, 0);#endif /* PPP_DEBUG */ if (serverData->serverIndex == serverData->serverCount) { serverData->serverIndex = 0; } serverHandle = radius_find_server_with_specified_parameters( serverConfig->IpAddress, serverConfig->portNumber, type); serverData->serverFlag &= ~RADIUS_SERVER_TRYNEXT; } if ((serverData->serverFlag & RADIUS_SERVER_ALL) && (serverData->serverFlag & RADIUS_SERVER_TRYNEXT) && (serverHandle != INVALID_HANDLE)) {#ifdef PPP_DEBUG logMsg("Trying next server, type %x\n", type, 0, 0, 0, 0, 0);#endif /* PPP_DEBUG */ newServerHandle = radius_get_next_server(serverHandle, type); serverData->serverFlag &= ~RADIUS_SERVER_TRYNEXT; radius_free_server_handle(serverHandle); serverHandle = newSer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -