📄 ospfh.h
字号:
else \
(L)->tail = (N)->prev; \
} while (0)
//linklist end
//thread
#ifndef THREAD_H
#define THREAD_H
#ifdef HAVE_RUSAGE
#define RUSAGE_T struct rusage
#define GETRUSAGE(X) getrusage (RUSAGE_SELF, X);
#else
#define RUSAGE_T struct timeval
#define GETRUSAGE(X) gettimeofday (X, NULL);
#endif /* HAVE_RUSAGE */
/* Linked list of thread. */
struct thread_list
{
struct thread *head;
struct thread *tail;
int count;
};
/* Master of the theads. */
struct thread_master
{
struct thread_list read;
struct thread_list write;
struct thread_list timer;
struct thread_list event;
struct thread_list ready;
struct thread_list unuse;
fd_set readfd;
fd_set writefd;
fd_set exceptfd;
unsigned long alloc;
};
/* Thread itself. */
struct thread
{
unsigned char type; /* thread type */
struct thread *next; /* next pointer of the thread */
struct thread *prev; /* previous pointer of the thread */
struct thread_master *master; /* pointer to the struct thread_master. */
int (*func) (struct thread *); /* event function */
void *arg; /* event argument */
union {
int val; /* second argument of the event. */
int fd; /* file descriptor in case of read/write. */
struct timeval sands; /* rest of time sands value. */
} u;
RUSAGE_T ru; /* Indepth usage info. */
};
/* Thread types. */
#define THREAD_READ 0
#define THREAD_WRITE 1
#define THREAD_TIMER 2
#define THREAD_EVENT 3
#define THREAD_READY 4
#define THREAD_UNUSED 5
/* Thread yield time. */
#define THREAD_YIELD_TIME_SLOT 100 * 1000L /* 100ms */
/* Macros. */
#define THREAD_ARG(X) ((X)->arg)
#define THREAD_FD(X) ((X)->u.fd)
#define THREAD_VAL(X) ((X)->u.val)
#define THREAD_READ_ON(master,thread,func,arg,sock) \
do { \
if (! thread) \
thread = thread_add_read (master, func, arg, sock); \
} while (0)
#define THREAD_WRITE_ON(master,thread,func,arg,sock) \
do { \
if (! thread) \
thread = thread_add_write (master, func, arg, sock); \
} while (0)
#define THREAD_TIMER_ON(master,thread,func,arg,time) \
do { \
if (! thread) \
thread = thread_add_timer (master, func, arg, time); \
} while (0)
#define THREAD_OFF(thread) \
do { \
if (thread) \
{ \
thread_cancel (thread); \
thread = NULL; \
} \
} while (0)
#define THREAD_READ_OFF(thread) THREAD_OFF(thread)
#define THREAD_WRITE_OFF(thread) THREAD_OFF(thread)
#define THREAD_TIMER_OFF(thread) THREAD_OFF(thread)
#endif
//end thread
struct cmd_element
{
char *string; /* Command specification by string. */
int (*func) (int , char ** , void *);
};
struct vector
{
unsigned int max; /* max number of used slot */
unsigned int alloced; /* number of allocated slot */
char **index; /* index to data */
};
#define CONF_CMD_NUM 6
#define QUERY_CMD_NUM 1
#define VTY_BUFSIZ 512
#define VECTOR_MIN_SIZE 30
#ifndef DIRECTORY_SEP
#define DIRECTORY_SEP '/'
#endif /* DIRECTORY_SEP */
#ifndef IS_DIRECTORY_SEP
#define IS_DIRECTORY_SEP(c) ((c) == DIRECTORY_SEP)
#endif
#define vector_slot(V,I) ((V)->index[(I)])
#define vector_max(V) ((V)->max)
/* Argc max counts. */
#define CMD_ARGC_MAX 25
//---------------OSPF向光域扩展-------------------------------------------------
/*
* Opaque LSA's link state ID is redefined as follows.
*
* 24 16 8 0
* +--------+--------+--------+--------+
* |tttttttt|........|........|........|
* +--------+--------+--------+--------+
* |<-Type->|<------- Opaque ID ------>|
*/
#define LSID_OPAQUE_TYPE_MASK 0xff000000 /* 8 bits */
#define LSID_OPAQUE_ID_MASK 0x00ffffff /* 24 bits */
#define TLV_HDR_SIZE sizeof (struct te_tlv_header)
#define LEGAL_TE_INSTANCE_RANGE(i) (0 <= (i) && (i) <= 0xffff)
#define ROUNDUP(val, gran) (((val) - 1 | (gran) - 1) + 1)
#define SET_OPAQUE_LSID(type, id) \
((((type) << 24) & LSID_OPAQUE_TYPE_MASK) \
| ((id) & LSID_OPAQUE_ID_MASK))
#define TLV_BODY_SIZE(tlvh) \
ROUNDUP ((tlvh)->length, sizeof (u_int32_t))
#define TLV_SIZE(tlvh) \
(TLV_HDR_SIZE + TLV_BODY_SIZE(tlvh))
struct te_tlv_header
{
u_int16_t type; /* TE_TLV_XXX (see below) */
u_int16_t length; /* Value portion only, in octets */
};
// Following section defines TLV body parts.
/* Link TLV */
#define TE_TLV_LINK 2
struct te_tlv_link
{
struct te_tlv_header header;
/* A set of link-sub-TLVs will follow. */
};
//-------The following are the MPLS TE LSAs Sub-TLVs--------------------------
/* Link Type Sub-TLV *//* Mandatory */
#define TE_LINK_SUBTLV_LINK_TYPE 1
struct te_link_subtlv_link_type
{
struct te_tlv_header header; /* Value length is 1 octet. */
struct {
#define LINK_TYPE_SUBTLV_VALUE_PTP 1
#define LINK_TYPE_SUBTLV_VALUE_MA 2
u_char link_type;
u_char padding[3];
} value;
};
/* Link Sub-TLV: Link ID *//* Mandatory */
#define TE_LINK_SUBTLV_LINK_ID 2
struct te_link_subtlv_link_id
{
struct te_tlv_header header; /* Value length is 4 octets. */
struct in_addr value; /* Same as router-lsa's link-id. */
};
/* Link Sub-TLV: Traffic Engineering Metric *//* Mandatory */
#define TE_LINK_SUBTLV_TE_METRIC 5
struct te_link_subtlv_te_metric
{
struct te_tlv_header header; /* Value length is 4 octets. */
u_int32_t value; /* Link metric for TE purpose. */
};
/* Link Sub-TLV: Resource Class/Color *//* Mandatory */
#define TE_LINK_SUBTLV_RSC_CLSCLR 9
struct te_link_subtlv_rsc_clsclr
{
struct te_tlv_header header; /* Value length is 4 octets. */
u_int32_t value; /* Admin. group membership. */
};
//-------The following are the GMPLS TE LSAs----------------------------------
/* Link Sub-TLV: Link Local/Remote Identifiers *//* Mandatory */
#define TE_LINK_SUBTLV_ID_IDENTIFIER 11
struct te_link_subtlv_id_identifier
{
struct te_tlv_header header; /* Value length is 8 octets. */
struct in_addr value[2]; /* Link Local/Remote Identifers. */
};
//--------The following are the ENNI OSPF TE LSAs---------------------------
/* Link Sub-TLV: Local node ID */ /* Mandatory */
#define TE_LINK_SUBTLV_LOCAL_NODE_ID 32773
struct te_link_subtlv_local_node_id
{
struct te_tlv_header header; /* Value length is 4 octets. */
struct in_addr value;
};
/* Link Sub-TLV: Remote node ID */ /* Mandatory */
#define TE_LINK_SUBTLV_REMOTE_NODE_ID 32774
struct te_link_subtlv_remote_node_id
{
struct te_tlv_header header; /* Value length is 4 octets. */
struct in_addr value;
};
/* Link Sub-TLV: Interface Switching Capability Descriptor */ /*Mandatory, Default value is PSC */
#define TE_LINK_SUBTLV_IFSWITCH_CAP 32775
struct te_link_subtlv_ifswitch_cap
{
struct te_tlv_header header; /* Value length is 36 octets. */
struct {
#define IFSWITCH_CAP_SUBTLV_VALUE_PSC1 1
#define IFSWITCH_CAP_SUBTLV_VALUE_PSC2 2
#define IFSWITCH_CAP_SUBTLV_VALUE_PSC3 3
#define IFSWITCH_CAP_SUBTLV_VALUE_PSC4 4
#define IFSWITCH_CAP_SUBTLV_VALUE_L2SC 51
#define IFSWITCH_CAP_SUBTLV_VALUE_TDM 100
#define IFSWITCH_CAP_SUBTLV_VALUE_LSC 150
#define IFSWITCH_CAP_SUBTLV_VALUE_FSC 200
u_char switchcap;
#define IFSWITCH_CAP_SUBTLV_ENCODING_PACK 1
#define IFSWITCH_CAP_SUBTLV_ENCODING_ETHE 2
#define IFSWITCH_CAP_SUBTLV_ENCODING_PDH 3
#define IFSWITCH_CAP_SUBTLV_ENCODING_SDH 5
#define IFSWITCH_CAP_SUBTLV_ENCODING_DIGWRAP 7
#define IFSWITCH_CAP_SUBTLV_ENCODING_LAMDA 8
#define IFSWITCH_CAP_SUBTLV_ENCODING_FIBER 9
#define IFSWITCH_CAP_SUBTLV_ENCODING_FIBCHAN 11
u_char encoding;
u_char reserved[2];
u_int32_t snum; /* One for each priority level. */
}value;
};
/* Link Sub-TLV: Ancestor node ID */ /* Optional */
#define TE_LINK_SUBTLV_ANCESTOR_NODE_ID 32776
struct te_link_subtlv_ancestor_node_id
{
struct te_tlv_header header; /* Value length is 4 octets. */
struct in_addr value;
};
//还差一个Hierarchy List TLV
#define TE_LINK_SUBTLV_HIERARCHY_LIST 32777
struct te_link_subtlv_hierarchy_list
{
struct te_tlv_header header; /* Value length is ?? octets. */
struct in_addr value[3]; //??
};
struct mpls_te_link
{
/* Store Link-TLV in network byte order. */
struct te_tlv_link link_header;
struct te_link_subtlv_link_type link_type;
struct te_link_subtlv_link_id link_id;
struct te_link_subtlv_te_metric te_metric;
struct te_link_subtlv_rsc_clsclr rsc_clsclr;
struct te_link_subtlv_id_identifier id_identifier;
struct te_link_subtlv_local_node_id local_id;
struct te_link_subtlv_remote_node_id remote_id;
struct te_link_subtlv_ifswitch_cap ifswitch_cap;
struct te_link_subtlv_ancestor_node_id ancestor_id;
struct te_link_subtlv_hierarchy_list hierarchy_list;
};
struct ospf
{
/* OSPF Router Controller ID. */
struct in_addr self_rc_id;
/* The IP Address */
struct in_addr ip_address;
/* neighbor RC */
struct list *nbrlist;
/* The speaker */
struct in_addr speaker_rc_id;
struct in_addr uplayer_rc_id;
struct in_addr downlayer_rc_id;
/* Threads. */
struct thread *t_write;
struct thread *t_read;
struct thread *t_maxage; /* MaxAge LSA remover timer. */
struct thread *t_maxage_walker; /* MaxAge LSA checking timer. */
struct thread *t_lsa_list;
struct thread *t_lsa_self;
struct thread *t_ls_ack; /* timer */
struct thread *t_ls_feed_up_timer;
// struct thread *t_ls_feed_down_timer;
/* Timer values. */
u_int32_t v_ls_ack; /* Delayed Link State Acknowledgment */
u_int32_t v_ls_feed_up;
// u_int32_t v_ls_feed_down;
struct
{
struct list *ls_ack;
struct in_addr dst;
} ls_ack_direct;
/* Packet send buffer. */
struct ospf_fifo *outbuf; /* Output packet queue */
struct list *lsa_list; /* The LSAs belong to */
struct ospf_lsa *lsa_self;
struct list *ls_ack; /* Link State Acknowledgment list. */
struct list *maxage_lsa;
int mtu; /*MTU of the packet*/
int fd;
/* Statistics for LSA used for new instantiation. */
u_int32_t rx_lsa_count;
/* Statistics for LSA origination. */
u_int32_t lsa_originate_count;
u_int32_t transmit_delay; /*InftransDelay*/
// u_char priority; /*RouterPriority*/
// u_int32_t output_cost; /*interface output cost*/
u_int32_t retransmit_interval; /*RxmtInterval*/
/* Statistics fields. */
u_int32_t ls_upd_in; /* LS update message input count. */
u_int32_t ls_upd_out; /* LS update message output count. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -