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

irlan_common.h

Go to the documentation of this file.
00001 /*********************************************************************
00002  *                
00003  * Filename:      irlan_common.h
00004  * Version:       0.8
00005  * Description:   IrDA LAN access layer
00006  * Status:        Experimental.
00007  * Author:        Dag Brattli <dagb@cs.uit.no>
00008  * Created at:    Sun Aug 31 20:14:37 1997
00009  * Modified at:   Fri Apr 21 11:11:38 2000
00010  * Modified by:   Dag Brattli <dagb@cs.uit.no>
00011  * 
00012  *     Copyright (c) 1998-2000 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 IRLAN_H
00027 #define IRLAN_H
00028 
00029 #include <asm/param.h>  /* for HZ */
00030 
00031 #include <linux/kernel.h>
00032 #include <linux/types.h>
00033 #include <linux/skbuff.h>
00034 #include <linux/netdevice.h>
00035 
00036 #include <net/irda/irqueue.h>
00037 #include <net/irda/irttp.h>
00038 
00039 #define IRLAN_MTU        1518
00040 #define IRLAN_TIMEOUT    10*HZ /* 10 seconds */
00041 
00042 /* Command packet types */
00043 #define CMD_GET_PROVIDER_INFO   0
00044 #define CMD_GET_MEDIA_CHAR      1
00045 #define CMD_OPEN_DATA_CHANNEL   2
00046 #define CMD_CLOSE_DATA_CHAN     3
00047 #define CMD_RECONNECT_DATA_CHAN 4
00048 #define CMD_FILTER_OPERATION    5
00049 
00050 /* Some responses */
00051 #define RSP_SUCCESS                 0
00052 #define RSP_INSUFFICIENT_RESOURCES  1
00053 #define RSP_INVALID_COMMAND_FORMAT  2
00054 #define RSP_COMMAND_NOT_SUPPORTED   3
00055 #define RSP_PARAM_NOT_SUPPORTED     4
00056 #define RSP_VALUE_NOT_SUPPORTED     5
00057 #define RSP_NOT_OPEN                6
00058 #define RSP_AUTHENTICATION_REQUIRED 7
00059 #define RSP_INVALID_PASSWORD        8
00060 #define RSP_PROTOCOL_ERROR          9
00061 #define RSP_ASYNCHRONOUS_ERROR    255
00062 
00063 /* Media types */
00064 #define MEDIA_802_3 1
00065 #define MEDIA_802_5 2
00066 
00067 /* Filter parameters */
00068 #define DATA_CHAN   1
00069 #define FILTER_TYPE 2
00070 #define FILTER_MODE 3
00071 
00072 /* Filter types */
00073 #define IRLAN_DIRECTED   0x01
00074 #define IRLAN_FUNCTIONAL 0x02
00075 #define IRLAN_GROUP      0x04
00076 #define IRLAN_MAC_FRAME  0x08
00077 #define IRLAN_MULTICAST  0x10
00078 #define IRLAN_BROADCAST  0x20
00079 #define IRLAN_IPX_SOCKET 0x40
00080 
00081 /* Filter modes */
00082 #define ALL     1
00083 #define FILTER  2
00084 #define NONE    3
00085 
00086 /* Filter operations */
00087 #define GET     1
00088 #define CLEAR   2
00089 #define ADD     3
00090 #define REMOVE  4
00091 #define DYNAMIC 5
00092 
00093 /* Access types */
00094 #define ACCESS_DIRECT  1
00095 #define ACCESS_PEER    2
00096 #define ACCESS_HOSTED  3
00097 
00098 #define IRLAN_BYTE   0
00099 #define IRLAN_SHORT  1
00100 #define IRLAN_ARRAY  2
00101 
00102 #define IRLAN_MAX_HEADER (TTP_HEADER+LMP_HEADER+LAP_MAX_HEADER)
00103 
00104 /*
00105  *  IrLAN client
00106  */
00107 struct irlan_client_cb {
00108         int state;
00109 
00110         int open_retries;
00111 
00112         struct tsap_cb *tsap_ctrl;
00113         __u32 max_sdu_size;
00114         __u8  max_header_size;
00115         
00116         int access_type;         /* Access type of provider */
00117         __u8 reconnect_key[255];
00118         __u8 key_len;
00119         
00120         __u16 recv_arb_val;
00121         __u16 max_frame;
00122         int filter_type;
00123 
00124         int unicast_open;
00125         int broadcast_open;
00126 
00127         int tx_busy;
00128         struct sk_buff_head txq; /* Transmit control queue */
00129 
00130         struct iriap_cb *iriap;
00131 
00132         struct timer_list kick_timer;
00133 };
00134 
00135 /*
00136  * IrLAN provider
00137  */
00138 struct irlan_provider_cb {
00139         int state;
00140         
00141         struct tsap_cb *tsap_ctrl;
00142         __u32 max_sdu_size;
00143         __u8  max_header_size;
00144 
00145         /*
00146          *  Store some values here which are used by the provider to parse
00147          *  the filter operations
00148          */
00149         int data_chan;
00150         int filter_type;
00151         int filter_mode;
00152         int filter_operation;
00153         int filter_entry;
00154         int access_type;     /* Access type */
00155         __u16 send_arb_val;
00156 
00157         __u8 mac_address[6]; /* Generated MAC address for peer device */
00158 };
00159 
00160 /*
00161  *  IrLAN control block
00162  */
00163 struct irlan_cb {
00164         queue_t q; /* Must be first */
00165 
00166         int    magic;
00167         char   ifname[9];
00168         struct device dev;         /* Ethernet device structure*/
00169         struct net_device_stats stats;
00170 
00171         __u32 saddr;               /* Source device address */
00172         __u32 daddr;               /* Destination device address */
00173         int   disconnect_reason;   /* Why we got disconnected */
00174 
00175         int media;                 /* Media type */
00176         __u8 version[2];           /* IrLAN version */
00177         
00178         struct tsap_cb *tsap_data; /* Data TSAP */
00179 
00180         int  use_udata;            /* Use Unit Data transfers */
00181 
00182         __u8 stsap_sel_data;       /* Source data TSAP selector */
00183         __u8 dtsap_sel_data;       /* Destination data TSAP selector */
00184         __u8 dtsap_sel_ctrl;       /* Destination ctrl TSAP selector */
00185 
00186         struct irlan_client_cb   client;   /* Client specific fields */
00187         struct irlan_provider_cb provider; /* Provider specific fields */
00188 
00189         __u32 max_sdu_size;
00190         __u8  max_header_size;
00191         
00192         struct timer_list watchdog_timer;
00193 };
00194 
00195 struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr);
00196 void irlan_close(struct irlan_cb *self);
00197 void irlan_close_tsaps(struct irlan_cb *self);
00198 void irlan_mod_inc_use_count(void);
00199 void irlan_mod_dec_use_count(void);
00200 
00201 int  irlan_register_netdev(struct irlan_cb *self);
00202 void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel);
00203 
00204 void irlan_open_data_tsap(struct irlan_cb *self);
00205 
00206 int irlan_run_ctrl_tx_queue(struct irlan_cb *self);
00207 
00208 void irlan_get_provider_info(struct irlan_cb *self);
00209 void irlan_get_unicast_addr(struct irlan_cb *self);
00210 void irlan_get_media_char(struct irlan_cb *self);
00211 void irlan_open_data_channel(struct irlan_cb *self);
00212 void irlan_close_data_channel(struct irlan_cb *self);
00213 void irlan_set_multicast_filter(struct irlan_cb *self, int status);
00214 void irlan_set_broadcast_filter(struct irlan_cb *self, int status);
00215 void irlan_open_unicast_addr(struct irlan_cb *self);
00216 
00217 int irlan_insert_byte_param(struct sk_buff *skb, char *param, __u8 value);
00218 int irlan_insert_short_param(struct sk_buff *skb, char *param, __u16 value);
00219 int irlan_insert_string_param(struct sk_buff *skb, char *param, char *value);
00220 int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *value, 
00221                              __u16 value_len);
00222 
00223 int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len);
00224 void print_ret_code(__u8 code);
00225 
00226 extern hashbin_t *irlan;
00227 
00228 #endif
00229 
00230