📄 mplcpinterfaces.c
字号:
/* mpLcpInterfaces.c - Mp Related Lcp Interface Functions *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01n,28jan03,ijm fix for SPR# 85936, if LCP is passive, manager's stack does not transition to authentication or network phase, changed logMsg to printf01m,22oct02,sj include mpP.h01l,28jun02,as Redefined the call of function add_new_ppp_option_to_list ()in lcpProxyLcpDo() 01k,28may02,rvr fixed build warnings 01j,28may02,rvr fixed build errors with diab compiler01i,19feb02,ak Releasing state locks in error paths in proxyLcpDo()01h,17feb02,ak support for dynamic assignment of MP Member Stack to Manager Stack01g,04feb02,ak Modified lcpProxyLcpDo() as part of memory reduction process01f,19sep01,ak Removing magic number option from Manager Stack in proxyLcpDo()01e,18sep01,ak Retrieving remote MRU in the lcpMpOptionsGet01d,18aug01,ak Deleting the interface reference to AUTH_INFO_INTERFACE in lcpMpOptionsGet()01c,06jun01,ak Configuring bundle's MRRU as MRU in the Manager Stack01b,05may01,ak added support for controlling authentication on the bundle using profile parameter01a,23feb01,ak created*//*DESCRIPTIONThis file contains functions that implements MP related LCP interface functions.*//* includes */#include "pfw/pfw.h"#include "pfw/pfwInterface.h"#include "pfw/pfwProfile.h"#include "ppp/mp.h"#include "private/ppp/mpP.h"#include "ppp/interfaces/lcpInterfaces.h"#include "ppp/interfaces/authInfoInterface.h"#include "private/ppp/pppLcpComponentP.h"#include "ppp/pppInterfaces.h"#include "string.h"#include "tickLib.h"/* define */#define LCP_MRRU_OPTION_LENGTH 4/* IMPORTS *//* LOCALS */STATUS lcpMpOptionsGet (PFW_PLUGIN_OBJ_STATE *, LCP_BUNDLE_OPTIONS *);STATUS lcpProxyLcpDo (PFW_PLUGIN_OBJ_STATE *, PFW_PLUGIN_OBJ_STATE *); STATUS lcpMpLinkTime (PFW_PLUGIN_OBJ_STATE *);/******************************************************************************** lcpMpOptionsGet - Gets the LCP bundle options negotiated on the link* * This function retrieves the bundle related LCP negotiable option values * negotiated on the given Member Stack. This function is called by * mp_create_bundle_or_add_to_the_bundle () to get he MP options negotiated on * the link to decide to which bundle link has to be added* * RETURNS: OK or ERROR*/STATUS lcpMpOptionsGet ( PFW_PLUGIN_OBJ_STATE *pLcpState, /* LCP state of the Member Stack */ LCP_BUNDLE_OPTIONS *pLcpBundleOptions /* MP options negotiated on the link are filled in this structure */ ) { LCP_STACK_DATA *pStackData = NULL; OPTION_LIST tx_accepted_list; OPTION_LIST rx_accepted_list; PFW_OBJ *pfwObj = NULL; PFW_STACK_OBJ *pMemberStackObj = NULL; PFW_PLUGIN_OBJ_STATE *pState = NULL; OPTION_LIST_ENTRY *pOptionEntry = NULL; PFW_PLUGIN_OBJ *pPluginObj = NULL; AUTH_INFO_INTERFACE *pAuthMpInterfaceObj = NULL; UINT authMpInterfaceId = 0; char *pTemp = NULL; if (pfwPluginObjStateLock(pLcpState) == ERROR) return ERROR; pStackData = pLcpState->stackData; pMemberStackObj = pLcpState->stackObj; /* Get accepted lists on sending end and receiving end */ tx_accepted_list = pStackData->option_lists.tx_accepted; rx_accepted_list = pStackData->option_lists.rx_accepted; pfwObj = pfwStackObjPfwGet (pMemberStackObj); if (pfwObj == NULL) { pfwPrintError (__FILE__, "lcpMpOptionsGet", __LINE__, 0, 0, "NULL Framework reference"); if (pfwPluginObjStateRelease(pLcpState) == ERROR) return ERROR; return ERROR; } /* Get local MRU */ pOptionEntry = find_matching_option(&tx_accepted_list, LCP_MAXIMUM_RECEIVE_UNIT); if (pOptionEntry != NULL) pLcpBundleOptions->localMRU = ntohs (pOptionEntry->uptr_data->_ushort); else pLcpBundleOptions->localMRU = 1500; /* Get remote MRU */ pOptionEntry = find_matching_option(&rx_accepted_list, LCP_MAXIMUM_RECEIVE_UNIT); if (pOptionEntry != NULL) pLcpBundleOptions->remoteMRU = ntohs (pOptionEntry->uptr_data->_ushort); else pLcpBundleOptions->remoteMRU = 1500; /* Get local MRRU */ pOptionEntry = find_matching_option(&tx_accepted_list, LCP_MULTILINK_MAXIMUM_RECEIVED_RECONSTRUCTED_UNIT); if (pOptionEntry != NULL) { pLcpBundleOptions->is_link_in_receiving_end = TRUE; pLcpBundleOptions->localMRRU = ntohs (pOptionEntry->uptr_data->_ushort); } else { pLcpBundleOptions->is_link_in_receiving_end = FALSE; } /* Get remote MRRU */ pOptionEntry = find_matching_option(&rx_accepted_list, LCP_MULTILINK_MAXIMUM_RECEIVED_RECONSTRUCTED_UNIT); if (pOptionEntry != NULL) { pLcpBundleOptions->is_link_in_sending_end = TRUE; pLcpBundleOptions->remoteMRRU = ntohs (pOptionEntry->uptr_data->_ushort); } else pLcpBundleOptions->is_link_in_sending_end = FALSE; /* Get SSNHF for local end */ pOptionEntry = find_matching_option(&tx_accepted_list, LCP_MULTILINK_SHORT_SEQUENCE_NUMBER_HEADER_FORMAT); if (pOptionEntry != NULL) { pLcpBundleOptions->use_short_sequence_number_in_rx_end = TRUE; } else pLcpBundleOptions->use_short_sequence_number_in_rx_end = FALSE; /* Get SSNHF for remote end */ pOptionEntry = find_matching_option(&rx_accepted_list, LCP_MULTILINK_SHORT_SEQUENCE_NUMBER_HEADER_FORMAT); if (pOptionEntry != NULL) { pLcpBundleOptions->use_short_sequence_number_in_tx_end = TRUE; } else pLcpBundleOptions->use_short_sequence_number_in_tx_end = FALSE; /*Local End Point Discriminator */ pOptionEntry = find_matching_option(&tx_accepted_list, LCP_ENDPOINT_DISCRIMINATOR); if (pOptionEntry != NULL) { pLcpBundleOptions->bundle_identifier.local_station_discriminator .discriminatorClass = *((BYTE *)pOptionEntry->uptr_data); pLcpBundleOptions->bundle_identifier.local_station_discriminator.length = (pOptionEntry->length - 1); pTemp = (char *)pOptionEntry->uptr_data; memcpy ((void *)pLcpBundleOptions->bundle_identifier. local_station_discriminator.address, (const void *) (pTemp + 1), (pLcpBundleOptions->bundle_identifier. local_station_discriminator.length)); } else { pLcpBundleOptions-> bundle_identifier.local_station_discriminator.discriminatorClass = 0; pLcpBundleOptions->bundle_identifier.local_station_discriminator.length = 0; } /*Remote End Point Discriminator */ pOptionEntry = find_matching_option(&rx_accepted_list, LCP_ENDPOINT_DISCRIMINATOR); if (pOptionEntry != NULL) { pLcpBundleOptions->bundle_identifier.remote_station_discriminator .discriminatorClass = *((BYTE *)pOptionEntry->uptr_data); pLcpBundleOptions->bundle_identifier.remote_station_discriminator.length = (pOptionEntry->length - 1); pTemp = (char *)pOptionEntry->uptr_data; memcpy ((void *)pLcpBundleOptions->bundle_identifier. remote_station_discriminator.address, (const void *) (pTemp + 1), (pLcpBundleOptions->bundle_identifier. remote_station_discriminator.length)); } else { pLcpBundleOptions->bundle_identifier. remote_station_discriminator.discriminatorClass = 0; pLcpBundleOptions->bundle_identifier. remote_station_discriminator.length = 0; } /* Local Authentication Protocol */ pOptionEntry = find_matching_option(&tx_accepted_list, LCP_AUTHENTICATION_PROTOCOL); if (pOptionEntry != NULL) { pLcpBundleOptions->localAuthProtocol = ntohs (pOptionEntry->uptr_data->_ushort); pPluginObj = (PFW_PLUGIN_OBJ *)pfwComponentObjGetByProtocol (pfwObj, pLcpBundleOptions->localAuthProtocol); if (pPluginObj == NULL) {#ifdef PPP_DEBUG printf ("MP:lcpMpOptionsGet():protocol 0x%x does not exist\n", pLcpBundleOptions->localAuthProtocol);#endif /* PPP_DEBUG */ if (pfwPluginObjStateRelease(pLcpState) == ERROR) return ERROR; return ERROR; } pState = pfwPluginObjStateGet (pMemberStackObj, pPluginObj); if (pState == NULL) {#ifdef PPP_DEBUG printf ("MP:lcpMpOptionsGet(): proto 0x%x does not exist in stack 0x%x\n", pLcpBundleOptions->localAuthProtocol,(int) pMemberStackObj); #endif /* PPP_DEBUG */ if (pfwPluginObjStateRelease(pLcpState) == ERROR) return ERROR; return ERROR; } /* * Get the local user name configured in the local authentication * component */ authMpInterfaceId = pfwInterfaceIdGet (pfwObj, "AUTH_INFO_INTERFACE"); if (authMpInterfaceId == 0) { pfwPrintError (__FILE__, "lcpMpOptionsGet", __LINE__, 0, 0, "AUTH_INFO_INTERFACE is not available"); if (pfwPluginObjStateRelease(pLcpState) == ERROR) return ERROR; return ERROR; } pAuthMpInterfaceObj = (AUTH_INFO_INTERFACE *) pfwInterfaceObjGetViaPluginObj (pPluginObj, authMpInterfaceId); if (pAuthMpInterfaceObj == NULL) {#ifdef PPP_DEBUG printf ("MP:lcpMpOptionsGet(): No AUTH_INFO_INTERFACE for proto 0x%x\n", pLcpBundleOptions->localAuthProtocol);#endif /* PPP_DEBUG */ if (pfwPluginObjStateRelease(pLcpState) == ERROR) return ERROR; return ERROR; } pAuthMpInterfaceObj->localUserNameGet (pState, pLcpBundleOptions->bundle_identifier.local_user_name); if (pfwInterfaceReferenceDelete (&pAuthMpInterfaceObj->interfaceObj) == ERROR) {#ifdef PPP_DEBUG printf ("MP:lcpMpOptionsGet(): Can't delete reference to AUTH_INFO_INTERFACE\n");#endif /* PPP_DEBUG */ if (pfwPluginObjStateRelease(pLcpState) == ERROR) return ERROR; return ERROR; } } /* Remote Authentication Protocol */ pOptionEntry = find_matching_option(&rx_accepted_list, LCP_AUTHENTICATION_PROTOCOL); if (pOptionEntry != NULL) { pLcpBundleOptions->remoteAuthProtocol = ntohs (pOptionEntry->uptr_data->_ushort); pPluginObj = (PFW_PLUGIN_OBJ *)pfwComponentObjGetByProtocol (pfwObj, pLcpBundleOptions->remoteAuthProtocol); if (pPluginObj == NULL) {#ifdef PPP_DEBUG printf ("MP:lcpMpOptionsGet(): protocol 0x%x does not exist\n", pLcpBundleOptions->remoteAuthProtocol);#endif /* PPP_DEBUG */ if (pfwPluginObjStateRelease(pLcpState) == ERROR) return ERROR; return ERROR; } pState = pfwPluginObjStateGet (pMemberStackObj, pPluginObj); if (pState == NULL) {#ifdef PPP_DEBUG printf ("MP:lcpMpOptionsGet(): proto 0x%x does not exist in stack 0x%x\n", pLcpBundleOptions->remoteAuthProtocol, (int) pMemberStackObj);#endif /* PPP_DEBUG */ if (pfwPluginObjStateRelease(pLcpState) == ERROR) return ERROR; return ERROR; } /* * Get the remote user name configured in the remote authentication * component */ authMpInterfaceId = pfwInterfaceIdGet (pfwObj, "AUTH_INFO_INTERFACE"); if (authMpInterfaceId == 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -