| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#include <stdio.h> |
| 22 |
#include <stdlib.h> |
| 23 |
#include <unistd.h> |
| 24 |
#include <time.h> |
| 25 |
#include <sys/types.h> |
| 26 |
#include <netinet/in.h> |
| 27 |
#include <sys/socket.h> |
| 28 |
|
| 29 |
#include <config.h> |
| 30 |
#include <netax25/ax25.h> |
| 31 |
#include <netrose/rose.h> |
| 32 |
#include <netax25/axlib.h> |
| 33 |
|
| 34 |
#include "ax25rtd.h" |
| 35 |
|
| 36 |
void dump_ip_routes(int fd, int cmd) |
| 37 |
{ |
| 38 |
ip_rt_entry *bp; |
| 39 |
config *config; |
| 40 |
char buf[256], *dev; |
| 41 |
unsigned long ip; |
| 42 |
int len; |
| 43 |
|
| 44 |
for (bp = ip_routes; bp; bp = bp->next) { |
| 45 |
ip = htonl(bp->ip); |
| 46 |
|
| 47 |
if (cmd) { |
| 48 |
len = sprintf(buf, "add ip "); |
| 49 |
dev = bp->iface; |
| 50 |
} else { |
| 51 |
len = 0; |
| 52 |
config = dev_get_config(bp->iface); |
| 53 |
if (config != NULL) |
| 54 |
dev = config->port; |
| 55 |
else |
| 56 |
dev = bp->iface; |
| 57 |
} |
| 58 |
|
| 59 |
len += sprintf(buf + len, "%d.%d.%d.%d", |
| 60 |
(int) ((ip & 0xFF000000) >> 24), |
| 61 |
(int) ((ip & 0x00FF0000) >> 16), |
| 62 |
(int) ((ip & 0x0000FF00) >> 8), |
| 63 |
(int) (ip & 0x000000FF)); |
| 64 |
|
| 65 |
len += |
| 66 |
sprintf(buf + len, " %-4s %8.8lx %-9s ", dev, |
| 67 |
bp->timestamp, ax25_ntoa(&bp->call)); |
| 68 |
if (bp->invalid) |
| 69 |
len += sprintf(buf + len, "X\n"); |
| 70 |
else |
| 71 |
len += |
| 72 |
sprintf(buf + len, "%c\n", |
| 73 |
bp->ipmode ? 'v' : 'd'); |
| 74 |
|
| 75 |
write(fd, buf, len); |
| 76 |
} |
| 77 |
|
| 78 |
if (!cmd) |
| 79 |
write(fd, ".\n", 2); |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
void dump_ax25_routes(int fd, int cmd) |
| 84 |
{ |
| 85 |
ax25_rt_entry *bp; |
| 86 |
config *config; |
| 87 |
char buf[256], *dev; |
| 88 |
int k, len; |
| 89 |
|
| 90 |
for (bp = ax25_routes; bp; bp = bp->next) { |
| 91 |
if (cmd) { |
| 92 |
len = sprintf(buf, "add ax25 "); |
| 93 |
dev = bp->iface; |
| 94 |
} else { |
| 95 |
len = 0; |
| 96 |
config = dev_get_config(bp->iface); |
| 97 |
if (config != NULL) |
| 98 |
dev = config->port; |
| 99 |
else |
| 100 |
dev = bp->iface; |
| 101 |
} |
| 102 |
|
| 103 |
len += |
| 104 |
sprintf(buf + len, "%-9s %-4s %8.8lx", |
| 105 |
ax25_ntoa(&bp->call), dev, bp->timestamp); |
| 106 |
|
| 107 |
for (k = 0; k < bp->ndigi; k++) |
| 108 |
len += |
| 109 |
sprintf(buf + len, " %s", |
| 110 |
ax25_ntoa(&bp->digipeater[k])); |
| 111 |
len += sprintf(buf + len, "\n"); |
| 112 |
write(fd, buf, len); |
| 113 |
} |
| 114 |
|
| 115 |
if (!cmd) |
| 116 |
write(fd, ".\n", 2); |
| 117 |
} |
| 118 |
|
| 119 |
void dump_config(int fd) |
| 120 |
{ |
| 121 |
config *config; |
| 122 |
int k; |
| 123 |
|
| 124 |
fprintf(stderr, "config:\n"); |
| 125 |
for (config = Config; config; config = config->next) { |
| 126 |
fprintf(stderr, "Device = %s\n", config->dev); |
| 127 |
fprintf(stderr, "Port = %s\n", config->port); |
| 128 |
fprintf(stderr, "ax25_add_route = %d\n", |
| 129 |
config->ax25_add_route); |
| 130 |
fprintf(stderr, "ax25_for_me = %d\n", |
| 131 |
config->ax25_for_me); |
| 132 |
fprintf(stderr, "ax25_add_default = %d\n", |
| 133 |
config->ax25_add_default); |
| 134 |
fprintf(stderr, "ip_add_route = %d\n", |
| 135 |
config->ip_add_route); |
| 136 |
fprintf(stderr, "ip_add_arp = %d\n", |
| 137 |
config->ip_add_arp); |
| 138 |
fprintf(stderr, "ip_adjust_mode = %d\n", |
| 139 |
config->ip_adjust_mode); |
| 140 |
fprintf(stderr, "netmask = %8.8lx\n", |
| 141 |
config->netmask); |
| 142 |
fprintf(stderr, "ip = %8.8lx\n", config->ip); |
| 143 |
fprintf(stderr, "nmycalls = %d\n", |
| 144 |
config->nmycalls); |
| 145 |
fprintf(stderr, "calls ="); |
| 146 |
for (k = 0; k < config->nmycalls; k++) |
| 147 |
fprintf(stderr, " %s", |
| 148 |
ax25_ntoa(&config->mycalls[k])); |
| 149 |
fprintf(stderr, "\n"); |
| 150 |
fprintf(stderr, "ax25_default_path="); |
| 151 |
for (k = 0; |
| 152 |
k < config->ax25_default_path.fsa_ax25.sax25_ndigis; |
| 153 |
k++) |
| 154 |
fprintf(stderr, " %s", |
| 155 |
ax25_ntoa(&config->ax25_default_path. |
| 156 |
fsa_digipeater[k])); |
| 157 |
fprintf(stderr, "\n.\n"); |
| 158 |
} |
| 159 |
} |