2006-07-03 01:17:05 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
2009-04-09 18:05:13 +05:30
|
|
|
#ifndef UTILS_H
|
|
|
|
#define UTILS_H 1
|
2002-11-10 07:03:55 +05:30
|
|
|
|
|
|
|
#include "libnetlink.h"
|
|
|
|
#include "ll_map.h"
|
|
|
|
#include "rtm_map.h"
|
|
|
|
|
2009-04-09 18:05:13 +05:30
|
|
|
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
|
2008-05-09 23:29:34 +05:30
|
|
|
|
2007-11-19 04:26:25 +05:30
|
|
|
extern family_t preferred_family;
|
2007-04-07 06:44:45 +05:30
|
|
|
extern smallint show_stats; /* UNUSED */
|
|
|
|
extern smallint show_details; /* UNUSED */
|
|
|
|
extern smallint show_raw; /* UNUSED */
|
|
|
|
extern smallint resolve_hosts; /* UNUSED */
|
|
|
|
extern smallint oneline;
|
|
|
|
extern char _SL_;
|
2002-11-10 07:03:55 +05:30
|
|
|
|
|
|
|
#ifndef IPPROTO_ESP
|
2010-10-29 15:16:52 +05:30
|
|
|
#define IPPROTO_ESP 50
|
2002-11-10 07:03:55 +05:30
|
|
|
#endif
|
|
|
|
#ifndef IPPROTO_AH
|
2010-10-29 15:16:52 +05:30
|
|
|
#define IPPROTO_AH 51
|
2002-11-10 07:03:55 +05:30
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SPRINT_BSIZE 64
|
2010-10-29 15:16:52 +05:30
|
|
|
#define SPRINT_BUF(x) char x[SPRINT_BSIZE]
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2008-05-31 13:03:18 +05:30
|
|
|
typedef struct {
|
2007-01-01 00:27:37 +05:30
|
|
|
uint8_t family;
|
|
|
|
uint8_t bytelen;
|
|
|
|
int16_t bitlen;
|
|
|
|
uint32_t data[4];
|
2002-11-10 07:03:55 +05:30
|
|
|
} inet_prefix;
|
|
|
|
|
2008-10-21 18:12:45 +05:30
|
|
|
#define PREFIXLEN_SPECIFIED 1
|
|
|
|
|
2002-11-10 07:03:55 +05:30
|
|
|
#define DN_MAXADDL 20
|
|
|
|
#ifndef AF_DECnet
|
|
|
|
#define AF_DECnet 12
|
|
|
|
#endif
|
|
|
|
|
2007-01-30 04:21:25 +05:30
|
|
|
struct dn_naddr {
|
2008-02-16 18:48:17 +05:30
|
|
|
unsigned short a_len;
|
|
|
|
unsigned char a_addr[DN_MAXADDL];
|
2002-11-10 07:03:55 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
#define IPX_NODE_LEN 6
|
|
|
|
|
|
|
|
struct ipx_addr {
|
2004-01-31 04:29:50 +05:30
|
|
|
uint32_t ipx_net;
|
|
|
|
uint8_t ipx_node[IPX_NODE_LEN];
|
2002-11-10 07:03:55 +05:30
|
|
|
};
|
|
|
|
|
2017-04-07 20:45:40 +05:30
|
|
|
char** next_arg(char **argv) FAST_FUNC;
|
|
|
|
#define NEXT_ARG() do { argv = next_arg(argv); } while (0)
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2017-04-07 20:45:40 +05:30
|
|
|
uint32_t get_addr32(char *name) FAST_FUNC;
|
|
|
|
int get_addr_1(inet_prefix *dst, char *arg, int family) FAST_FUNC;
|
|
|
|
/*void get_prefix_1(inet_prefix *dst, char *arg, int family) FAST_FUNC;*/
|
|
|
|
int get_addr(inet_prefix *dst, char *arg, int family) FAST_FUNC;
|
|
|
|
void get_prefix(inet_prefix *dst, char *arg, int family) FAST_FUNC;
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2017-04-07 20:45:40 +05:30
|
|
|
unsigned get_unsigned(char *arg, const char *errmsg) FAST_FUNC;
|
|
|
|
uint32_t get_u32(char *arg, const char *errmsg) FAST_FUNC;
|
|
|
|
uint16_t get_u16(char *arg, const char *errmsg) FAST_FUNC;
|
|
|
|
|
|
|
|
const char *rt_addr_n2a(int af, void *addr) FAST_FUNC;
|
2009-03-05 14:51:57 +05:30
|
|
|
#ifdef RESOLVE_HOSTNAMES
|
2017-04-07 20:45:40 +05:30
|
|
|
const char *format_host(int af, int len, void *addr) FAST_FUNC;
|
2009-03-05 14:51:57 +05:30
|
|
|
#else
|
2015-10-14 17:26:42 +05:30
|
|
|
#define format_host(af, len, addr) \
|
|
|
|
rt_addr_n2a(af, addr)
|
2009-03-05 14:51:57 +05:30
|
|
|
#endif
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2017-04-07 20:45:40 +05:30
|
|
|
void invarg_1_to_2(const char *, const char *) FAST_FUNC NORETURN;
|
|
|
|
void duparg(const char *, const char *) FAST_FUNC NORETURN;
|
|
|
|
void duparg2(const char *, const char *) FAST_FUNC NORETURN;
|
|
|
|
|
|
|
|
int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits) FAST_FUNC;
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2017-04-07 20:45:40 +05:30
|
|
|
//const char *dnet_ntop(int af, const void *addr, char *str, size_t len);
|
|
|
|
//int dnet_pton(int af, const char *src, void *addr);
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2017-04-07 20:45:40 +05:30
|
|
|
//const char *ipx_ntop(int af, const void *addr, char *str, size_t len);
|
|
|
|
//int ipx_pton(int af, const char *src, void *addr);
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2017-04-07 20:45:40 +05:30
|
|
|
unsigned get_hz(void) FAST_FUNC;
|
2015-10-14 16:23:47 +05:30
|
|
|
|
2009-04-09 18:05:13 +05:30
|
|
|
POP_SAVED_FUNCTION_VISIBILITY
|
2008-05-09 23:29:34 +05:30
|
|
|
|
2009-04-09 18:05:13 +05:30
|
|
|
#endif
|