📄 ospf_configuration.c
字号:
/**************************************************************************************** ospf_is_parameter_default - checks to see if paramter is default** This routine checks the string to see if the parameter is default** <cptr_value_string> Configuration string from ospf_cfg.c** RETURNS: TRUE or FALSE** ERRNO: N/A** NOMANUAL*/static enum BOOLEAN ospf_is_parameter_default (char *cptr_parameter_string){ OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_is_parameter_default\r\n"); if (strstr (ospf_strlwr (cptr_parameter_string), "default") != NULL) { return (TRUE); } else { return (FALSE); }}/**************************************************************************************** ospf_set_default_values_for_areas - sets the default values for areas** This routine sets the default values for all areas configured.* This includes the area address range cost as 1, injecting default* route into stub area as FALSE, advertise area address range as TRUE,* stub default cost as 1 and nssa to FALSE.** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_set_default_values_for_areas (void){ USHORT area_number =0;#if defined (__NSSA__) ospf.nssa_enabled = FALSE;#endif /*__NSSA__*/ OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_set_default_values_for_areas\r\n"); for (area_number = 0x0000; area_number < NUMBER_OF_OSPF_AREAS; ++area_number) { ospf.area[area_number].config.address_range_cost = OSPF_DEFAULT_COST; /* SPR#86319 - the variable inject_summary_lsa_into_stub_area controls * the import of summary LSAs into stub areas. It has no effect on other * areas. Since rfc1850 MIB defines the default value for the ospfAreaSummary * object as noAreaSummary, set the inject_summary_lsa_into_stub_area * to false for consistency. That means the router will neither originate nor * propagate summary LSAs into the stub area. It will rely entirely on * its default route. */ ospf.area[area_number].config.inject_summary_lsa_into_stub_area = FALSE; ospf.area[area_number].config.advertise_address_range = TRUE; ospf.area[area_number].config.stub_default_cost = 1;#if defined (__NSSA__) ospf.area[area_number].config.nssa_enabled = FALSE;#endif /*__NSSA__*/ }}/**************************************************************************************** ospf_set_default_values_for_ports - sets the default values for all the interfaces configured** This routine sets the default values for all interfaces configured.* This includes the interface as broadcast, hello interval as 10,* dead interval timer as 40, transmit delay as 1, priority as 1,* default cost as 1, authentication as none, poll 120, and* retransmit interval as 5.** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_set_default_values_for_ports (void){ USHORT port_number =0; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_set_default_values_for_ports\r\n"); for (port_number = 0x0000; port_number < NUMBER_OF_OSPF_PORTS; ++port_number) { ospf.port[port_number].config.type = OSPF_BROADCAST; ospf.port[port_number].config.hello_interval = OSPF_BROADCAST_DEFAULT_HELLO; ospf.port[port_number].config.router_dead_interval = OSPF_DEFAULT_ROUTER_DEAD_INTERVAL; ospf.port[port_number].config.transmit_delay = OSPF_DEFAULT_TRANSMIT_DELAY; ospf.port[port_number].config.priority = OSPF_DEFAULT_PRIORITY; ospf.port[port_number].config.cost = OSPF_DEFAULT_COST; ospf.port[port_number].config.authentication_type = OSPF_AUTHENTICATION_NONE; ospf.port[port_number].config.poll_interval = OSPF_DEFAULT_POLL_INTERVAL; ospf.port[port_number].config.retransmit_interval = OSPF_DEFAULT_RETRANSMIT_INTERVAL; }}/**************************************************************************************** ospf_convert_4bytes_to_ulong - utility function to convert 4 bytes to ULONG** This routine combines 4 bytes into a ULONG.** <byte_4> fourth byte** <byte_3> third byte** <byte_2> second byte** <byte_1> first byte** RETURNS: ULONG** ERRNO: N/A** NOMANUAL*/static ULONG ospf_convert_4bytes_to_ulong (BYTE byte_4, BYTE byte_3, BYTE byte_2, BYTE byte_1){ ULONG return_value =0; ULONG byte_array[4]; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_convert_4bytes_to_ulong\r\n"); byte_array[0] = byte_1; byte_array[1] = byte_2; byte_array[2] = byte_3; byte_array[3] = byte_4; return_value = (ULONG) byte_array[0]; return_value |= (ULONG) (byte_array[1] << 8); return_value |= (ULONG) (byte_array[2] << 16); return_value |= (ULONG) (byte_array[3] << 24); return (return_value);}/**************************************************************************************** ospf_configure_subnets_to_redistribute - configure subnets to redistribute** This routine configures subnets to redistribute throughout OSPF.** <cptr_value_string> Configuration string from ospf_cfg.c** <sptr_head_link> Head of link list of subnets** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_configure_subnets_to_redistribute (char *cptr_value_string, LINK *sptr_head_link){ ULONG network_address =0; ULONG network_mask =0; char *cptr_current_token; OSPF_ADDRESS_MASK_PAIRS *sptr_address_mask_pair =NULL; ULONG tmp0 =0; ULONG tmp1 =0; ULONG tmp2 =0; ULONG tmp3 =0; ULONG metric_type; ULONG metric_value; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_configure_subnets_to_redistribute\r\n"); for ( cptr_current_token = strtok (cptr_value_string, "\t,;\n"); cptr_current_token != NULL; cptr_current_token = strtok ((char *) '\0', ",\t\n;") ) { sscanf (cptr_current_token,"%03u.%03u.%03u.%03u", (int*) &tmp3, (int*) &tmp2, (int*) &tmp1, (int*) &tmp0); network_address = ospf_convert_4bytes_to_ulong ((BYTE) tmp3, (BYTE) tmp2, (BYTE) tmp1, (BYTE) tmp0); cptr_current_token = strtok ((char *) '\0', ",\t\n;"); if (cptr_current_token == NULL) { return; } sscanf (cptr_current_token,"%03u.%03u.%03u.%03u", (int*) &tmp3, (int*) &tmp2, (int*) &tmp1, (int*) &tmp0); network_mask = ospf_convert_4bytes_to_ulong ((BYTE) tmp3, (BYTE) tmp2, (BYTE) tmp1, (BYTE) tmp0); /* SPR 83418 -- Begin */ /* check for metric type and value */ cptr_current_token = strtok ((char *) '\0', ",\t\n;"); if (cptr_current_token == NULL) { /* default is type 2*/ metric_type = OSPF_EXTERNAL_METRIC_TYPE_2; metric_value = 0; } else { sscanf (cptr_current_token,"%u", (int*) &metric_type); if((metric_type != OSPF_EXTERNAL_METRIC_TYPE_2) && (metric_type != OSPF_EXTERNAL_METRIC_TYPE_1)) return; /* check for metric value */ cptr_current_token = strtok ((char *) '\0', ",\t\n;"); if(cptr_current_token != NULL) { sscanf (cptr_current_token, "%u", (int*) &metric_value); } } /* SPR 83418 -- End */ sptr_address_mask_pair = (OSPF_ADDRESS_MASK_PAIRS *) table_malloc (1, sizeof (OSPF_ADDRESS_MASK_PAIRS) ); if (sptr_address_mask_pair == NULL) { ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "SPTR_ADDRESS_MASK_PAIR"); return; } memset (sptr_address_mask_pair, 0x0, sizeof (OSPF_ADDRESS_MASK_PAIRS) ); sptr_address_mask_pair->network_address = network_address; sptr_address_mask_pair->network_mask = network_mask; /* SPR 83418 -- Begin */ sptr_address_mask_pair->metric_type = metric_type; sptr_address_mask_pair->metric_value = metric_value; /* SPR 83418 -- End */ ospf_add_entry_to_list ( (LINK *) sptr_head_link, (LINK *) (sptr_address_mask_pair) ); } return;}/**************************************************************************************** ospf_get_router_id - gets the router id of the router** This routine retrieves the OSPF router id of the router** RETURNS: ULONG** ERRNO: N/A** NOMANUAL*/ULONG ospf_get_router_id(){ OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_get_router_id\r\n"); return ospf.router_id;}/**************************************************************************************** ospf_get_number_of_areas - gets the number of total number of areas** This routine retrieves the total number of areas in the OSPF router** RETURNS: ULONG** ERRNO: N/A** NOMANUAL*/ULONG ospf_get_number_of_areas(){ OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_get_number_of_areas\r\n"); return ospf.number_of_areas;}/**************************************************************************************** ospf_get_number_of_virtual_links - gets the number of total number of virtual links** This routine retrieves the total number of virtual links in the OSPF router** RETURNS: ULONG** ERRNO: N/A** NOMANUAL*/ULONG ospf_get_number_of_virtual_links(){ OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_get_number_of_virtual_links\r\n"); return ospf.number_of_virtual_links;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -