Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

irttp.h

Go to the documentation of this file.
00001 /*********************************************************************
00002  *                
00003  * Filename:      irttp.h
00004  * Version:       1.0
00005  * Description:   Tiny Transport Protocol (TTP) definitions
00006  * Status:        Experimental.
00007  * Author:        Dag Brattli <dagb@cs.uit.no>
00008  * Created at:    Sun Aug 31 20:14:31 1997
00009  * Modified at:   Sun Dec 12 13:09:07 1999
00010  * Modified by:   Dag Brattli <dagb@cs.uit.no>
00011  * 
00012  *     Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, 
00013  *     All Rights Reserved.
00014  *     
00015  *     This program is free software; you can redistribute it and/or 
00016  *     modify it under the terms of the GNU General Public License as 
00017  *     published by the Free Software Foundation; either version 2 of 
00018  *     the License, or (at your option) any later version.
00019  *
00020  *     Neither Dag Brattli nor University of Tromsų admit liability nor
00021  *     provide warranty for any of this software. This material is 
00022  *     provided "AS-IS" and at no charge.
00023  *
00024  ********************************************************************/
00025 
00026 #ifndef IRTTP_H
00027 #define IRTTP_H
00028 
00029 #include <linux/types.h>
00030 #include <linux/skbuff.h>
00031 #include <asm/spinlock.h>
00032 
00033 #include <net/irda/irda.h>
00034 #include <net/irda/irlmp.h>
00035 #include <net/irda/qos.h>
00036 #include <net/irda/irqueue.h>
00037 
00038 #define TTP_MAX_CONNECTIONS    LM_MAX_CONNECTIONS
00039 #define TTP_HEADER             1
00040 #define TTP_MAX_HEADER         (TTP_HEADER + LMP_MAX_HEADER)
00041 #define TTP_SAR_HEADER         5
00042 #define TTP_PARAMETERS         0x80
00043 #define TTP_MORE               0x80
00044 
00045 #define DEFAULT_INITIAL_CREDIT 14
00046 
00047 #define TTP_LOW_THRESHOLD       4
00048 #define TTP_HIGH_THRESHOLD     10
00049 #define TTP_MAX_QUEUE          14
00050 
00051 /* Some priorities for disconnect requests */
00052 #define P_NORMAL    0
00053 #define P_HIGH      1
00054 
00055 #define TTP_SAR_DISABLE 0
00056 #define TTP_SAR_UNBOUND 0xffffffff
00057 
00058 /* Parameters */
00059 #define TTP_MAX_SDU_SIZE 0x01
00060 
00061 /*
00062  *  This structure contains all data assosiated with one instance of a TTP 
00063  *  connection.
00064  */
00065 struct tsap_cb {
00066         queue_t q;            /* Must be first */
00067         magic_t magic;        /* Just in case */
00068 
00069         __u8 stsap_sel;       /* Source TSAP */
00070         __u8 dtsap_sel;       /* Destination TSAP */
00071 
00072         struct lsap_cb *lsap; /* Corresponding LSAP to this TSAP */
00073 
00074         __u8 connected;       /* TSAP connected */
00075          
00076         __u8 initial_credit;  /* Initial credit to give peer */
00077 
00078         int avail_credit;    /* Available credit to return to peer */
00079         int remote_credit;   /* Credit held by peer TTP entity */
00080         int send_credit;     /* Credit held by local TTP entity */
00081         
00082         struct sk_buff_head tx_queue; /* Frames to be transmitted */
00083         struct sk_buff_head rx_queue; /* Received frames */
00084         struct sk_buff_head rx_fragments;
00085         int tx_queue_lock;
00086         int rx_queue_lock;
00087         spinlock_t lock;
00088 
00089         notify_t notify;       /* Callbacks to client layer */
00090 
00091         struct net_device_stats stats;
00092         struct timer_list todo_timer; 
00093         
00094         __u32 max_seg_size;     /* Max data that fit into an IrLAP frame */
00095         __u8  max_header_size;
00096 
00097         int   rx_sdu_busy;     /* RxSdu.busy */
00098         __u32 rx_sdu_size;     /* Current size of a partially received frame */
00099         __u32 rx_max_sdu_size; /* Max receive user data size */
00100 
00101         int tx_sdu_busy;       /* TxSdu.busy */
00102         __u32 tx_max_sdu_size; /* Max transmit user data size */
00103 
00104         int close_pend;        /* Close, but disconnect_pend */
00105         int disconnect_pend;   /* Disconnect, but still data to send */
00106         struct sk_buff *disconnect_skb;
00107 };
00108 
00109 struct irttp_cb {
00110         magic_t    magic;       
00111         hashbin_t *tsaps;
00112 };
00113 
00114 int  irttp_init(void);
00115 void irttp_cleanup(void);
00116 
00117 struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify);
00118 int irttp_close_tsap(struct tsap_cb *self);
00119 
00120 int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb);
00121 int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb);
00122 
00123 int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel, 
00124                           __u32 saddr, __u32 daddr,
00125                           struct qos_info *qos, __u32 max_sdu_size, 
00126                           struct sk_buff *userdata);
00127 int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size, 
00128                             struct sk_buff *userdata);
00129 int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *skb,
00130                              int priority);
00131 void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow);
00132 struct tsap_cb *irttp_dup(struct tsap_cb *self, void *instance);
00133 
00134 static __inline __u32 irttp_get_saddr(struct tsap_cb *self)
00135 {
00136         return irlmp_get_saddr(self->lsap);
00137 }
00138 
00139 static __inline __u32 irttp_get_daddr(struct tsap_cb *self)
00140 {
00141         return irlmp_get_daddr(self->lsap);
00142 }
00143 
00144 static __inline __u32 irttp_get_max_seg_size(struct tsap_cb *self)
00145 {
00146         return self->max_seg_size;
00147 }
00148 
00149 extern struct irttp_cb *irttp;
00150 
00151 #endif /* IRTTP_H */