[1770] | 1 | /* vi: set sw=4 ts=4: */
|
---|
[821] | 2 | #ifndef __UTILS_H__
|
---|
| 3 | #define __UTILS_H__ 1
|
---|
| 4 |
|
---|
| 5 | #include "libnetlink.h"
|
---|
| 6 | #include "ll_map.h"
|
---|
| 7 | #include "rtm_map.h"
|
---|
| 8 |
|
---|
| 9 | extern int preferred_family;
|
---|
[1770] | 10 | extern smallint show_stats; /* UNUSED */
|
---|
| 11 | extern smallint show_details; /* UNUSED */
|
---|
| 12 | extern smallint show_raw; /* UNUSED */
|
---|
| 13 | extern smallint resolve_hosts; /* UNUSED */
|
---|
| 14 | extern smallint oneline;
|
---|
| 15 | extern char _SL_;
|
---|
[821] | 16 |
|
---|
| 17 | #ifndef IPPROTO_ESP
|
---|
| 18 | #define IPPROTO_ESP 50
|
---|
| 19 | #endif
|
---|
| 20 | #ifndef IPPROTO_AH
|
---|
| 21 | #define IPPROTO_AH 51
|
---|
| 22 | #endif
|
---|
| 23 |
|
---|
| 24 | #define SPRINT_BSIZE 64
|
---|
| 25 | #define SPRINT_BUF(x) char x[SPRINT_BSIZE]
|
---|
| 26 |
|
---|
| 27 | extern void incomplete_command(void) ATTRIBUTE_NORETURN;
|
---|
| 28 |
|
---|
[1770] | 29 | #define NEXT_ARG() do { argv++; if (--argc <= 0) incomplete_command(); } while (0)
|
---|
[821] | 30 |
|
---|
| 31 | typedef struct
|
---|
| 32 | {
|
---|
[1770] | 33 | uint8_t family;
|
---|
| 34 | uint8_t bytelen;
|
---|
| 35 | int16_t bitlen;
|
---|
| 36 | uint32_t data[4];
|
---|
[821] | 37 | } inet_prefix;
|
---|
| 38 |
|
---|
| 39 | #define DN_MAXADDL 20
|
---|
| 40 | #ifndef AF_DECnet
|
---|
| 41 | #define AF_DECnet 12
|
---|
| 42 | #endif
|
---|
| 43 |
|
---|
[1770] | 44 | struct dn_naddr {
|
---|
[821] | 45 | unsigned short a_len;
|
---|
| 46 | unsigned char a_addr[DN_MAXADDL];
|
---|
| 47 | };
|
---|
| 48 |
|
---|
| 49 | #define IPX_NODE_LEN 6
|
---|
| 50 |
|
---|
| 51 | struct ipx_addr {
|
---|
| 52 | uint32_t ipx_net;
|
---|
| 53 | uint8_t ipx_node[IPX_NODE_LEN];
|
---|
| 54 | };
|
---|
| 55 |
|
---|
[1770] | 56 | extern uint32_t get_addr32(char *name);
|
---|
[821] | 57 | extern int get_addr_1(inet_prefix *dst, char *arg, int family);
|
---|
| 58 | extern int get_prefix_1(inet_prefix *dst, char *arg, int family);
|
---|
| 59 | extern int get_addr(inet_prefix *dst, char *arg, int family);
|
---|
| 60 | extern int get_prefix(inet_prefix *dst, char *arg, int family);
|
---|
| 61 |
|
---|
| 62 | extern int get_integer(int *val, char *arg, int base);
|
---|
| 63 | extern int get_unsigned(unsigned *val, char *arg, int base);
|
---|
| 64 | #define get_byte get_u8
|
---|
| 65 | #define get_ushort get_u16
|
---|
| 66 | #define get_short get_s16
|
---|
[1770] | 67 | extern int get_u32(uint32_t *val, char *arg, int base);
|
---|
| 68 | extern int get_u16(uint16_t *val, char *arg, int base);
|
---|
| 69 | extern int get_s16(int16_t *val, char *arg, int base);
|
---|
| 70 | extern int get_u8(uint8_t *val, char *arg, int base);
|
---|
| 71 | extern int get_s8(int8_t *val, char *arg, int base);
|
---|
[821] | 72 |
|
---|
| 73 | extern const char *format_host(int af, int len, void *addr, char *buf, int buflen);
|
---|
| 74 | extern const char *rt_addr_n2a(int af, int len, void *addr, char *buf, int buflen);
|
---|
| 75 |
|
---|
[1770] | 76 | void invarg(const char *, const char *) ATTRIBUTE_NORETURN;
|
---|
| 77 | void duparg(const char *, const char *) ATTRIBUTE_NORETURN;
|
---|
| 78 | void duparg2(const char *, const char *) ATTRIBUTE_NORETURN;
|
---|
| 79 | int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits);
|
---|
[821] | 80 |
|
---|
| 81 | const char *dnet_ntop(int af, const void *addr, char *str, size_t len);
|
---|
| 82 | int dnet_pton(int af, const char *src, void *addr);
|
---|
| 83 |
|
---|
| 84 | const char *ipx_ntop(int af, const void *addr, char *str, size_t len);
|
---|
| 85 | int ipx_pton(int af, const char *src, void *addr);
|
---|
| 86 |
|
---|
| 87 | #endif /* __UTILS_H__ */
|
---|