1/********************************************************************* 2 * 3 * Filename: irlan_common.h 4 * Version: 0.8 5 * Description: IrDA LAN access layer 6 * Status: Experimental. 7 * Author: Dag Brattli <dagb@cs.uit.no> 8 * Created at: Sun Aug 31 20:14:37 1997 9 * Modified at: Sun Oct 31 19:41:24 1999 10 * Modified by: Dag Brattli <dagb@cs.uit.no> 11 * 12 * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, 13 * All Rights Reserved. 14 * 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. 19 * 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. 23 * 24 ********************************************************************/ 25 26#ifndef IRLAN_H 27#define IRLAN_H 28 29#include <asm/param.h> /* for HZ */ 30 31#include <linux/kernel.h> 32#include <linux/types.h> 33#include <linux/skbuff.h> 34#include <linux/netdevice.h> 35#include <linux/if_ether.h> 36 37#include <net/irda/irttp.h> 38 39#define IRLAN_MTU 1518 40#define IRLAN_TIMEOUT 10*HZ /* 10 seconds */ 41 42/* Command packet types */ 43#define CMD_GET_PROVIDER_INFO 0 44#define CMD_GET_MEDIA_CHAR 1 45#define CMD_OPEN_DATA_CHANNEL 2 46#define CMD_CLOSE_DATA_CHAN 3 47#define CMD_RECONNECT_DATA_CHAN 4 48#define CMD_FILTER_OPERATION 5 49 50/* Some responses */ 51#define RSP_SUCCESS 0 52#define RSP_INSUFFICIENT_RESOURCES 1 53#define RSP_INVALID_COMMAND_FORMAT 2 54#define RSP_COMMAND_NOT_SUPPORTED 3 55#define RSP_PARAM_NOT_SUPPORTED 4 56#define RSP_VALUE_NOT_SUPPORTED 5 57#define RSP_NOT_OPEN 6 58#define RSP_AUTHENTICATION_REQUIRED 7 59#define RSP_INVALID_PASSWORD 8 60#define RSP_PROTOCOL_ERROR 9 61#define RSP_ASYNCHRONOUS_ERROR 255 62 63/* Media types */ 64#define MEDIA_802_3 1 65#define MEDIA_802_5 2 66 67/* Filter parameters */ 68#define DATA_CHAN 1 69#define FILTER_TYPE 2 70#define FILTER_MODE 3 71 72/* Filter types */ 73#define IRLAN_DIRECTED 0x01 74#define IRLAN_FUNCTIONAL 0x02 75#define IRLAN_GROUP 0x04 76#define IRLAN_MAC_FRAME 0x08 77#define IRLAN_MULTICAST 0x10 78#define IRLAN_BROADCAST 0x20 79#define IRLAN_IPX_SOCKET 0x40 80 81/* Filter modes */ 82#define ALL 1 83#define FILTER 2 84#define NONE 3 85 86/* Filter operations */ 87#define GET 1 88#define CLEAR 2 89#define ADD 3 90#define REMOVE 4 91#define DYNAMIC 5 92 93/* Access types */ 94#define ACCESS_DIRECT 1 95#define ACCESS_PEER 2 96#define ACCESS_HOSTED 3 97 98#define IRLAN_BYTE 0 99#define IRLAN_SHORT 1 100#define IRLAN_ARRAY 2 101 102/* IrLAN sits on top if IrTTP */ 103#define IRLAN_MAX_HEADER (TTP_HEADER+LMP_HEADER) 104/* 1 byte for the command code and 1 byte for the parameter count */ 105#define IRLAN_CMD_HEADER 2 106 107#define IRLAN_STRING_PARAMETER_LEN(name, value) (1 + strlen((name)) + 2 \ 108 + strlen ((value))) 109#define IRLAN_BYTE_PARAMETER_LEN(name) (1 + strlen((name)) + 2 + 1) 110#define IRLAN_SHORT_PARAMETER_LEN(name) (1 + strlen((name)) + 2 + 2) 111 112/* 113 * IrLAN client 114 */ 115struct irlan_client_cb { 116 int state; 117 118 int open_retries; 119 120 struct tsap_cb *tsap_ctrl; 121 __u32 max_sdu_size; 122 __u8 max_header_size; 123 124 int access_type; /* Access type of provider */ 125 __u8 reconnect_key[255]; 126 __u8 key_len; 127 128 __u16 recv_arb_val; 129 __u16 max_frame; 130 int filter_type; 131 132 int unicast_open; 133 int broadcast_open; 134 135 int tx_busy; 136 struct sk_buff_head txq; /* Transmit control queue */ 137 138 struct iriap_cb *iriap; 139 140 struct timer_list kick_timer; 141}; 142 143/* 144 * IrLAN provider 145 */ 146struct irlan_provider_cb { 147 int state; 148 149 struct tsap_cb *tsap_ctrl; 150 __u32 max_sdu_size; 151 __u8 max_header_size; 152 153 /* 154 * Store some values here which are used by the provider to parse 155 * the filter operations 156 */ 157 int data_chan; 158 int filter_type; 159 int filter_mode; 160 int filter_operation; 161 int filter_entry; 162 int access_type; /* Access type */ 163 __u16 send_arb_val; 164 165 __u8 mac_address[ETH_ALEN]; /* Generated MAC address for peer device */ 166}; 167 168/* 169 * IrLAN control block 170 */ 171struct irlan_cb { 172 int magic; 173 struct list_head dev_list; 174 struct net_device *dev; /* Ethernet device structure*/ 175 176 __u32 saddr; /* Source device address */ 177 __u32 daddr; /* Destination device address */ 178 int disconnect_reason; /* Why we got disconnected */ 179 180 int media; /* Media type */ 181 __u8 version[2]; /* IrLAN version */ 182 183 struct tsap_cb *tsap_data; /* Data TSAP */ 184 185 int use_udata; /* Use Unit Data transfers */ 186 187 __u8 stsap_sel_data; /* Source data TSAP selector */ 188 __u8 dtsap_sel_data; /* Destination data TSAP selector */ 189 __u8 dtsap_sel_ctrl; /* Destination ctrl TSAP selector */ 190 191 struct irlan_client_cb client; /* Client specific fields */ 192 struct irlan_provider_cb provider; /* Provider specific fields */ 193 194 __u32 max_sdu_size; 195 __u8 max_header_size; 196 197 wait_queue_head_t open_wait; 198 struct timer_list watchdog_timer; 199}; 200 201void irlan_close(struct irlan_cb *self); 202void irlan_close_tsaps(struct irlan_cb *self); 203 204int irlan_register_netdev(struct irlan_cb *self); 205void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel); 206void irlan_start_watchdog_timer(struct irlan_cb *self, int timeout); 207 208void irlan_open_data_tsap(struct irlan_cb *self); 209 210int irlan_run_ctrl_tx_queue(struct irlan_cb *self); 211 212struct irlan_cb *irlan_get_any(void); 213void irlan_get_provider_info(struct irlan_cb *self); 214void irlan_get_media_char(struct irlan_cb *self); 215void irlan_open_data_channel(struct irlan_cb *self); 216void irlan_close_data_channel(struct irlan_cb *self); 217void irlan_set_multicast_filter(struct irlan_cb *self, int status); 218void irlan_set_broadcast_filter(struct irlan_cb *self, int status); 219 220int irlan_insert_byte_param(struct sk_buff *skb, char *param, __u8 value); 221int irlan_insert_short_param(struct sk_buff *skb, char *param, __u16 value); 222int irlan_insert_string_param(struct sk_buff *skb, char *param, char *value); 223int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *value, 224 __u16 value_len); 225 226int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len); 227 228#endif 229 230 231