diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 103 | ||||
-rw-r--r-- | usr.sbin/bgpd/mrt.h | 76 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.h | 81 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.h | 70 |
4 files changed, 166 insertions, 164 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 96374e903ec..c35a9ccd97e 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.264 2011/05/01 12:56:04 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.265 2011/09/18 09:31:25 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -854,6 +854,47 @@ struct rde_memstats { int64_t attr_dcnt; }; +#define MRT_FILE_LEN 512 +#define MRT2MC(x) ((struct mrt_config *)(x)) +#define MRT_MAX_TIMEOUT 7200 + +enum mrt_type { + MRT_NONE, + MRT_TABLE_DUMP, + MRT_TABLE_DUMP_MP, + MRT_TABLE_DUMP_V2, + MRT_ALL_IN, + MRT_ALL_OUT, + MRT_UPDATE_IN, + MRT_UPDATE_OUT +}; + +enum mrt_state { + MRT_STATE_RUNNING, + MRT_STATE_OPEN, + MRT_STATE_REOPEN, + MRT_STATE_REMOVE +}; + +struct mrt { + char rib[PEER_DESCR_LEN]; + struct msgbuf wbuf; + LIST_ENTRY(mrt) entry; + u_int32_t peer_id; + u_int32_t group_id; + enum mrt_type type; + enum mrt_state state; + u_int16_t seqnum; +}; + +struct mrt_config { + struct mrt conf; + char name[MRT_FILE_LEN]; /* base file name */ + char file[MRT_FILE_LEN]; /* actual file name */ + time_t ReopenTimer; + time_t ReopenTimerInterval; +}; + /* prototypes */ /* bgpd.c */ void send_nexthop_update(struct kroute_nexthop *); @@ -862,21 +903,9 @@ int send_network(int, struct network_config *, struct filter_set_head *); int bgpd_filternexthop(struct kroute *, struct kroute6 *); -/* log.c */ -void log_init(int); -void log_verbose(int); -void vlog(int, const char *, va_list); -void log_peer_warn(const struct peer_config *, const char *, ...); -void log_peer_warnx(const struct peer_config *, const char *, ...); -void log_warn(const char *, ...); -void log_warnx(const char *, ...); -void log_info(const char *, ...); -void log_debug(const char *, ...); -void fatal(const char *) __dead; -void fatalx(const char *) __dead; - -/* parse.y */ -int cmdline_symset(char *); +/* control.c */ +void control_cleanup(const char *); +int control_imsg_relay(struct imsg *); /* config.c */ int host(const char *, struct bgpd_addr *, u_int8_t *); @@ -901,17 +930,29 @@ int kr_net_reload(u_int, struct network_head *); int kr_reload(void); struct in6_addr *prefixlen2mask6(u_int8_t prefixlen); -/* control.c */ -void control_cleanup(const char *); -int control_imsg_relay(struct imsg *); +/* log.c */ +void log_init(int); +void log_verbose(int); +void vlog(int, const char *, va_list); +void log_peer_warn(const struct peer_config *, const char *, ...); +void log_peer_warnx(const struct peer_config *, const char *, ...); +void log_warn(const char *, ...); +void log_warnx(const char *, ...); +void log_info(const char *, ...); +void log_debug(const char *, ...); +void fatal(const char *) __dead; +void fatalx(const char *) __dead; -/* pftable.c */ -int pftable_exists(const char *); -int pftable_add(const char *); -int pftable_clear_all(void); -int pftable_addr_add(struct pftable_msg *); -int pftable_addr_remove(struct pftable_msg *); -int pftable_commit(void); +/* mrt.c */ +void mrt_clear_seq(void); +void mrt_write(struct mrt *); +void mrt_clean(struct mrt *); +void mrt_init(struct imsgbuf *, struct imsgbuf *); +int mrt_timeout(struct mrt_head *); +void mrt_reconfigure(struct mrt_head *); +void mrt_handler(struct mrt_head *); +struct mrt *mrt_get(struct mrt_head *, struct mrt *); +int mrt_mergeconfig(struct mrt_head *, struct mrt_head *); /* name2id.c */ u_int16_t rib_name2id(const char *); @@ -927,6 +968,16 @@ const char *pftable_id2name(u_int16_t); void pftable_unref(u_int16_t); void pftable_ref(u_int16_t); +/* parse.y */ +int cmdline_symset(char *); + +/* pftable.c */ +int pftable_exists(const char *); +int pftable_add(const char *); +int pftable_clear_all(void); +int pftable_addr_add(struct pftable_msg *); +int pftable_addr_remove(struct pftable_msg *); +int pftable_commit(void); /* rde_filter.c */ void filterset_free(struct filter_set_head *); diff --git a/usr.sbin/bgpd/mrt.h b/usr.sbin/bgpd/mrt.h index 352b65c2ad2..db1c1dcec35 100644 --- a/usr.sbin/bgpd/mrt.h +++ b/usr.sbin/bgpd/mrt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mrt.h,v 1.29 2011/09/17 16:29:44 claudio Exp $ */ +/* $OpenBSD: mrt.h,v 1.30 2011/09/18 09:31:25 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -40,6 +40,13 @@ */ #define MRT_HEADER_SIZE 12 +struct mrt_hdr { + u_int32_t timestamp; + u_int16_t type; + u_int16_t subtype; + u_int32_t length; +} __packed; + enum MRT_MSG_TYPES { MSG_NULL, /* 0 empty msg (deprecated) */ MSG_START, /* 1 sender is starting up */ @@ -345,71 +352,4 @@ enum MRT_BGP_TYPES { * terminated ... | 0 | * +--------+--------+--------+ */ - -#define MRT_FILE_LEN 512 -enum mrt_type { - MRT_NONE, - MRT_TABLE_DUMP, - MRT_TABLE_DUMP_MP, - MRT_TABLE_DUMP_V2, - MRT_ALL_IN, - MRT_ALL_OUT, - MRT_UPDATE_IN, - MRT_UPDATE_OUT -}; - -enum mrt_state { - MRT_STATE_RUNNING, - MRT_STATE_OPEN, - MRT_STATE_REOPEN, - MRT_STATE_REMOVE -}; - -struct mrt { - char rib[PEER_DESCR_LEN]; - struct msgbuf wbuf; - LIST_ENTRY(mrt) entry; - u_int32_t peer_id; - u_int32_t group_id; - enum mrt_type type; - enum mrt_state state; - u_int16_t seqnum; -}; - -struct mrt_config { - struct mrt conf; - char name[MRT_FILE_LEN]; /* base file name */ - char file[MRT_FILE_LEN]; /* actual file name */ - time_t ReopenTimer; - time_t ReopenTimerInterval; -}; - -#define MRT2MC(x) ((struct mrt_config *)(x)) -#define MRT_MAX_TIMEOUT 7200 - -struct bgpd_config; -struct rde_peer_head; -struct peer; -struct prefix; -struct rib_entry; - -/* prototypes */ -void mrt_dump_bgp_msg(struct mrt *, void *, u_int16_t, - struct peer *); -void mrt_dump_state(struct mrt *, u_int16_t, u_int16_t, - struct peer *); -int mrt_dump_v2_hdr(struct mrt *, struct bgpd_config *, - struct rde_peer_head *); -void mrt_clear_seq(void); -void mrt_dump_upcall(struct rib_entry *, void *); -void mrt_done(void *); -void mrt_write(struct mrt *); -void mrt_clean(struct mrt *); -void mrt_init(struct imsgbuf *, struct imsgbuf *); -int mrt_timeout(struct mrt_head *); -void mrt_reconfigure(struct mrt_head *); -void mrt_handler(struct mrt_head *); -struct mrt *mrt_get(struct mrt_head *, struct mrt *); -int mrt_mergeconfig(struct mrt_head *, struct mrt_head *); - #endif diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 853fbfb6f23..1e4b3ca378b 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.139 2011/09/17 16:29:44 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.140 2011/09/18 09:31:25 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and @@ -299,6 +299,12 @@ struct prefix { extern struct rde_memstats rdemem; /* prototypes */ +/* mrt.c */ +int mrt_dump_v2_hdr(struct mrt *, struct bgpd_config *, + struct rde_peer_head *); +void mrt_dump_upcall(struct rib_entry *, void *); +void mrt_done(void *); + /* rde.c */ void rde_send_kroute(struct prefix *, struct prefix *, u_int16_t); void rde_send_nexthop(struct bgpd_addr *, int); @@ -363,6 +369,42 @@ void community_ext_delete(struct rde_aspath *, int community_ext_conv(struct filter_extcommunity *, u_int16_t, u_int64_t *); +/* rde_decide.c */ +void prefix_evaluate(struct prefix *, struct rib_entry *); + +/* rde_filter.c */ +enum filter_actions rde_filter(u_int16_t, struct rde_aspath **, + struct filter_head *, struct rde_peer *, + struct rde_aspath *, struct bgpd_addr *, u_int8_t, + struct rde_peer *, enum directions); +void rde_apply_set(struct rde_aspath *, struct filter_set_head *, + u_int8_t, struct rde_peer *, struct rde_peer *); +int rde_filter_equal(struct filter_head *, struct filter_head *, + struct rde_peer *, enum directions); + +/* rde_prefix.c */ +#define pt_empty(pt) ((pt)->refcnt == 0) +#define pt_ref(pt) do { \ + ++(pt)->refcnt; \ + if ((pt)->refcnt == 0) \ + fatalx("pt_ref: overflow"); \ +} while(0) +#define pt_unref(pt) do { \ + if ((pt)->refcnt == 0) \ + fatalx("pt_unref: underflow"); \ + --(pt)->refcnt; \ +} while(0) + +void pt_init(void); +void pt_shutdown(void); +void pt_getaddr(struct pt_entry *, struct bgpd_addr *); +struct pt_entry *pt_fill(struct bgpd_addr *, int); +struct pt_entry *pt_get(struct bgpd_addr *, int); +struct pt_entry *pt_add(struct bgpd_addr *, int); +void pt_remove(struct pt_entry *); +struct pt_entry *pt_lookup(struct bgpd_addr *); +int pt_prefix_cmp(const struct pt_entry *, const struct pt_entry *); + /* rde_rib.c */ extern u_int16_t rib_size; extern struct rib *ribs; @@ -421,9 +463,6 @@ void nexthop_update(struct kroute_nexthop *); struct nexthop *nexthop_get(struct bgpd_addr *); int nexthop_compare(struct nexthop *, struct nexthop *); -/* rde_decide.c */ -void prefix_evaluate(struct prefix *, struct rib_entry *); - /* rde_update.c */ void up_init(struct rde_peer *); void up_down(struct rde_peer *); @@ -443,40 +482,6 @@ u_char *up_dump_mp_unreach(u_char *, u_int16_t *, struct rde_peer *, int up_dump_mp_reach(u_char *, u_int16_t *, struct rde_peer *, u_int8_t); -/* rde_prefix.c */ -#define pt_empty(pt) ((pt)->refcnt == 0) -#define pt_ref(pt) do { \ - ++(pt)->refcnt; \ - if ((pt)->refcnt == 0) \ - fatalx("pt_ref: overflow"); \ -} while(0) -#define pt_unref(pt) do { \ - if ((pt)->refcnt == 0) \ - fatalx("pt_unref: underflow"); \ - --(pt)->refcnt; \ -} while(0) - -void pt_init(void); -void pt_shutdown(void); -void pt_getaddr(struct pt_entry *, struct bgpd_addr *); -struct pt_entry *pt_fill(struct bgpd_addr *, int); -struct pt_entry *pt_get(struct bgpd_addr *, int); -struct pt_entry *pt_add(struct bgpd_addr *, int); -void pt_remove(struct pt_entry *); -struct pt_entry *pt_lookup(struct bgpd_addr *); -int pt_prefix_cmp(const struct pt_entry *, const struct pt_entry *); - - -/* rde_filter.c */ -enum filter_actions rde_filter(u_int16_t, struct rde_aspath **, - struct filter_head *, struct rde_peer *, - struct rde_aspath *, struct bgpd_addr *, u_int8_t, - struct rde_peer *, enum directions); -void rde_apply_set(struct rde_aspath *, struct filter_set_head *, - u_int8_t, struct rde_peer *, struct rde_peer *); -int rde_filter_equal(struct filter_head *, struct filter_head *, - struct rde_peer *, enum directions); - /* util.c */ u_int32_t aspath_extract(const void *, int); diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h index 2bfa138c944..a8f52685625 100644 --- a/usr.sbin/bgpd/session.h +++ b/usr.sbin/bgpd/session.h @@ -1,4 +1,4 @@ -/* $OpenBSD: session.h,v 1.111 2010/12/09 13:50:41 claudio Exp $ */ +/* $OpenBSD: session.h,v 1.112 2011/09/18 09:31:25 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -232,29 +232,11 @@ struct ctl_timer { time_t val; }; -/* session.c */ -void session_socket_blockmode(int, enum blockmodes); -pid_t session_main(int[2], int[2], int[2], int[2]); -void bgp_fsm(struct peer *, enum session_events); -int session_neighbor_rrefresh(struct peer *p); -struct peer *getpeerbyaddr(struct bgpd_addr *); -struct peer *getpeerbydesc(const char *); -int imsg_compose_parent(int, u_int32_t, pid_t, void *, u_int16_t); -int imsg_compose_rde(int, pid_t, void *, u_int16_t); -void session_stop(struct peer *, u_int8_t); - -/* log.c */ -char *log_fmt_peer(const struct peer_config *); -void log_statechange(struct peer *, enum session_state, - enum session_events); -void log_notification(const struct peer *, u_int8_t, u_int8_t, - u_char *, u_int16_t, const char *); -void log_conn_attempt(const struct peer *, struct sockaddr *); - -/* parse.y */ -int parse_config(char *, struct bgpd_config *, struct mrt_head *, - struct peer **, struct network_head *, struct filter_head *, - struct rdomain_head *); +/* carp.c */ +int carp_demote_init(char *, int); +void carp_demote_shutdown(void); +int carp_demote_get(char *); +int carp_demote_set(char *, int); /* config.c */ int merge_config(struct bgpd_config *, struct bgpd_config *, @@ -262,9 +244,6 @@ int merge_config(struct bgpd_config *, struct bgpd_config *, void prepare_listeners(struct bgpd_config *); int get_mpe_label(struct rdomain *); -/* rde.c */ -pid_t rde_main(int[2], int[2], int[2], int[2], int); - /* control.c */ int control_init(int, char *); int control_listen(int); @@ -272,6 +251,25 @@ void control_shutdown(int); int control_dispatch_msg(struct pollfd *, u_int *); unsigned int control_accept(int, int); +/* log.c */ +char *log_fmt_peer(const struct peer_config *); +void log_statechange(struct peer *, enum session_state, + enum session_events); +void log_notification(const struct peer *, u_int8_t, u_int8_t, + u_char *, u_int16_t, const char *); +void log_conn_attempt(const struct peer *, struct sockaddr *); + +/* mrt.c */ +void mrt_dump_bgp_msg(struct mrt *, void *, u_int16_t, + struct peer *); +void mrt_dump_state(struct mrt *, u_int16_t, u_int16_t, + struct peer *); + +/* parse.y */ +int parse_config(char *, struct bgpd_config *, struct mrt_head *, + struct peer **, struct network_head *, struct filter_head *, + struct rdomain_head *); + /* pfkey.c */ int pfkey_read(int, struct sadb_msg *); int pfkey_establish(struct peer *); @@ -283,11 +281,19 @@ void print_config(struct bgpd_config *, struct rib_names *, struct network_head *, struct peer *, struct filter_head *, struct mrt_head *, struct rdomain_head *); -/* carp.c */ -int carp_demote_init(char *, int); -void carp_demote_shutdown(void); -int carp_demote_get(char *); -int carp_demote_set(char *, int); +/* rde.c */ +pid_t rde_main(int[2], int[2], int[2], int[2], int); + +/* session.c */ +void session_socket_blockmode(int, enum blockmodes); +pid_t session_main(int[2], int[2], int[2], int[2]); +void bgp_fsm(struct peer *, enum session_events); +int session_neighbor_rrefresh(struct peer *p); +struct peer *getpeerbyaddr(struct bgpd_addr *); +struct peer *getpeerbydesc(const char *); +int imsg_compose_parent(int, u_int32_t, pid_t, void *, u_int16_t); +int imsg_compose_rde(int, pid_t, void *, u_int16_t); +void session_stop(struct peer *, u_int8_t); /* timer.c */ struct peer_timer *timer_get(struct peer *, enum Timer); |