diff options
author | Sebastian Benoit <benno@cvs.openbsd.org> | 2017-05-28 10:01:53 +0000 |
---|---|---|
committer | Sebastian Benoit <benno@cvs.openbsd.org> | 2017-05-28 10:01:53 +0000 |
commit | 90eef07f063af85537832b565bc801af317ecace (patch) | |
tree | b39a0a4ccb87b86e07793312867f92f4b277fe74 /usr.sbin/traceroute/traceroute.h | |
parent | 88c2969b1928b632d0289227ceb82206e3f4e3c0 (diff) |
introduce struct tr_conf to keep all of the configuration.
Functions needing access to any of those vars get it passed as a parameter.
result: even less global vars.
ok florian@
Diffstat (limited to 'usr.sbin/traceroute/traceroute.h')
-rw-r--r-- | usr.sbin/traceroute/traceroute.h | 68 |
1 files changed, 50 insertions, 18 deletions
diff --git a/usr.sbin/traceroute/traceroute.h b/usr.sbin/traceroute/traceroute.h index 2729ac30e9b..91a38fe76dd 100644 --- a/usr.sbin/traceroute/traceroute.h +++ b/usr.sbin/traceroute/traceroute.h @@ -1,4 +1,4 @@ -/* $OpenBSD: traceroute.h,v 1.2 2017/01/13 18:00:10 florian Exp $ */ +/* $OpenBSD: traceroute.h,v 1.3 2017/05/28 10:01:52 benno Exp $ */ /* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */ /* @@ -86,30 +86,68 @@ struct packetdata { u_int32_t usec; } __packed; -extern struct in_addr gateway[MAX_LSRR + 1]; -extern int lsrrlen; +struct tr_conf { + int verbose; + + u_short ident; + + int incflag; /* Do not inc the dest. port num */ + int dflag; /* set SO_DEBUG */ + int dump; + int Aflag; /* lookup ASN */ + int first_ttl; /* Set the first TTL or hop limit */ + + u_char proto; /* IP payload protocol to use */ + int protoset; + + int ttl_flag; /* display ttl on returned packet */ + u_int8_t max_ttl; /* Set the maximum TTL / hop limit */ + int nflag; /* print addresses numerically */ + + u_int16_t port; /* start udp dest port */ + int nprobes; + char *source; + int sump; + + int tos; + int tflag; /* tos value was set */ + + int last_tos; + + u_int rtableid; /* Set the routing table */ + + int waittime; /* time to wait for a response */ + + int lsrr; /* Loose Source Record Route */ + int lsrrlen; + struct in_addr gateway[MAX_LSRR + 1]; +}; + extern int32_t sec_perturb; extern int32_t usec_perturb; extern u_char packet[512]; extern u_char *outpacket; /* last inbound (icmp) packet */ -int wait_for_reply(int, struct msghdr *); +int wait_for_reply(int, struct msghdr *, int); void dump_packet(void); -void build_probe4(int, u_int8_t, int); -void build_probe6(int, u_int8_t, int, struct sockaddr *); -void send_probe(int, u_int8_t, int, struct sockaddr *); -struct udphdr *get_udphdr(struct ip6_hdr *, u_char *); -int packet_ok(int, struct msghdr *, int, int, int); -int packet_ok4(struct msghdr *, int, int, int); -int packet_ok6(struct msghdr *, int, int, int); +void build_probe4(struct tr_conf *, int, u_int8_t, int); +void build_probe6(struct tr_conf *, int, u_int8_t, int, + struct sockaddr *); +void send_probe(struct tr_conf *, int, u_int8_t, int, + struct sockaddr *); +struct udphdr *get_udphdr(struct tr_conf *, struct ip6_hdr *, u_char *); +int packet_ok(struct tr_conf *, int, struct msghdr *, int, int, + int); +int packet_ok4(struct tr_conf *, struct msghdr *, int, int, int); +int packet_ok6(struct tr_conf *, struct msghdr *, int, int, int); void icmp_code(int, int, int *, int *); void icmp4_code(int, int *, int *); void icmp6_code(int, int *, int *); void dump_packet(void); void print_exthdr(u_char *, int); void check_tos(struct ip*); -void print(struct sockaddr *, int, const char *); +void print(struct tr_conf *, struct sockaddr *, int, const char *); const char *inetname(struct sockaddr*); void print_asn(struct sockaddr_storage *); u_short in_cksum(u_short *, int); @@ -129,18 +167,12 @@ extern int datalen; /* How much data */ extern char *hostname; -extern u_short ident; extern u_int16_t srcport; -extern u_int16_t port; /* start udp dest port # for probe packets */ -extern u_char proto; #define ICMP_CODE 0; extern int verbose; -extern int curwaittime; /* time left to wait for response */ -extern int nflag; /* print addresses numerically */ extern int dump; -extern int Aflag; /* lookup ASN */ extern int last_tos; extern char *__progname; |