summaryrefslogtreecommitdiffstats
path: root/include/net/ax25.h
blob: fc0509a3fe4edbef30c6b6282faf02e407c1b7b6 (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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
 *	Declarations of AX.25 type objects.
 *
 *	Alan Cox (GW4PTS) 	10/11/93
 */
 
#ifndef _AX25_H
#define _AX25_H 
#include <linux/ax25.h>

#define AX25_TICS                       (HZ/10)             /* AX25 timertic is 1/10 sec (100 ms) */
#define AX25_SLOWHZ			10                  /* 10 timertics, 1 second */

#define	AX25_T1CLAMPLO  		AX25_SLOWHZ         /* 1 sec   */
#define	AX25_T1CLAMPHI 			(30 * AX25_SLOWHZ)  /* 30 secs */

#define	AX25_BPQ_HEADER_LEN		16

#define	AX25_ADDR_LEN			7
#define AX25_MIN_HEADER_LEN             (AX25_ADDR_LEN*2+1) /* Source, Destination, Control */
#define	AX25_MAX_HEADER_LEN             (AX25_MIN_HEADER_LEN+1+AX25_ADDR_LEN*AX25_MAX_DIGIS) /* ... including Digipeaters */

/*
 * these are obsolete
 *
 * #define	AX25_KISS_HEADER_LEN		1
 * #define	AX25_HEADER_LEN			17
 * #define	AX25_DIGI_HEADER_LEN		(AX25_MAX_DIGIS * AX25_ADDR_LEN)
 */

/* AX.25 Protocol IDs */
#define AX25_P_ROSE			0x01
#define AX25_P_IP			0xCC
#define AX25_P_ARP			0xCD
#define AX25_P_TEXT 			0xF0
#define AX25_P_NETROM 			0xCF
#define	AX25_P_SEGMENT			0x08
#define AX25_P_VJCOMP                   0x06 /* Matthias Welwarsky (DG2FEF) */
#define AX25_P_VJUNCOMP                 0x07 /* Matthias Welwarsky (DG2FEF) */

/* AX.25 Segment control values */
#define	AX25_SEG_REM			0x7F
#define	AX25_SEG_FIRST			0x80

#define AX25_CBIT			0x80	/* Command/Response bit */
#define AX25_EBIT			0x01	/* HDLC Address Extension bit */
#define AX25_HBIT			0x80	/* Has been repeated bit */

#define AX25_SSSID_SPARE		0x60	/* Unused bits in SSID for standard AX.25 */
#define AX25_ESSID_SPARE		0x20	/* Unused bits in SSID for extended AX.25 */
#define AX25_DAMA_FLAG			0x20	/* Well, it is *NOT* unused! (dl1bke 951121) */

#define	AX25_COND_ACK_PENDING		0x01
#define	AX25_COND_REJECT		0x02
#define	AX25_COND_PEER_RX_BUSY		0x04
#define	AX25_COND_OWN_RX_BUSY		0x08
#define AX25_COND_STATE_CHANGE          0x10
#define AX25_COND_RELEASE               0x20
#define AX25_COND_SETUP                 0x40
#define AX25_COND_START_T1              0x80

#define AX25_SCHED_IDLE                 0
#define AX25_SCHED_READY                1

#ifndef _LINUX_NETDEVICE_H
#include <linux/netdevice.h>
#endif

/*
 * These headers are taken from the KA9Q package by Phil Karn. These specific
 * files have been placed under the GPL (not the whole package) by Phil.
 *
 *
 * Copyright 1991 Phil Karn, KA9Q
 *
 * 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; version 2 dated June, 1991.
 *
 * 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.
 */

/* Upper sub-layer (LAPB) definitions */

/* Control field templates */
#define	AX25_I			0x00	/* Information frames */
#define	AX25_S			0x01	/* Supervisory frames */
#define	AX25_RR			0x01	/* Receiver ready */
#define	AX25_RNR		0x05	/* Receiver not ready */
#define	AX25_REJ		0x09	/* Reject */
#define	AX25_U			0x03	/* Unnumbered frames */
#define	AX25_SABM		0x2f	/* Set Asynchronous Balanced Mode */
#define	AX25_SABME		0x6f	/* Set Asynchronous Balanced Mode Extended */
#define	AX25_DISC		0x43	/* Disconnect */
#define	AX25_DM			0x0f	/* Disconnected mode */
#define	AX25_UA			0x63	/* Unnumbered acknowledge */
#define	AX25_FRMR		0x87	/* Frame reject */
#define	AX25_UI			0x03	/* Unnumbered information */

#define	AX25_PF			0x10	/* Poll/final bit for standard AX.25 */
#define	AX25_EPF		0x01	/* Poll/final bit for extended AX.25 */

#define AX25_ILLEGAL		0x100	/* Impossible to be a real frame type */

#define	AX25_POLLOFF		0
#define	AX25_POLLON		1

/* AX25 L2 C-bit */
#define AX25_COMMAND		1
#define AX25_RESPONSE		2

/* Define Link State constants. */

enum {
	AX25_STATE_0 = 0,
	AX25_STATE_1,
	AX25_STATE_2,
	AX25_STATE_3,
	AX25_STATE_4,
	AX25_LISTEN
};

typedef enum {
	AX25_SEQMASK  = 7,
	AX25_ESEQMASK = 127
} ax25_seqmask_t;

#ifndef _AX25_VJ_H
struct axvj_slcomp;
#endif

typedef struct {
	unsigned int csum;
	struct sk_buff *skb;
} ax25_reseq_t;

typedef struct ax25_cb {
	struct ax25_cb          *prev;         /* doubly linked list now */
	struct ax25_cb		*next;
	struct ax25_cb          *peer;         /* for FlexNet style digipeating */
	struct net_device	*device;       /* backlink to device structure */
	int                     inserted;      /* Socket is on a list */
	struct sock		*sk;	       /* Backlink to socket */

	/* used by the DDI layer */
	struct {
		int             state;
		struct ax25_cb  *prev;
		struct ax25_cb  *next;
	} ready;

	unsigned short          tx_cmd, tx_rsp;

	/* layer II values
	 *
	 * vs = sequence number assigned to next to be transmitted I frame
	 * va = sequence number of first I frame our peer has not acked yet
	 * vr = sequence number of next frame we expect to receive from peer
	 * vl = last frame we ack'ed yet
	 */
	ax25_addr_t             addr;
	unsigned char		state, condition;
	unsigned short		vs, vr, va, vs_max, vl, window;
	ax25_seqmask_t          seqmask;
	unsigned long           rtt_timestamp;
	short                   rtt, vs_rtt;
	unsigned char		n2, n2count;
	unsigned short		t1, t2, t3, idle;
	unsigned short		wrt_timer, ack_timer, idletimer, killtimer;
	unsigned short		paclen, fragno, fraglen;
	unsigned char		iamdigi, pidincl, backoff;
	struct sk_buff_head	write_queue;
	struct sk_buff_head     rcv_queue;            /* MW: for flow control handling */
	struct sk_buff_head	ack_queue;
	struct sk_buff_head	frag_queue;
        struct axvj_slcomp      *slcomp;              /* MW: for VJ Compression */
        unsigned char           slcomp_enable;        /* MW: dito. */
	ax25_reseq_t            reseq[AX25_SEQMASK+1];  /* MW: resequencer, not for EMODULUS */
	rwlock_t		timer_lock;
} ax25_cb;

typedef struct {
	ax25_addr_t		addr;
	unsigned short		frametype;
	unsigned short		nr;
	unsigned short		ns;
        unsigned char		pf;
	unsigned char		cmdrsp;
	unsigned char		dama;
} ax25_pktinfo;

#define DAMA_STATE(ax25_cb) (AX25_PTR(ax25_cb->device)->dama_mode)

/* needed by netrom/rose */
extern __inline__ unsigned long ax25_display_timer(struct timer_list *timer)
{
	if (!timer_pending(timer))
		return 0;
	return timer->expires - jiffies;
}

#include <net/ax25call.h>

extern ax25_address* asc2ax(char *);
extern ax25_address null_ax25_address;
extern char* ax2asc(ax25_address *);
extern int ax25cmp(ax25_address *, ax25_address *);
extern ax25_cb *ax25_send_frame(struct sk_buff*, int, ax25_addr_t*, struct net_device*);
extern ax25_cb *ax25_find_cb(ax25_addr_t*, struct net_device*);

/* ax25_out.c */
extern void ax25_output(ax25_cb *, int, struct sk_buff *);

/* ax25_timer.c */
extern void ax25_timer(ax25_cb *);
extern void ax25_link_failed(ax25_cb *, int);
extern int  (*ax25_protocol_function(unsigned int))(struct sk_buff *, ax25_cb *);

/* sysctl_net_ax25.c */
extern void ax25_register_sysctl(void);
extern void ax25_unregister_sysctl(void);

/* support routines for modules that use AX.25, in ax25_timer.c */
extern int  ax25_protocol_register(unsigned int, int (*)(struct sk_buff *, ax25_cb *));
extern void ax25_protocol_release(unsigned int);
extern int  ax25_linkfail_register(void (*)(ax25_cb *, int));
extern void ax25_linkfail_release(void (*)(ax25_cb *, int));
extern int  ax25_listen_register(ax25_address *, struct net_device *);
extern void ax25_listen_release(ax25_address *, struct net_device *);
extern int  ax25_protocol_is_registered(unsigned int);

#endif