Import 2.3.4pre3
[davej-history.git] / include / net / irda / irttp.h
blob3e6511ceae5bcd73951e9c1875422a35a5fa7092
1 /*********************************************************************
2 *
3 * Filename: irttp.h
4 * Version: 1.0
5 * Description: Tiny Transport Protocol (TTP) definitions
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Sun Aug 31 20:14:31 1997
9 * Modified at: Mon May 10 19:14:51 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * Neither Dag Brattli nor University of Tromsø admit liability nor
20 * provide warranty for any of this software. This material is
21 * provided "AS-IS" and at no charge.
23 ********************************************************************/
25 #ifndef IRTTP_H
26 #define IRTTP_H
28 #include <linux/types.h>
29 #include <linux/skbuff.h>
30 #include <asm/spinlock.h>
32 #include <net/irda/irda.h>
33 #include <net/irda/irlmp.h>
34 #include <net/irda/qos.h>
35 #include <net/irda/irqueue.h>
37 #define TTP_MAX_CONNECTIONS LM_MAX_CONNECTIONS
38 #define TTP_HEADER 1
39 #define TTP_MAX_HEADER (TTP_HEADER + LMP_MAX_HEADER)
40 #define TTP_SAR_HEADER 5
41 #define TTP_PARAMETERS 0x80
42 #define TTP_MORE 0x80
44 #define DEFAULT_INITIAL_CREDIT 22
46 #define LOW_THRESHOLD 4
47 #define HIGH_THRESHOLD 8
48 #define TTP_MAX_QUEUE 22
50 /* Some priorities for disconnect requests */
51 #define P_NORMAL 0
52 #define P_HIGH 1
54 #define SAR_DISABLE 0
55 #define SAR_UNBOUND 0xffffffff
58 * This structure contains all data assosiated with one instance of a TTP
59 * connection.
61 struct tsap_cb {
62 QUEUE queue; /* For linking it into the hashbin */
63 int magic; /* Just in case */
65 __u8 stsap_sel; /* Source TSAP */
66 __u8 dtsap_sel; /* Destination TSAP */
68 struct lsap_cb *lsap; /* Corresponding LSAP to this TSAP */
70 __u8 connected; /* TSAP connected */
72 __u8 initial_credit; /* Initial credit to give peer */
74 int avail_credit; /* Available credit to return to peer */
75 int remote_credit; /* Credit held by peer TTP entity */
76 int send_credit; /* Credit held by local TTP entity */
78 struct sk_buff_head tx_queue; /* Frames to be transmitted */
79 struct sk_buff_head rx_queue; /* Received frames */
80 struct sk_buff_head rx_fragments;
81 int tx_queue_lock;
82 int rx_queue_lock;
83 spinlock_t lock;
85 struct notify_t notify; /* Callbacks to client layer */
87 struct irda_statistics stats;
88 struct timer_list todo_timer;
90 __u32 max_seg_size; /* Max data that fit into an IrLAP frame */
91 __u8 max_header_size;
93 int rx_sdu_busy; /* RxSdu.busy */
94 __u32 rx_sdu_size; /* Current size of a partially received frame */
95 __u32 rx_max_sdu_size; /* Max receive user data size */
97 int tx_sdu_busy; /* TxSdu.busy */
98 __u32 tx_max_sdu_size; /* Max transmit user data size */
100 int close_pend; /* Close, but disconnect_pend */
101 int disconnect_pend; /* Disconnect, but still data to send */
102 struct sk_buff *disconnect_skb;
105 struct irttp_cb {
106 int magic;
108 hashbin_t *tsaps;
111 int irttp_init(void);
112 void irttp_cleanup(void);
114 struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit,
115 struct notify_t *notify);
116 int irttp_close_tsap(struct tsap_cb *self);
118 int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb);
119 int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb);
121 int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
122 __u32 saddr, __u32 daddr,
123 struct qos_info *qos, __u32 max_sdu_size,
124 struct sk_buff *userdata);
125 void irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
126 struct sk_buff *userdata);
127 struct tsap_cb *irttp_dup(struct tsap_cb *self, void *instance);
128 void irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *skb,
129 int priority);
130 void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow);
132 static __inline __u32 irttp_get_saddr(struct tsap_cb *self)
134 return irlmp_get_saddr(self->lsap);
137 static __inline __u32 irttp_get_daddr(struct tsap_cb *self)
139 return irlmp_get_daddr(self->lsap);
142 extern struct irttp_cb *irttp;
144 #endif /* IRTTP_H */