summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd/ldpe.h
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2016-05-23 19:09:26 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2016-05-23 19:09:26 +0000
commit9a6be7cacb6639ebc04ff1c77d286ff2bfeab4ac (patch)
tree70480467d857aa1836cf8a37bb8dfe4d40f7aaef /usr.sbin/ldpd/ldpe.h
parent67d9951684dd55318043e75ea48c0967801eb517 (diff)
Make functions and variables static whenever possible.
The benefits of this include: * clean up of the ldpd global namespace; * improved readability; * more hints to the compiler/linker to generate more efficient code. Whenever possible, move global static variables to a smaller scope (function). All extern variables are now declared in header files to avoid unnecessary duplication. This patch also cleans up the indentation of all function prototypes and global variables.
Diffstat (limited to 'usr.sbin/ldpd/ldpe.h')
-rw-r--r--usr.sbin/ldpd/ldpe.h128
1 files changed, 49 insertions, 79 deletions
diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h
index 8caea614685..83248b5f78f 100644
--- a/usr.sbin/ldpd/ldpe.h
+++ b/usr.sbin/ldpd/ldpe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.h,v 1.52 2016/05/23 18:58:48 renato Exp $ */
+/* $OpenBSD: ldpe.h,v 1.53 2016/05/23 19:09:25 renato Exp $ */
/*
* Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org>
@@ -97,6 +97,12 @@ struct nbr {
char md5key[TCP_MD5_KEY_LEN];
} auth;
};
+RB_HEAD(nbr_id_head, nbr);
+RB_PROTOTYPE(nbr_id_head, nbr, id_tree, nbr_id_compare)
+RB_HEAD(nbr_addr_head, nbr);
+RB_PROTOTYPE(nbr_addr_head, nbr, addr_tree, nbr_addr_compare)
+RB_HEAD(nbr_pid_head, nbr);
+RB_PROTOTYPE(nbr_pid_head, nbr, pid_tree, nbr_pid_compare)
struct pending_conn {
TAILQ_ENTRY(pending_conn) entry;
@@ -117,6 +123,12 @@ struct ldpd_sysdep {
uint8_t no_md5sig;
};
+extern struct ldpd_conf *leconf;
+extern struct ldpd_sysdep sysdep;
+extern struct nbr_id_head nbrs_by_id;
+extern struct nbr_addr_head nbrs_by_addr;
+extern struct nbr_pid_head nbrs_by_pid;
+
/* accept.c */
void accept_init(void);
int accept_add(int, void (*)(int, short, void *), void *);
@@ -138,10 +150,10 @@ void send_keepalive(struct nbr *);
int recv_keepalive(struct nbr *, char *, uint16_t);
/* notification.c */
-void send_notification_nbr(struct nbr *, uint32_t, uint32_t, uint32_t);
+void send_notification_full(struct tcp_conn *, struct notify_msg *);
void send_notification(uint32_t, struct tcp_conn *, uint32_t,
uint32_t);
-void send_notification_full(struct tcp_conn *, struct notify_msg *);
+void send_notification_nbr(struct nbr *, uint32_t, uint32_t, uint32_t);
int recv_notification(struct nbr *, char *, uint16_t);
/* address.c */
@@ -152,8 +164,8 @@ int recv_address(struct nbr *, char *, uint16_t);
#define PREFIX_SIZE(x) (((x) + 7) / 8)
void send_labelmessage(struct nbr *, uint16_t, struct mapping_head *);
int recv_labelmessage(struct nbr *, char *, uint16_t, uint16_t);
-void gen_fec_tlv(struct ibuf *, struct map *);
void gen_pw_status_tlv(struct ibuf *, uint32_t);
+void gen_fec_tlv(struct ibuf *, struct map *);
int tlv_decode_fec_elm(struct nbr *, struct ldp_msg *, char *,
uint16_t, struct map *);
@@ -163,17 +175,11 @@ int ldpe_imsg_compose_parent(int, pid_t, void *,
uint16_t);
int ldpe_imsg_compose_lde(int, uint32_t, pid_t, void *,
uint16_t);
-void ldpe_dispatch_main(int, short, void *);
-void ldpe_dispatch_lde(int, short, void *);
-void ldpe_dispatch_pfkey(int, short, void *);
-void ldpe_setup_sockets(int, int, int, int);
-void ldpe_close_sockets(int);
void ldpe_reset_nbrs(int);
void ldpe_reset_ds_nbrs(void);
void ldpe_remove_dynamic_tnbrs(int);
void ldpe_stop_init_backoff(int);
struct ctl_conn;
-void ldpe_iface_af_ctl(struct ctl_conn *, int, unsigned int);
void ldpe_iface_ctl(struct ctl_conn *, unsigned int);
void ldpe_adj_ctl(struct ctl_conn *);
void ldpe_nbr_ctl(struct ctl_conn *);
@@ -181,104 +187,68 @@ void mapping_list_add(struct mapping_head *, struct map *);
void mapping_list_clr(struct mapping_head *);
/* interface.c */
-int if_start(struct iface *, int);
-int if_reset(struct iface *, int);
-void if_update_af(struct iface_af *, int);
-void if_update(struct iface *, int);
-void if_update_all(int);
-
struct iface *if_new(struct kif *);
void if_del(struct iface *);
struct iface *if_lookup(struct ldpd_conf *, unsigned short);
struct iface_af *iface_af_get(struct iface *, int);
-struct if_addr *if_addr_new(struct kaddr *);
-struct if_addr *if_addr_lookup(struct if_addr_head *, struct kaddr *);
void if_addr_add(struct kaddr *);
void if_addr_del(struct kaddr *);
-
-struct ctl_iface *if_to_ctl(struct iface_af *);
-
+void if_update(struct iface *, int);
+void if_update_all(int);
+struct ctl_iface *if_to_ctl(struct iface_af *);
in_addr_t if_get_ipv4_addr(struct iface *);
-int if_join_ipv4_group(struct iface *, struct in_addr *);
-int if_leave_ipv4_group(struct iface *, struct in_addr *);
-int if_join_ipv6_group(struct iface *, struct in6_addr *);
-int if_leave_ipv6_group(struct iface *, struct in6_addr *);
/* adjacency.c */
struct adj *adj_new(struct in_addr, struct hello_source *,
- union ldpd_addr *);
+ union ldpd_addr *);
void adj_del(struct adj *);
struct adj *adj_find(struct hello_source *);
int adj_get_af(struct adj *adj);
void adj_start_itimer(struct adj *);
void adj_stop_itimer(struct adj *);
struct tnbr *tnbr_new(struct ldpd_conf *, int, union ldpd_addr *);
-void tnbr_del(struct tnbr *);
struct tnbr *tnbr_find(struct ldpd_conf *, int, union ldpd_addr *);
struct tnbr *tnbr_check(struct tnbr *);
void tnbr_update(struct tnbr *);
void tnbr_update_all(int);
-
struct ctl_adj *adj_to_ctl(struct adj *);
/* neighbor.c */
-struct nbr *nbr_new(struct in_addr, int, int, union ldpd_addr *, uint32_t);
-void nbr_del(struct nbr *);
-void nbr_update_peerid(struct nbr *);
-
-struct nbr *nbr_find_ldpid(uint32_t);
-struct nbr *nbr_find_addr(int, union ldpd_addr *);
-struct nbr *nbr_find_peerid(uint32_t);
-int nbr_adj_count(struct nbr *, int);
-
-int nbr_fsm(struct nbr *, enum nbr_event);
-int nbr_session_active_role(struct nbr *);
-
-void nbr_ktimer(int, short, void *);
-void nbr_start_ktimer(struct nbr *);
-void nbr_stop_ktimer(struct nbr *);
-void nbr_ktimeout(int, short, void *);
-void nbr_start_ktimeout(struct nbr *);
-void nbr_stop_ktimeout(struct nbr *);
-void nbr_idtimer(int, short, void *);
-void nbr_start_idtimer(struct nbr *);
-void nbr_stop_idtimer(struct nbr *);
-int nbr_pending_idtimer(struct nbr *);
-int nbr_pending_connect(struct nbr *);
-int nbr_establish_connection(struct nbr *);
-
-uint16_t nbr_get_keepalive(int, struct in_addr);
+int nbr_fsm(struct nbr *, enum nbr_event);
+struct nbr *nbr_new(struct in_addr, int, int, union ldpd_addr *,
+ uint32_t);
+void nbr_del(struct nbr *);
+struct nbr *nbr_find_ldpid(uint32_t);
+struct nbr *nbr_find_addr(int, union ldpd_addr *);
+struct nbr *nbr_find_peerid(uint32_t);
+int nbr_adj_count(struct nbr *, int);
+int nbr_session_active_role(struct nbr *);
+void nbr_stop_ktimer(struct nbr *);
+void nbr_stop_ktimeout(struct nbr *);
+void nbr_start_idtimer(struct nbr *);
+void nbr_stop_idtimer(struct nbr *);
+int nbr_pending_idtimer(struct nbr *);
+int nbr_pending_connect(struct nbr *);
+int nbr_establish_connection(struct nbr *);
struct nbr_params *nbr_params_new(struct in_addr);
struct nbr_params *nbr_params_find(struct ldpd_conf *, struct in_addr);
-
-struct ctl_nbr *nbr_to_ctl(struct nbr *);
-
-extern struct nbr_id_head nbrs_by_id;
-RB_PROTOTYPE(nbr_id_head, nbr, id_tree, nbr_id_compare)
-extern struct nbr_addr_head nbrs_by_addr;
-RB_PROTOTYPE(nbr_addr_head, nbr, addr_tree, nbr_addr_compare)
-extern struct nbr_pid_head nbrs_by_pid;
-RB_PROTOTYPE(nbr_pid_head, nbr, pid_tree, nbr_pid_compare)
+uint16_t nbr_get_keepalive(int, struct in_addr);
+struct ctl_nbr *nbr_to_ctl(struct nbr *);
/* packet.c */
-int gen_ldp_hdr(struct ibuf *, uint16_t);
-int gen_msg_hdr(struct ibuf *, uint32_t, uint16_t);
-int send_packet(int, int, union ldpd_addr *, struct iface_af *, void *,
- size_t);
-void disc_recv_packet(int, short, void *);
-void session_accept(int, short, void *);
-void session_accept_nbr(struct nbr *, int);
-void session_read(int, short, void *);
-void session_write(int, short, void *);
-void session_close(struct nbr *);
-void session_shutdown(struct nbr *, uint32_t, uint32_t, uint32_t);
-
+int gen_ldp_hdr(struct ibuf *, uint16_t);
+int gen_msg_hdr(struct ibuf *, uint32_t, uint16_t);
+int send_packet(int, int, union ldpd_addr *,
+ struct iface_af *, void *, size_t);
+void disc_recv_packet(int, short, void *);
+void session_accept(int, short, void *);
+void session_accept_nbr(struct nbr *, int);
+void session_shutdown(struct nbr *, uint32_t, uint32_t,
+ uint32_t);
+void session_close(struct nbr *);
struct tcp_conn *tcp_new(int, struct nbr *);
-void tcp_close(struct tcp_conn *);
-struct pending_conn *pending_conn_new(int, int, union ldpd_addr *);
void pending_conn_del(struct pending_conn *);
struct pending_conn *pending_conn_find(int, union ldpd_addr *);
-void pending_conn_timeout(int, short, void *);
char *pkt_ptr; /* packet buffer */
@@ -286,7 +256,7 @@ char *pkt_ptr; /* packet buffer */
int pfkey_read(int, struct sadb_msg *);
int pfkey_establish(struct nbr *, struct nbr_params *);
int pfkey_remove(struct nbr *);
-int pfkey_init(struct ldpd_sysdep *);
+int pfkey_init(void);
/* l2vpn.c */
void ldpe_l2vpn_init(struct l2vpn *);