数据结构IpT_Rte_Module_Data是一个ip_dispatch和其子进程所共有的一个数据结构,下面列出的和路由表相关的
struct IpT_Rte_Module_Data {
…
IpT_Cmn_Rte_Table* ip_route_table;
IpT_Rte_Table* ip_static_rte_table;
InetT_Address default_route_addr_array[2];
IpT_Rte_Map_Table * rte_map_table;
IpT_Rte_Map_Table * firewall_filter_table;
struct IpT_Manet_Info* manet_info_ptr;/* Mobile Ad hoc network information. */
…
}
1)IpT_Cmn_Rte_Table* ip_route_table;
是系统所公用的路由表,类比于内核中的内核路由表;
typedef struct IpT_Cmn_Rte_Table
{
Objid node_objid;
int usage_threshold;
/* Vector which keeps track of the process handles */
/* of all routing processes (including any multiple */
/* processes of the same protocol) that are running */
/* on this node. */
PrgT_Vector* routeproc_vptr;
/* Vector which keeps track of the redistribution */
/* matrix for this node. Each element in the list */
/* will correspond to a routing process running on */
/* this node (therefore, the size of this vector */
/* and the size of routeproc_vptr will be the */
/* same). Each element will have a corresponding */
/* list of all the routing processes it */
/* redistributes to. */
PrgT_Vector* redist_matrix_vptr;
IpT_Rte_Table_Load load_type;
/* IPv4 and IPv6 Patricia trees. */
OmsT_Ptree* ptree_ptr_array[IPC_NUM_ADDR_FAMILIES];
/* Total number of entries in the table. */
int num_entries;
/* Statistics for monitoring routing table updates. */
/* The array of stathandles will record statistics */
/* separately for All updates, Add, Remove, Changes */
/* and also time between two consecutive updates. */
/* Uses "IpT_Rte_Table_Updates" as the indices. */
Stathandle update_stathandle [6];
double last_update_time;
/* Key to the hash of convergence statistics */
OmsT_Convergence_Handle convg_handle;
/* Information about the IPv4 default route */
IpT_Cmn_Rte_Table_Entry *gateway_of_last_resort;
IpT_Cmn_Rte_Table_Entry *best_default_route;
/* Default routes need to mantained separately. */
/* This is for IPv4 only. */
<span style="color:#ff0000;"> List* resolved_default_routes;
List* unresolved_default_routes;</span>
/* Pointer to the Module data of the parent node */
struct IpT_Rte_Module_Data* iprmd_ptr;
/* Cache table used to implement destination based */
/* load balancing. */
IpT_Cmn_Rte_Dest_Src_Table_Handle dest_src_table;
/* Number of entries in the above table. */
int dest_src_table_size;
/* VRF to which this route table belongs. */
struct IpT_Vrf_Table* vrf_table_ptr;
#ifdef OPD_PARALLEL
/* Spinlock to serialize access to this route table */
PrgT_Mt_Spinlock ip_cmn_rte_table_spinlock;
#endif /* OPD_PARALLEL */
} IpT_Cmn_Rte_Table;
<span style="color: rgb(255, 0, 0);"> List* resolved_default_routes;
List* unresolved_default_routes;</span>
是实际路由表,List是一个链表结构;
其路由表项Entry是由下面的数据结构表示:
typedef struct IpT_Cmn_Rte_Table_Entry {
IpT_Dest_Prefix dest_prefix;
IpT_Rte_Proc_Id route_src_proto;
double route_insert_time;
OpT_uInt16 flags;
void* route_src_obj_ptr;
int admin_distance;
List* next_hop_list;
List* backup_list;
} IpT_Cmn_Rte_Table_Entry;
typedef struct IpT_Dest_Prefix{
unsigned char addr_family; /* InetT_Addr_Family value */
InetT_Subnet_Mask subnet_mask; /* Subnet mask. */
union{
IpT_Address ipv4_addr; /* Ipv4 address.*/
struct Ipv6T_Address* ipv6_addr_ptr; /* Ipv6 address.*/
} address;
} InetT_Address_Range;
2)IpT_Rte_Table* ip_static_rte_table;
是保存静态路由表,静态路由表会插入到common table中;
静态路由表Entry:
typedef struct IpT_Rte_Table_Entry
{
Boolean valid;
IpT_Dest_Prefix dest_prefix;
InetT_Address next_hop;
int admin_weight;
}IpT_Rte_Table_Entry;
3)InetT_Address default_route_addr_array[2];
表示的系统的默认路由,默认路由是指向其所连接网关的IP地址,这是个具有两个元素的数组,分别表示ipv4和ipv6;
4) struct IpT_Manet_Info* manet_info_ptr;/* Mobile Ad hoc network information.*/
有的Mobile Ad hoc network会有用来建立路由的协议路由表
typedef struct IpT_Manet_Info
{
Prohandle mgr_prohandle;
IpT_Rte_Protocol rte_protocol;
AodvT_Route_Table* aodv_route_table_ptr;
Boolean manet_gateway_status;
} IpT_Manet_Info;
当协议时aodv协议时,用到aodv路由表:
typedef struct
{
InetT_Address_Hash_Table_Handle route_table;
IpT_Cmn_Rte_Table* ip_cmn_rte_table_ptr;
IpT_Rte_Proc_Id aodv_protocol_id;
double route_expiry_time;
double delete_period;
AodvT_Local_Stathandles* stat_handles_ptr;
int active_route_count;
} AodvT_Route_Table;
Aodv路由表Entry:
typedef struct {
IpT_Dest_Prefix dest_prefix;
int dest_seq_num;
Boolean valid_dest_sequence_number_flag;
AodvC_Route_Entry_State route_entry_state;
InetT_Address next_hop_addr;
IpT_Port_Info next_hop_port_info;
int hop_count;
List* precursor_lptr;
double route_expiry_time;
Evhandle route_expiry_evhandle;
} AodvT_Route_Entry;