📄 ospf_ky_driver.c
字号:
/* ospf_ky_driver.c - ospf ky driver *//* Copyright 2002 Wind River Systems, Inc. *//*modification history___________________02c,05sep02,agi fixed compiler warning02b,12aug02,agi moved #if defined to not include any driver code if not needed02a,02aug02,agi Fixed DIAB compiler warning*//*DESCRIPTIONThis file contains the sample driver function to execute Katz-Yeung API calls.This file will initialize the ky task and read from the ky configuration file.This file will make use of the Katz-Yeung API calls to initialize the ky taskand create data to be added onto a type 10 opaque lsa and flooded out thenetwork for the area specified.*//* This include is here to prevent the DIAB "empty file" warning */#include "ospf.h"#if defined (__KY_DRIVER__)/* includes */#include <ky.h>#include <cspf.h>#include <teDb.h>/*************************************************************************** ospf_ky_driver - Driver function to execute Katz-Yeung API functions** This routine creates Katz-Yeung data and adds that data to a type 10* opaque lsa and floods it throughout the area.** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void ospf_ky_driver(){ ULONG te_unreserved_bandwidth[8] = { 50, 50, 50, 50, 50, 50, 50, 50}; OSPF_INTERFACE *sptr_opaque_interface = NULL; CSPF_ROUTING_TABLE_NODE *routing_table = NULL; char *new_lsa = NULL; USHORT opaque_length = 0x0000; OSPF_TE_PARAMETERS te_parameters1; OSPF_TE_PARAMETERS *te_parameters2 = NULL; int priority = 0; OSPF_TE_TLV_DATA tlv_data; UNION_OSPF_LS_ID ospf_lsid; /* Register callback functions for Katz-Yeung */ kyOpenTE(); /* Initialize TE parameters for generating LSPs */ teInitializeParams(); /* Create TE parameters */ ospfTeCreateIf(ospf.router_id, 2, 0, 0, 0, 50, 50, 50, te_unreserved_bandwidth, 50); /* Originate TE Opaque LSA */ sptr_opaque_interface = ospf.sptr_interface_list; if (sptr_opaque_interface != NULL) { ospfSetOrigOpaqueLsa(sptr_opaque_interface->address, sptr_opaque_interface->netmask, 10, OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA); } /* Test Driver code for encoding and decoding TLVs */ memset(&te_parameters1, 0x00, sizeof (OSPF_TE_PARAMETERS)); te_parameters1.ospf_te_link_id = 1; te_parameters1.ospf_te_link_type = 2; te_parameters1.ospf_te_local_address[0] = ospf.sptr_interface_list->address; te_parameters1.ospf_te_maximum_bandwidth = 2; te_parameters1.ospf_te_maximum_reservable_bandwidth = 4; te_parameters1.ospf_te_metric = 5; te_parameters1.ospf_te_remote_address[0] = ospf.sptr_interface_list->address; te_parameters1.ospf_te_resource_class_color = 6; te_parameters1.ospf_te_router_address = ospf.router_id; for (priority = 0; priority < 8; priority++) { te_parameters1.ospf_te_unreserved_bandwidth[priority] = 9; } te_parameters1.sptr_forward_link = NULL; te_parameters1.sptr_backward_link = NULL; ospfTeEncodeTlv (ospf.sptr_area_list, &te_parameters1, &new_lsa, &opaque_length); memset(&tlv_data, 0x00, sizeof (OSPF_TE_TLV_DATA)); tlv_data.data = new_lsa; tlv_data.data_length = opaque_length; tlv_data.sptr_forward_link = NULL; tlv_data.sptr_backward_link = NULL; tlv_data.TElsatype = 10; te_parameters2 = ospfTeDecodeTlv(opaque_length, 10, &tlv_data); table_free(te_parameters2); ospf_lsid.opaque_lsid.opaque_type = OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA; ospf_lsid.opaque_lsid.opaque_reserved = 0; ospf_lsid.opaque_lsid.opaque_instance = 0; ospf_originate_type_10_links_advertisement (ospf.sptr_area_list, OSPF_AREA_LOCAL_OPAQUE_LSA, ospf_lsid.lsid, new_lsa, opaque_length, 0); table_free(new_lsa); /* build CSPF routing table */ routing_table = cspf_build_routing_table (); kyCloseTE(); cspf_free_routing_table_nodes(cspf.sptr_routing_table_head); cspf.sptr_routing_table_head = NULL;}void ospf_ky_stub() { return; }#endif /* __KY_DRIVER__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -