Import 2.3.18pre1
[davej-history.git] / include / net / irda / irttp.h
blob48ac3ee8e0e533472f470347cc5c29412747406c
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: Tue Aug 24 09:27:05 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
13 * All Rights Reserved.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
20 * Neither Dag Brattli nor University of Tromsø admit liability nor
21 * provide warranty for any of this software. This material is
22 * provided "AS-IS" and at no charge.
24 ********************************************************************/
26 #ifndef IRTTP_H
27 #define IRTTP_H
29 #include <linux/types.h>
30 #include <linux/skbuff.h>
31 #include <linux/spinlock.h>
33 #include <net/irda/irda.h>
34 #include <net/irda/irlmp.h>
35 #include <net/irda/qos.h>
36 #include <net/irda/irqueue.h>
38 #define TTP_MAX_CONNECTIONS LM_MAX_CONNECTIONS
39 #define TTP_HEADER 1
40 #define TTP_MAX_HEADER (TTP_HEADER + LMP_MAX_HEADER)
41 #define TTP_SAR_HEADER 5
42 #define TTP_PARAMETERS 0x80
43 #define TTP_MORE 0x80
45 #define DEFAULT_INITIAL_CREDIT 14
47 #define LOW_THRESHOLD 4
48 #define HIGH_THRESHOLD 10
49 #define TTP_MAX_QUEUE 14
51 /* Some priorities for disconnect requests */
52 #define P_NORMAL 0
53 #define P_HIGH 1
55 #define SAR_DISABLE 0
56 #define SAR_UNBOUND 0xffffffff
58 /* Parameters */
59 #define TTP_MAX_SDU_SIZE 0x01
62 * This structure contains all data assosiated with one instance of a TTP
63 * connection.
65 struct tsap_cb {
66 QUEUE queue; /* For linking it into the hashbin */
67 magic_t magic; /* Just in case */
69 __u8 stsap_sel; /* Source TSAP */
70 __u8 dtsap_sel; /* Destination TSAP */
72 struct lsap_cb *lsap; /* Corresponding LSAP to this TSAP */
74 __u8 connected; /* TSAP connected */
76 __u8 initial_credit; /* Initial credit to give peer */
78 int avail_credit; /* Available credit to return to peer */
79 int remote_credit; /* Credit held by peer TTP entity */
80 int send_credit; /* Credit held by local TTP entity */
82 struct sk_buff_head tx_queue; /* Frames to be transmitted */
83 struct sk_buff_head rx_queue; /* Received frames */
84 struct sk_buff_head rx_fragments;
85 int tx_queue_lock;
86 int rx_queue_lock;
87 spinlock_t lock;
89 notify_t notify; /* Callbacks to client layer */
91 struct irda_statistics stats;
92 struct timer_list todo_timer;
94 __u32 max_seg_size; /* Max data that fit into an IrLAP frame */
95 __u8 max_header_size;
97 int rx_sdu_busy; /* RxSdu.busy */
98 __u32 rx_sdu_size; /* Current size of a partially received frame */
99 __u32 rx_max_sdu_size; /* Max receive user data size */
101 int tx_sdu_busy; /* TxSdu.busy */
102 __u32 tx_max_sdu_size; /* Max transmit user data size */
104 int close_pend; /* Close, but disconnect_pend */
105 int disconnect_pend; /* Disconnect, but still data to send */
106 struct sk_buff *disconnect_skb;
109 struct irttp_cb {
110 magic_t magic;
111 hashbin_t *tsaps;
114 int irttp_init(void);
115 void irttp_cleanup(void);
117 struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify);
118 int irttp_close_tsap(struct tsap_cb *self);
120 int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb);
121 int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb);
123 int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
124 __u32 saddr, __u32 daddr,
125 struct qos_info *qos, __u32 max_sdu_size,
126 struct sk_buff *userdata);
127 int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
128 struct sk_buff *userdata);
129 int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *skb,
130 int priority);
131 void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow);
132 struct tsap_cb *irttp_dup(struct tsap_cb *self, void *instance);
134 static __inline __u32 irttp_get_saddr(struct tsap_cb *self)
136 return irlmp_get_saddr(self->lsap);
139 static __inline __u32 irttp_get_daddr(struct tsap_cb *self)
141 return irlmp_get_daddr(self->lsap);
144 extern struct irttp_cb *irttp;
146 #endif /* IRTTP_H */