2006-07-02 19:47:05 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
2002-11-10 01:33:55 +00:00
|
|
|
#ifndef __UTILS_H__
|
|
|
|
#define __UTILS_H__ 1
|
|
|
|
|
|
|
|
#include "libnetlink.h"
|
|
|
|
#include "ll_map.h"
|
|
|
|
#include "rtm_map.h"
|
|
|
|
|
2008-05-09 17:59:34 +00:00
|
|
|
#if __GNUC_PREREQ(4,1)
|
|
|
|
# pragma GCC visibility push(hidden)
|
|
|
|
#endif
|
|
|
|
|
2007-11-18 22:56:25 +00:00
|
|
|
extern family_t preferred_family;
|
2007-04-07 01:14:45 +00:00
|
|
|
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 01:33:55 +00:00
|
|
|
|
|
|
|
#ifndef IPPROTO_ESP
|
|
|
|
#define IPPROTO_ESP 50
|
|
|
|
#endif
|
|
|
|
#ifndef IPPROTO_AH
|
|
|
|
#define IPPROTO_AH 51
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SPRINT_BSIZE 64
|
|
|
|
#define SPRINT_BUF(x) char x[SPRINT_BSIZE]
|
|
|
|
|
2006-01-22 22:55:11 +00:00
|
|
|
extern void incomplete_command(void) ATTRIBUTE_NORETURN;
|
2002-11-10 01:33:55 +00:00
|
|
|
|
2007-11-18 22:56:25 +00:00
|
|
|
#define NEXT_ARG() do { if (!*++argv) incomplete_command(); } while (0)
|
2002-11-10 01:33:55 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2006-12-31 18:57:37 +00:00
|
|
|
uint8_t family;
|
|
|
|
uint8_t bytelen;
|
|
|
|
int16_t bitlen;
|
|
|
|
uint32_t data[4];
|
2002-11-10 01:33:55 +00:00
|
|
|
} inet_prefix;
|
|
|
|
|
|
|
|
#define DN_MAXADDL 20
|
|
|
|
#ifndef AF_DECnet
|
|
|
|
#define AF_DECnet 12
|
|
|
|
#endif
|
|
|
|
|
2007-01-29 22:51:25 +00:00
|
|
|
struct dn_naddr {
|
2008-02-16 13:18:17 +00:00
|
|
|
unsigned short a_len;
|
|
|
|
unsigned char a_addr[DN_MAXADDL];
|
2002-11-10 01:33:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define IPX_NODE_LEN 6
|
|
|
|
|
|
|
|
struct ipx_addr {
|
2004-01-30 22:59:50 +00:00
|
|
|
uint32_t ipx_net;
|
|
|
|
uint8_t ipx_node[IPX_NODE_LEN];
|
2002-11-10 01:33:55 +00:00
|
|
|
};
|
|
|
|
|
2006-12-31 18:57:37 +00:00
|
|
|
extern uint32_t get_addr32(char *name);
|
2002-11-10 01:33:55 +00:00
|
|
|
extern int get_addr_1(inet_prefix *dst, char *arg, int family);
|
|
|
|
extern int get_prefix_1(inet_prefix *dst, char *arg, int family);
|
|
|
|
extern int get_addr(inet_prefix *dst, char *arg, int family);
|
|
|
|
extern int get_prefix(inet_prefix *dst, char *arg, int family);
|
|
|
|
|
|
|
|
extern int get_integer(int *val, char *arg, int base);
|
|
|
|
extern int get_unsigned(unsigned *val, char *arg, int base);
|
|
|
|
#define get_byte get_u8
|
|
|
|
#define get_ushort get_u16
|
|
|
|
#define get_short get_s16
|
2006-12-31 18:57:37 +00:00
|
|
|
extern int get_u32(uint32_t *val, char *arg, int base);
|
|
|
|
extern int get_u16(uint16_t *val, char *arg, int base);
|
|
|
|
extern int get_s16(int16_t *val, char *arg, int base);
|
|
|
|
extern int get_u8(uint8_t *val, char *arg, int base);
|
|
|
|
extern int get_s8(int8_t *val, char *arg, int base);
|
2002-11-10 01:33:55 +00:00
|
|
|
|
|
|
|
extern const char *format_host(int af, int len, void *addr, char *buf, int buflen);
|
|
|
|
extern const char *rt_addr_n2a(int af, int len, void *addr, char *buf, int buflen);
|
|
|
|
|
2007-01-29 22:51:58 +00:00
|
|
|
void invarg(const char *, const char *) ATTRIBUTE_NORETURN;
|
|
|
|
void duparg(const char *, const char *) ATTRIBUTE_NORETURN;
|
|
|
|
void duparg2(const char *, const char *) ATTRIBUTE_NORETURN;
|
2007-04-07 01:14:45 +00:00
|
|
|
int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits);
|
2002-11-10 01:33:55 +00:00
|
|
|
|
|
|
|
const char *dnet_ntop(int af, const void *addr, char *str, size_t len);
|
|
|
|
int dnet_pton(int af, const char *src, void *addr);
|
|
|
|
|
|
|
|
const char *ipx_ntop(int af, const void *addr, char *str, size_t len);
|
|
|
|
int ipx_pton(int af, const char *src, void *addr);
|
|
|
|
|
2008-05-09 17:59:34 +00:00
|
|
|
#if __GNUC_PREREQ(4,1)
|
|
|
|
# pragma GCC visibility pop
|
|
|
|
#endif
|
|
|
|
|
2002-11-10 01:33:55 +00:00
|
|
|
#endif /* __UTILS_H__ */
|