📄 pppoptn.c
字号:
/* IPV6 Support */ sptr_receive_list_option = (OPTION_LIST_ENTRY *) get_entry_from_list ((LINK *) &sptr_option_lists->received); while (sptr_receive_list_option != NULL) {#ifdef CHECK_FOR_DUPLICATE_OPTIONS_IN_CONFIG_REQUEST /* check if the same option is listed again */ if (find_matching_option(&sptr_option_lists->received, sptr_receive_list_option->type.generic) != NULL) { return (OPTION_PARSING_ERROR); }#endif /*CHECK_FOR_DUPLICATE_OPTIONS_IN_CONFIG_REQUEST*/ sptr_configured_option = find_matching_option ( &sptr_option_lists->remote_configured, /*&sptr_option_lists->configured,*/ sptr_receive_list_option->type.generic); sptr_localConfigured_option = find_matching_option ( &sptr_option_lists->configured, sptr_receive_list_option->type.generic); if (sptr_configured_option == NULL) { add_entry_to_list ((LINK *) &sptr_option_lists->tx_reject, (LINK *) sptr_receive_list_option); return_code = SOME_OPTIONS_ARE_REJECTED; } else { option_value_ok = ppp_configure_request_option_processor (sptr_receive_list_option, sptr_option_lists,pluginState); if (option_value_ok == PASS) { add_entry_to_list ((LINK *) &sptr_option_lists->rx_accepted, (LINK *) sptr_receive_list_option); } else { /* IPV6 Support */ if (strcmp (pluginState->pluginObj->name, "PPP_IPV6CP") == 0) { if (sptr_receive_list_option->type.generic == IPV6_INTERFACE_IDENTIFIER_OPTION_TYPE) { if (checkIpv6InterfaceIdentifierForZero (sptr_localConfigured_option, sptr_receive_list_option) == OK) { add_entry_to_list ((LINK *) &sptr_option_lists->tx_reject, (LINK *) sptr_receive_list_option); return_code = SOME_OPTIONS_ARE_REJECTED; } } } /* IPV6 Support */ if (return_code == OPTIONS_RECEIVED_ARE_OK) { return_code = SOME_OPTIONS_ARE_NACKED; } add_entry_to_list ((LINK *) &sptr_option_lists->tx_nak, (LINK *) sptr_receive_list_option); } } sptr_receive_list_option = (OPTION_LIST_ENTRY *) get_entry_from_list ((LINK *) &sptr_option_lists->received); } if (return_code == SOME_OPTIONS_ARE_REJECTED) resetNakOptionSelectedField (&sptr_option_lists->remote_configured); return (return_code); }/* IPV6 Support *//******************************************************************************** generateConfigureNakForInterfaceIdentifier - * To genrate NAK for IPV6 Interface-Identifier option* * RFIC 2472 (Page 8; Paragraph 4)** If negotiation of the Interface-Identifier is required, and the peer did not * provide the option in its Configure-Request, the option SHOULD be appended to * a Configure-Nak. The tentative value of the Interface-Identifier given must be * acceptable as the remote Interface-Identifier; i.e. it should be different from * the identifier value selected for the local end of the PPP link. The next * Configure-Request from the peer may include this option. If the next * Configure-Request does not include this option the peer MUST NOT send another * Configure-Nak with this option included. It should assume that the peer's * implementation does not support this option.*/LOCAL OPTION_PARSE_RESULT generateConfigureNakForInterfaceIdentifier ( PFW_PLUGIN_OBJ_STATE * pPfwPlugingObjState, OPTION_LIST_ENTRY * pIpv6nakOption, OPTION_LIST_ENTRY * pIpv6LocalOption, OPTION_LIST * sptr_nak_option_list, OPTION_LIST * sptr_rej_option_list, OPTION_LIST * sptr_recv_option_list ) { IPV6CP_STACK_DATA * pIpv6cpStackData = NULL; pIpv6cpStackData = (IPV6CP_STACK_DATA *) pPfwPlugingObjState->stackData; /* * If negotiation of the Interface-Identifier is required, and the * peer did not provide the option in its Configure-Request, the * option SHOULD be appended to a Configure-Nak (Once only). */ if (pIpv6cpStackData->previousNakSent == FALSE) { /* * If both the identifier is zero add the option to reject list * else update the values in nak list alone. */ if (checkIpv6InterfaceIdentifierForZero (pIpv6LocalOption, pIpv6nakOption) == OK) { add_entry_to_list ((LINK *) sptr_rej_option_list, (LINK *) sptr_recv_option_list->sptr_forward_link); free_ppp_option_list (sptr_nak_option_list); return SOME_OPTIONS_ARE_REJECTED; } else { pIpv6cpStackData->previousNakSent = TRUE; return SOME_OPTIONS_ARE_NACKED; } } /* * If the second Configure-Request does not include this option we * should not send another Configure-Nak with this option included. We * assume that the peer's implementation does not support this option. * So free all the options in nak list and add the rest of IPV6 options * to the rej list. */ free_ppp_option_list (sptr_nak_option_list); pIpv6cpStackData->previousNakSent = FALSE; if (sptr_recv_option_list->sptr_forward_link != NULL) { add_entry_to_list ((LINK *) sptr_rej_option_list, (LINK *) sptr_recv_option_list->sptr_forward_link); return SOME_OPTIONS_ARE_REJECTED; } /* When a IPV6 configure request is received with no options */ return OPTION_PARSING_ERROR; }/******************************************************************************** checkIpv6InterfaceIdentifierForZero - To check local and remote * Interface-Identifier is equal to zero */LOCAL STATUS checkIpv6InterfaceIdentifierForZero ( OPTION_LIST_ENTRY * sptr_local_option, OPTION_LIST_ENTRY * sptr_remote_option ) { int index = 0; int sum = 0; /* If local and remote Interface-Identifier is equal to zero */ for (index = 0; index < sptr_local_option->length;index++) sum = sum + sptr_remote_option->uptr_data->byte_array [index] + sptr_local_option->uptr_data->byte_array [index]; if (sum == 0) return OK; /* * 1) If the two Interface-Identifiers are different but the * received Interface-Identifier is zero and * 2) If the two Interface-Identifiers are equal and are not zero. * * For both the above case a Configure-Nak is sent with a non-zero * Interface-Identifier value suggested for use by the remote peer. */ generateNewInterfaceIdentifier (sptr_remote_option); /* * Newly generated Interface-Identifier MUST be different from the * Interface-Identifier of the last Configure-Request */ for (index = 0, sum = 0; index < sptr_remote_option->length; index++) sum = sum + sptr_remote_option->uptr_data->byte_array[index]; while ((memcmp (sptr_remote_option->uptr_data,sptr_local_option->uptr_data, sptr_local_option->length) == 0) || (sum == 0)) { generateNewInterfaceIdentifier (sptr_remote_option); for (index = 0,sum=0; index < sptr_remote_option->length;index++) sum = sum + sptr_remote_option->uptr_data->byte_array[index]; } return ERROR; }/******************************************************************************** generateNewInterfaceIdentifier - Generate IPV6 Interface-Identifier * for remote peer.** If a good source of uniqueness cannot be found, it is recommended that a * random number be generated. In this case the "u" bit of the interface * identifier MUST be set to zero (0).*/void generateNewInterfaceIdentifier ( OPTION_LIST_ENTRY * sptr_remote_option ) { ULONG magicNumber = 0; int i = 0; int index = 0; BYTE * pRemoteOption = (BYTE *) sptr_remote_option->uptr_data; for (i = 0; i < 2; i++) { magicNumber = random (); memcpy (&pRemoteOption [(index * sizeof (ULONG))], &magicNumber, sizeof (ULONG)); index ++; } /* * In this case the "u" bit of the interface identifier MUST be * set to zero (0). This is 7th Bit from the MSB. */ pRemoteOption [0] = pRemoteOption [0] & 0xFD; }/* IPV6 Support *//******************************************************************************** resetNakOptionSelectedField -*/LOCAL void resetNakOptionSelectedField ( OPTION_LIST * sptr_option_list ) { OPTION_LIST_ENTRY *sptr_configured_option = NULL; for (sptr_configured_option = sptr_option_list->sptr_forward_link; sptr_configured_option != NULL; sptr_configured_option = sptr_configured_option->sptr_forward_link) { sptr_configured_option->nak_option_selected = 0; } return; }/*******************************************************************************set_missing_required_options_in_nak -*/OPTION_PARSE_RESULT set_missing_required_options_in_nak /* changed to non-static - WindNet Multilink */ ( PFW_OBJ * pfw, OPTION_LIST *sptr_configured_option_list, OPTION_LIST *sptr_rxed_option_list, OPTION_LIST *sptr_nak_option_list ) { OPTION_LIST_ENTRY *sptr_configured_option = NULL; OPTION_LIST_ENTRY *sptr_rxed_option = NULL; OPTION_LIST_ENTRY *sptr_nak_option = NULL; OPTION_PARSE_RESULT return_code; return_code = OPTIONS_RECEIVED_ARE_OK; for (sptr_configured_option =sptr_configured_option_list->sptr_forward_link; sptr_configured_option != NULL; sptr_configured_option = sptr_configured_option->sptr_forward_link) { for (sptr_rxed_option = sptr_rxed_option_list->sptr_forward_link; sptr_rxed_option != NULL; sptr_rxed_option = sptr_rxed_option->sptr_forward_link ) { if (sptr_configured_option->type.generic == sptr_rxed_option->type.generic) { break; } } if (sptr_configured_option->option_flags.negotiation_required == PPP_FLAG_ON) { if (sptr_rxed_option == NULL) { sptr_nak_option = duplicate_option (pfw,sptr_configured_option); if (sptr_nak_option != NULL) { sptr_nak_option->alternate_option_list.sptr_forward_link = NULL; sptr_nak_option->alternate_option_list.sptr_backward_link = NULL; sptr_nak_option->range_option = NULL; add_entry_to_list ((LINK *) sptr_nak_option_list, (LINK *) sptr_nak_option); return_code = SOME_OPTIONS_ARE_NACKED; } } } } return (return_code); }/******************************************************************************** parse_ppp_options_from_nak_configure -*/OPTION_PARSE_RESULT parse_ppp_options_from_nak_configure ( PFW_OBJ * pfw, OPTION_LISTS *sptr_option_lists, M_BLK_ID packet, PFW_PLUGIN_OBJ_STATE *pluginState ) { OPTION_LIST_ENTRY *sptr_configured_option = NULL; OPTION_LIST_ENTRY *sptr_receive_list_option = NULL; TEST option_value_ok; OPTION_PARSE_RESULT return_code; return_code = OPTIONS_RECEIVED_ARE_OK; free_ppp_option_list (&sptr_option_lists->received); free_ppp_option_list (&sptr_option_lists->rx_nak); free_ppp_option_list (&sptr_option_lists->tx_reject); if (parse_ppp_options_from_packet (pfw,&sptr_option_lists->received, packet) == FAIL) { return (OPTION_PARSING_ERROR); }#ifdef PPP_DEBUG printf ("%s Rx ConfigNak: ", pluginState->pluginObj->name); option_list_print(&sptr_option_lists->received); printf ("\n");#endif /* PPP_DEBUG */ sptr_receive_list_option = (OPTION_LIST_ENTRY *) get_entry_from_list ((LINK *) &sptr_option_lists->received);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -