📄 pppoptnp.c
字号:
case sizeof (ULONG): printf ("Min: %ld Max: %ld Step: %ld\n", ntohl(sptr_option->range_option->uptr_lowest_value->_ulong), ntohl(sptr_option->range_option->uptr_highest_value->_ulong), ntohl(sptr_option->range_option->uptr_step->_ulong) ); break; } } return; }/******************************************************************************** ppp_configure_nak_option_processor -*/TEST ppp_configure_nak_option_processor ( OPTION_LIST_ENTRY *sptr_remote_option, OPTION_LISTS *sptr_option_lists, /* LCP option lists */ PFW_PLUGIN_OBJ_STATE * pluginState ) { OPTION_LIST_ENTRY *sptr_local_option = NULL; ALTERNATE_OPTION *sptr_alternate_option = NULL; sptr_local_option = find_matching_option ( &sptr_option_lists->tx_accepted, sptr_remote_option->type.generic); /* this should never happen but just in case */ if (sptr_local_option == NULL) return (FAIL); if (sptr_local_option->option_flags.negotiable == PPP_FLAG_OFF) { /* close the connection */ ppp_negotiation_error (pluginState, sptr_remote_option, sptr_option_lists); return (FAIL); } /* if it's EID then remove it from the configure request RFC 1990 page 17 */ if (sptr_remote_option->type.generic == LCP_ENDPOINT_DISCRIMINATOR && sptr_local_option->option_flags.negotiable == PPP_FLAG_ON) { remove_configuration_option (&sptr_option_lists->tx_accepted, LCP_ENDPOINT_DISCRIMINATOR); return (PASS); } if (sptr_local_option->option_flags.range_checking_enabled == PPP_FLAG_OFF && sptr_local_option->option_flags.alternate_checking_enabled == PPP_FLAG_OFF) { /* IPV6 Support */ if (strcmp (pluginState->pluginObj->name, "PPP_IPV6CP") == 0) { if (sptr_remote_option->type.generic == IPV6_INTERFACE_IDENTIFIER_OPTION_TYPE) { nakProcessingCheckForInterfaceIdentifier (sptr_option_lists, sptr_remote_option, sptr_local_option, pluginState); return (PASS); } } /* IPV6 Support */ /* * manager has not restricted option values: accept anything * peer proposes. IP addresses, for example, would be * configured this way when the local side must obtain * an address asigned by the remote side. */ if (sptr_local_option->length == sptr_remote_option->length) { memcpy (sptr_local_option->uptr_data, sptr_remote_option->uptr_data, sptr_remote_option->length); } else { replace_data_field_in_option (pluginState->pluginObj->pfwObj, sptr_local_option, sptr_remote_option->uptr_data, sptr_remote_option->length); } return (PASS); } /* check configured values */ if (option_value_match (sptr_local_option,sptr_remote_option) != NULL) { return (PASS); } sptr_alternate_option = alternate_option_value_match (sptr_local_option, sptr_remote_option); if (sptr_alternate_option != NULL) { replace_data_field_in_option (pluginState->pluginObj->pfwObj, sptr_local_option, sptr_alternate_option->uptr_data, sptr_alternate_option->length); return (PASS); } if (range_option_value_match (sptr_local_option,sptr_remote_option) == TRUE) { replace_data_field_in_option (pluginState->pluginObj->pfwObj, sptr_local_option, sptr_remote_option->uptr_data,sptr_remote_option->length); return (PASS); }#if 0 /* do not accept options that may not be supported */ replace_data_field_in_option (pluginState->pluginObj->pfwObj, sptr_local_option, sptr_remote_option->uptr_data,sptr_remote_option->length); return (PASS);#endif if (set_option_values_from_nak (pluginState->pluginObj->pfwObj, sptr_option_lists, sptr_local_option)== PASS) {#ifdef PPP_DEBUG printf ("Found option:\n"); option_entry_print (sptr_local_option);#endif return PASS; }/* IPV6 Support */ /* * If none of the above succeeds for IPV6 Interface Identifier option, * Do a final check if you can accept the peer suggested and then accept. */ if (strcmp (pluginState->pluginObj->name, "PPP_IPV6CP") == 0) { if (sptr_remote_option->type.generic == IPV6_INTERFACE_IDENTIFIER_OPTION_TYPE) { nakProcessingCheckForInterfaceIdentifier (sptr_option_lists, sptr_remote_option, sptr_local_option, pluginState); return (PASS); } }/* IPV6 Support */#if 0 /* * we could start from the beginining again, and rely on the peer * to give up first when it reaches maximum failures, and sends us * a reject, but it is safer for us to call it quits now to * avoid an endless loop * */ /* * set_option_values_from_nak resets the nak_option_selected counter * allowing us to start over with the first configured value. The * peer may send us a configure reject before convergence occurs. * */ if (set_option_values_from_nak (pluginState->pluginObj->pfwObj, sptr_option_lists, sptr_local_option)== PASS) {#ifdef PPP_DEBUG printf ("Starting over with option:\n"); option_entry_print (sptr_local_option);#endif return PASS; }#endif /* propose all the available options only once */ ppp_negotiation_error (pluginState, sptr_remote_option, sptr_option_lists); return FAIL; }/* IPV6 Support *//******************************************************************************** nakProcessingCheckForInterfaceIdentifier - To check local and remote * Interface-Identifier is equal to zero */LOCAL void nakProcessingCheckForInterfaceIdentifier ( OPTION_LISTS * sptr_option_lists, OPTION_LIST_ENTRY * sptr_remote_option, OPTION_LIST_ENTRY * sptr_local_option, PFW_PLUGIN_OBJ_STATE * pluginState ) { IPV6CP_STACK_DATA * pStackData = pluginState->stackData; int index = 0; int sum = 0; /* * Recvd Interface-Identifier is equal to the one sent in the * last Configure-Nak, a new Interface-Identifier MUST be chosen. * In this case, a new Configure-Request SHOULD be sent with the * new tentative Interface-Identifier */ /* * And also if Recvd Interface-Identifier is equal to a zero then * new Interface-Identifier MUST be chosen */ for (index = 0, sum=0; index < sptr_remote_option->length; index++) sum = sum + sptr_remote_option->uptr_data->byte_array[index]; if ((memcmp (sptr_remote_option->uptr_data, pStackData->lastSentNakIdentifier, sptr_remote_option->length) == 0) || (sum == 0)) { generateNewInterfaceIdentifier (sptr_local_option); return; } /* * Suggested Interface-Identifier different from that of the last * Configure-Nak sent to the peer indicates a unique * Interface-Identifier. In this case a new Configure-Request MUST * be sent with the identifier value suggested in the last * Configure-Nak from the peer. */ replace_data_field_in_option (pluginState->pluginObj->pfwObj, sptr_local_option, sptr_remote_option->uptr_data, sptr_remote_option->length); return; }/* IPV6 Support */#if 0/******************************************************************************** process_configuration_options -*/TEST process_configuration_options ( PFW_PLUGIN_OBJ_STATE * pluginState, OPTION_LISTS *sptr_option_lists, /* option lists */ M_BLK_ID mblk_rx_packet ) { OPTION_PARSE_RESULT parse_result; parse_result = parse_ppp_options_from_configure_request (sptr_option_lists, mblk_rx_packet,pluginState); if (parse_result == SOME_OPTIONS_ARE_REJECTED) { execute_ppp_state_machine (pluginState, PPP_RECEIVE_CONFIG_REQUEST_BAD_OPTION_EVENT, mblk_rx_packet); return (FAIL); } else if (parse_result == SOME_OPTIONS_ARE_NACKED) { execute_ppp_state_machine (pluginState, PPP_RECEIVE_CONFIGURE_REQUEST_BAD_EVENT, mblk_rx_packet); return (FAIL); } else { return (PASS); } }/******************************************************************************** process_configuration_nak_options -*/TEST process_configuration_nak_options ( PFW_PLUGIN_OBJ_STATE * pluginState, OPTION_LISTS * sptr_option_lists, /* option lists */ M_BLK_ID mblk_rx_packet ) { parse_ppp_options_from_nak_configure (sptr_option_lists, mblk_rx_packet, pluginState); return (PASS); }#endif/******************************************************************************** option_value_match - */OPTION_LIST_ENTRY *option_value_match ( OPTION_LIST_ENTRY *sptr_local_option, OPTION_LIST_ENTRY *sptr_remote_option ) { OPTION_LIST_ENTRY *sptr_next_local = NULL; if (sptr_local_option->length != sptr_remote_option->length) { for (sptr_next_local = find_next_matching_option (sptr_local_option); sptr_next_local != NULL; sptr_next_local = find_next_matching_option (sptr_next_local)) { if (sptr_local_option->length == sptr_remote_option->length) { if (memcmp (sptr_next_local->uptr_data, sptr_remote_option->uptr_data, sptr_local_option->length) == (int) NULL) { return (sptr_next_local); } } } } else { if (memcmp (sptr_local_option->uptr_data,sptr_remote_option->uptr_data, sptr_local_option->length) == (int) NULL) { return (sptr_local_option); } } return (NULL); }/******************************************************************************** find_next_matching_option -*/LOCAL OPTION_LIST_ENTRY *find_next_matching_option ( OPTION_LIST_ENTRY *sptr_option ) { OPTION_LIST_ENTRY *sptr_matching_option = NULL; for (sptr_matching_option = sptr_option->sptr_forward_link; sptr_matching_option != NULL; sptr_matching_option = sptr_matching_option->sptr_forward_link) { if (sptr_matching_option->type.generic == sptr_option->type.generic) { break; } } return (sptr_matching_option); }/******************************************************************************** alternate_option_value_match -*/ALTERNATE_OPTION *alternate_option_value_match ( OPTION_LIST_ENTRY *sptr_local_option, OPTION_LIST_ENTRY *sptr_remote_option ) { ALTERNATE_OPTION *sptr_alternate_option = NULL; if (sptr_local_option->option_flags.alternate_checking_enabled == PPP_FLAG_OFF) { return (NULL); } for (sptr_alternate_option = sptr_local_option->alternate_option_list.sptr_forward_link; sptr_alternate_option != NULL; sptr_alternate_option = sptr_alternate_option->links.sptr_forward_link) { if (sptr_alternate_option->length == sptr_remote_option->length) { if (memcmp (sptr_alternate_option->uptr_data, sptr_remote_option->uptr_data, sptr_alternate_option->length) == (int) NULL) { return (sptr_alternate_option); } } } return (NULL); }/******************************************************************************** range_option_value_match -*/BOOLEAN range_option_value_match ( OPTION_LIST_ENTRY *sptr_local_option, OPTION_LIST_ENTRY *sptr_remote_option ) { UNION_OPTION_DATA_TYPES *uptr_matching_option_data = NULL; USHORT option_length = 0; BYTE *bptr_step_option = NULL; BOOL stepIsZero = TRUE; if (sptr_local_option->option_flags.range_checking_enabled == PPP_FLAG_OFF) { return (FALSE); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -