2006-07-03 01:17:05 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
2002-11-10 07:03:55 +05:30
|
|
|
#ifndef __UTILS_H__
|
|
|
|
#define __UTILS_H__ 1
|
|
|
|
|
2006-06-08 01:47:41 +05:30
|
|
|
#include "libbb.h"
|
2002-11-10 07:03:55 +05:30
|
|
|
|
|
|
|
#include "libnetlink.h"
|
|
|
|
#include "ll_map.h"
|
|
|
|
#include "rtm_map.h"
|
|
|
|
|
|
|
|
extern int preferred_family;
|
|
|
|
extern int show_stats;
|
|
|
|
extern int show_details;
|
|
|
|
extern int show_raw;
|
|
|
|
extern int resolve_hosts;
|
|
|
|
extern int oneline;
|
2007-01-30 05:13:18 +05:30
|
|
|
//FIXME! Appears in two .h files!
|
|
|
|
extern const char * _SL_;
|
2002-11-10 07:03:55 +05:30
|
|
|
|
|
|
|
#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-23 04:25:11 +05:30
|
|
|
extern void incomplete_command(void) ATTRIBUTE_NORETURN;
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2006-12-26 16:12:51 +05:30
|
|
|
#define NEXT_ARG() do { argv++; if (--argc <= 0) incomplete_command(); } while (0)
|
2002-11-10 07:03:55 +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;
|
|
|
|
|
|
|
|
#define DN_MAXADDL 20
|
|
|
|
#ifndef AF_DECnet
|
|
|
|
#define AF_DECnet 12
|
|
|
|
#endif
|
|
|
|
|
2007-01-30 04:21:25 +05:30
|
|
|
struct dn_naddr {
|
2006-01-25 05:38:53 +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
|
|
|
};
|
|
|
|
|
2007-01-01 00:27:37 +05:30
|
|
|
extern uint32_t get_addr32(char *name);
|
2002-11-10 07:03:55 +05:30
|
|
|
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
|
2007-01-01 00:27:37 +05:30
|
|
|
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 07:03:55 +05:30
|
|
|
|
|
|
|
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-30 04:21:58 +05:30
|
|
|
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-01-30 04:21:25 +05:30
|
|
|
int matches(const char *arg, const char *pattern);
|
2002-11-10 07:03:55 +05:30
|
|
|
extern int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
#endif /* __UTILS_H__ */
|