9 #include "libnetlink.h"
13 extern int preferred_family
;
14 extern int show_stats
;
15 extern int show_details
;
17 extern int resolve_hosts
;
21 extern int max_flush_loops
;
22 extern int batch_mode
;
25 #define IPPROTO_ESP 50
31 #define IPPROTO_COMP 108
33 #ifndef IPSEC_PROTO_ANY
34 #define IPSEC_PROTO_ANY 255
37 #define SPRINT_BSIZE 64
38 #define SPRINT_BUF(x) char x[SPRINT_BSIZE]
40 extern void incomplete_command(void) __attribute__((noreturn
));
42 #define NEXT_ARG() do { argv++; if (--argc <= 0) incomplete_command(); } while(0)
43 #define NEXT_ARG_OK() (argc - 1 > 0)
44 #define PREV_ARG() do { argv--; argc++; } while(0)
55 #define PREFIXLEN_SPECIFIED 1
65 unsigned char a_addr
[DN_MAXADDL
];
68 #define IPX_NODE_LEN 6
72 u_int8_t ipx_node
[IPX_NODE_LEN
];
75 extern __u32
get_addr32(const char *name
);
76 extern int get_addr_1(inet_prefix
*dst
, const char *arg
, int family
);
77 extern int get_prefix_1(inet_prefix
*dst
, char *arg
, int family
);
78 extern int get_addr(inet_prefix
*dst
, const char *arg
, int family
);
79 extern int get_prefix(inet_prefix
*dst
, char *arg
, int family
);
80 extern int mask2bits(__u32 netmask
);
82 extern int get_integer(int *val
, const char *arg
, int base
);
83 extern int get_unsigned(unsigned *val
, const char *arg
, int base
);
84 extern int get_time_rtt(unsigned *val
, const char *arg
, int *raw
);
85 #define get_byte get_u8
86 #define get_ushort get_u16
87 #define get_short get_s16
88 extern int get_u64(__u64
*val
, const char *arg
, int base
);
89 extern int get_u32(__u32
*val
, const char *arg
, int base
);
90 extern int get_s32(__s32
*val
, const char *arg
, int base
);
91 extern int get_u16(__u16
*val
, const char *arg
, int base
);
92 extern int get_s16(__s16
*val
, const char *arg
, int base
);
93 extern int get_u8(__u8
*val
, const char *arg
, int base
);
94 extern int get_s8(__s8
*val
, const char *arg
, int base
);
96 extern char* hexstring_n2a(const __u8
*str
, int len
, char *buf
, int blen
);
97 extern __u8
* hexstring_a2n(const char *str
, __u8
*buf
, int blen
);
99 extern const char *format_host(int af
, int len
, const void *addr
,
100 char *buf
, int buflen
);
101 extern const char *rt_addr_n2a(int af
, const void *addr
,
102 char *buf
, int buflen
);
104 void missarg(const char *) __attribute__((noreturn
));
105 void invarg(const char *, const char *) __attribute__((noreturn
));
106 void duparg(const char *, const char *) __attribute__((noreturn
));
107 void duparg2(const char *, const char *) __attribute__((noreturn
));
108 int matches(const char *arg
, const char *pattern
);
109 extern int inet_addr_match(const inet_prefix
*a
, const inet_prefix
*b
, int bits
);
111 const char *dnet_ntop(int af
, const void *addr
, char *str
, size_t len
);
112 int dnet_pton(int af
, const char *src
, void *addr
);
114 const char *ipx_ntop(int af
, const void *addr
, char *str
, size_t len
);
115 int ipx_pton(int af
, const char *src
, void *addr
);
117 extern int __iproute2_hz_internal
;
118 extern int __get_hz(void);
120 static __inline__
int get_hz(void)
122 if (__iproute2_hz_internal
== 0)
123 __iproute2_hz_internal
= __get_hz();
124 return __iproute2_hz_internal
;
127 extern int __iproute2_user_hz_internal
;
128 extern int __get_user_hz(void);
130 static __inline__
int get_user_hz(void)
132 if (__iproute2_user_hz_internal
== 0)
133 __iproute2_user_hz_internal
= __get_user_hz();
134 return __iproute2_user_hz_internal
;
137 static inline __u32
nl_mgrp(__u32 group
)
140 fprintf(stderr
, "Use setsockopt for this group %d\n", group
);
143 return group
? (1 << (group
- 1)) : 0;
147 int print_timestamp(FILE *fp
);
149 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
151 extern int cmdlineno
;
152 extern ssize_t
getcmdline(char **line
, size_t *len
, FILE *in
);
153 extern int makeargs(char *line
, char *argv
[], int maxargs
);
154 extern int inet_get_addr(const char *src
, __u32
*dst
, struct in6_addr
*dst6
);
157 int iplink_parse(int argc
, char **argv
, struct iplink_req
*req
,
158 char **name
, char **type
, char **link
, char **dev
,
159 int *group
, int *index
);
160 #endif /* __UTILS_H__ */