1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
/* $Id: ax25rtd.h,v 1.1.1.1 2001/04/10 01:58:39 csmall Exp $
*
* Copyright (c) 1996 Jörg Reuter (jreuter@poboxes.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/* Defines for defaults */
#define IP_MAXROUTES 256
#define AX25_MAXROUTES 256
#define AX25_MAXCALLS 32
/* Some AX.25 stuff */
#define NEW_ARP 1
#define NEW_ROUTE 2
#define NEW_IPMODE 4
#define SEG_FIRST 0x80
#define SEG_REM 0x7F
#define PID_SEGMENT 0x08
#define PID_ARP 0xCD
#define PID_IP 0xCC
#define PID_NETROM 0xCF
#define HDLCAEB 0x01
#define SSSID_SPARE 0x40
#define AX25_REPEATED 0x80
#define LAPB_I 0x00
#define LAPB_S 0x01
#define LAPB_UI 0x03
#define LAPB_PF 0x10
#define ALEN 6
#define AXLEN 7
#define IPLEN 20
/* structs for the caches */
typedef struct ip_rt_entry_ {
struct ip_rt_entry_ *next, *prev;
unsigned long ip;
unsigned char iface[14];
ax25_address call;
char ipmode;
time_t timestamp;
char invalid;
} ip_rt_entry;
typedef struct ax25_rt_entry_ {
struct ax25_rt_entry_ *next, *prev;
unsigned char iface[14];
ax25_address call;
ax25_address digipeater[AX25_MAX_DIGIS];
int ndigi;
long cnt;
time_t timestamp;
} ax25_rt_entry;
/* struct for the channel configuration */
typedef struct config_ {
struct config_ *next;
char port[128];
char dev[14];
char ax25_add_route;
char ax25_for_me;
char ax25_add_default;
char ip_add_route;
char ip_add_arp;
char ip_adjust_mode;
char ip_arp_use_netlink;
unsigned int dg_mtu;
unsigned int vc_mtu;
unsigned long tcp_irtt;
unsigned long netmask;
unsigned long ip;
int nmycalls;
ax25_address mycalls[AX25_MAXCALLS];
struct full_sockaddr_ax25 ax25_default_path;
} config;
/* global variables */
extern const char * Version;
extern int reload;
extern config *Config;
extern ip_rt_entry * ip_routes;
extern int ip_routes_cnt;
extern int ip_maxroutes;
extern ax25_rt_entry * ax25_routes;
extern int ax25_routes_cnt;
extern int ax25_maxroutes;
extern char ip_encaps_dev[];
/* config.c */
void load_config(void);
void reload_config(void);
void load_cache(void);
void save_cache(void);
void interpret_command(int fd, unsigned char *buf);
/* listener.c */
int call_is_mycall(config *config, ax25_address *call);
int set_arp(config *config, long ip, ax25_address *call);
int set_route(config *config, long ip);
int set_ax25_route(config *config, ax25_rt_entry *rt);
int set_ipmode(config *config, ax25_address *call, int ipmode);
int del_kernel_ip_route(char *dev, long ip);
int del_kernel_ax25_route(char *dev, ax25_address *call);
void ax25_receive(int sock);
/* ax25rtd.c */
void daemon_shutdown(int reason);
int set_ipmode(config *config, ax25_address *call, int ipmode);
config * dev_get_config(char *dev);
config * port_get_config(char *port);
/* cache_dump.c */
void dump_ip_routes(int fd, int cmd);
void dump_ax25_routes(int fd, int cmd);
void dump_config(int fd);
/* cache_ctl.c */
int update_ip_route(config *config, unsigned long ip, int ipmode, ax25_address *call, time_t timestamp);
ax25_rt_entry * update_ax25_route(config *config, ax25_address *call, int ndigi, ax25_address *digi, time_t timestamp);
int del_ip_route(unsigned long ip);
int invalidate_ip_route(unsigned long ip);
int del_ax25_route(config * config, ax25_address *call);
void expire_ax25_route(time_t when);
void expire_ip_route(time_t when);
|