summaryrefslogtreecommitdiffstats
path: root/ax25ipd/ax25ipd.h
blob: 91314c4b48c071e5c116b4d436aa9fe514d7a837 (plain)
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
/* ax25ipd.h    general configuration info
 *
 * Copyright 1991, Michael Westerhof, Sun Microsystems, Inc.
 * This software may be freely used, distributed, or modified, providing
 * this header is not removed.
 *
 */

/*
 * Modifications added for dual port kiss TNC
 * by Michael Durrant VE3PNX and D. Jeff Dionne Feb 4, 1995
 */

/*
 * cleaned up and prototyped for inclusion into the standard linux ax25
 * toolset in january 1997 by rob mayfield, vk5xxx/vk5zeu
 */

/*
 * added route flags, it's a little ugly, but is extensible fairly easily.
 * provided a mechanism for handling broadcast traffic
 * Terry Dawson, VK2KTJ, July 1997.
 *
 * Minor bug fixes.
 * Terry Dawson, VK2KTJ, September 2001.
 */

/* Define the current version number
 *
 * The first digit represents the major release (0 is a prototype release)
 *
 * The second represents major changes that might affect configuration
 * file formats or compilation sequences, or anything that may make
 * existing setups change.
 *
 * The last digit(s) marks simple bug fixes.
 *
 */

#define IPPROTO_AX25 93
#define DEFAULT_UDP_PORT 10093

#include <limits.h>

extern int udp_mode;		/* true if we need a UDP socket */
extern int ip_mode;		/* true if we need the raw IP socket */
extern unsigned short my_udp;	/* the UDP port to use (network byte order) */
extern char ttydevice[PATH_MAX];	/* the tty device for serial comms */
extern int ttyspeed;		/* The baud rate on the tty device */
extern unsigned char mycallsign[7];	/* My callsign, shifted ASCII with SSID */
extern unsigned char mycallsign2[7];	/* My seconds port callsign, shifted ASCII with SSID */
extern unsigned char myalias[7];	/* An alias to use */
extern unsigned char myalias2[7];	/* An alias for second port */
extern char bc_text[128];	/* The text for beacon messages */
extern int bc_interval;		/* The interval, in seconds, between beacons */
extern int bc_every;		/* true=every, false=after */
extern int digi;		/* True if we are connected to a TNC */
extern int loglevel;		/* Verbosity level */
/* addition for dual port flag */
extern int dual_port;

struct ax25ipd_stats {
	int kiss_in;            /* # packets received */
	int kiss_toobig;        /* packet too large */
	int kiss_badtype;       /* control byte non-zero */
	int kiss_out;           /* # packets sent */
	int kiss_beacon_outs;   /* # of beacons sent */
	int kiss_tooshort;      /* packet too short to be a valid frame */
	int kiss_not_for_me;    /* packet not for me (in digi mode) */
	int kiss_i_am_dest;     /* I am destination (in digi mode) */
	int kiss_no_ip_addr;    /* Couldn't find an IP addr for this call */
	int udp_in;             /* # packets received */
	int udp_out;            /* # packets sent */
	int ip_in;              /* # packets received */
	int ip_out;             /* # packets sent */
	int ip_failed_crc;      /* from ip, but failed CRC check */
	int ip_tooshort;        /* packet too short to be a valid frame */
	int ip_not_for_me;      /* packet not for me (in digi mode) */
	int ip_i_am_dest;       /* I am destination (in digi mode) */
};

extern struct ax25ipd_stats stats;

#define MAX_FRAME 2048

extern void LOGLn(int level, const char *str, ...);

#define LOGL1(arg...) LOGLn(1, ##arg)
#define LOGL2(arg...) LOGLn(2, ##arg)
#define LOGL3(arg...) LOGLn(3, ##arg)
#define LOGL4(arg...) LOGLn(4, ##arg)

#define	AXRT_BCAST	1
#define	AXRT_DEFAULT	2

/* start external prototypes */
/* end external prototypes */

/* kiss.c */
void kiss_init(void);
void assemble_kiss(unsigned char *, int);
void send_kiss(unsigned char, unsigned char *, int);
void param_add(int, int);
void dump_params(void);
void send_params(void);
/* void do_beacon(void);  not here it isnt !! xxx */

/* routing.c */
void route_init(void);
void route_add(unsigned char *, unsigned char *, int, unsigned int);
void bcast_add(unsigned char *);
unsigned char *call_to_ip(unsigned char *);
int is_call_bcast(unsigned char *);
void send_broadcast(unsigned char *, int);
void dump_routes(void);

/* config.c */
void config_init(void);
void config_read(char *);
int parse_line(char *);
int a_to_call(char *, unsigned char *);
char *call_to_a(unsigned char *);
void dump_config(void);

/* process.c */
void process_init(void);
void from_kiss(unsigned char *, int);
void from_ip(unsigned char *, int);
/* void do_broadcast(void);  where did this go ?? xxx */
void do_beacon(void);
int addrmatch(unsigned char *, unsigned char *);
unsigned char *next_addr(unsigned char *);
void add_crc(unsigned char *, int);
void dump_ax25frame(char *, unsigned char *, int);

/* io.c */
void io_init(void);
void io_open(void);
void io_start(void);
void send_ip(unsigned char *, int, unsigned char *);
void send_tty(unsigned char *, int);

/* crc.c */
unsigned short int compute_crc(unsigned char *, int);
unsigned short int pppfcs(unsigned short, unsigned char *, int);
unsigned short int compute_crc(unsigned char *, int);
int ok_crc(unsigned char *, int);

/* io.c */
extern int ttyfd_bpq;
extern int ttyfd;

/* bpqether.c */
int send_bpq(unsigned char *buf, int len);
int receive_bpq(unsigned char *buf, int l);
int open_ethertap(char *ifname);
int set_bpq_dev_call_and_up(char *ethertap_name);

/*
 * end
 */