1 /*********************************************************************
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 Mar 22 13:17:30 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (c) 1998 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 ********************************************************************/
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
39 #define TTP_HEADER_WITH_SAR 6
40 #define TTP_PARAMETERS 0x80
43 #define DEFAULT_INITIAL_CREDIT 22
45 #define LOW_THRESHOLD 4
46 #define HIGH_THRESHOLD 8
47 #define TTP_MAX_QUEUE 22
49 /* Some priorities for disconnect requests */
54 #define SAR_UNBOUND 0xffffffff
57 * This structure contains all data assosiated with one instance of a TTP
61 QUEUE queue
; /* For linking it into the hashbin */
62 int magic
; /* Just in case */
64 int max_seg_size
; /* Max data that fit into an IrLAP frame */
66 __u8 stsap_sel
; /* Source TSAP */
67 __u8 dtsap_sel
; /* Destination TSAP */
69 struct lsap_cb
*lsap
; /* Corresponding LSAP to this TSAP */
71 __u8 connected
; /* TSAP connected */
73 __u8 initial_credit
; /* Initial credit to give peer */
75 int avail_credit
; /* Available credit to return to peer */
76 int remote_credit
; /* Credit held by peer TTP entity */
77 int send_credit
; /* Credit held by local TTP entity */
79 struct sk_buff_head tx_queue
; /* Frames to be transmitted */
80 struct sk_buff_head rx_queue
; /* Received frames */
81 struct sk_buff_head rx_fragments
;
86 struct notify_t notify
; /* Callbacks to client layer */
88 struct irda_statistics stats
;
89 struct timer_list todo_timer
;
91 int rx_sdu_busy
; /* RxSdu.busy */
92 __u32 rx_sdu_size
; /* Current size of a partially received frame */
93 __u32 rx_max_sdu_size
; /* Max receive user data size */
95 int tx_sdu_busy
; /* TxSdu.busy */
96 int tx_max_sdu_size
; /* Max transmit user data size */
98 int close_pend
; /* Close, but disconnect_pend */
99 int disconnect_pend
; /* Disconnect, but still data to send */
100 struct sk_buff
*disconnect_skb
;
109 int irttp_init(void);
110 void irttp_cleanup(void);
112 struct tsap_cb
*irttp_open_tsap(__u8 stsap_sel
, int credit
,
113 struct notify_t
*notify
);
114 int irttp_close_tsap(struct tsap_cb
*self
);
116 int irttp_data_request(struct tsap_cb
*self
, struct sk_buff
*skb
);
117 int irttp_udata_request(struct tsap_cb
*self
, struct sk_buff
*skb
);
119 int irttp_connect_request(struct tsap_cb
*self
, __u8 dtsap_sel
,
120 __u32 saddr
, __u32 daddr
,
121 struct qos_info
*qos
, __u32 max_sdu_size
,
122 struct sk_buff
*userdata
);
123 void irttp_connect_confirm(void *instance
, void *sap
, struct qos_info
*qos
,
124 __u32 max_sdu_size
, struct sk_buff
*skb
);
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
,
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
;