blob: eb0f9de472943b3521ff187c9b23e0d061dd5370 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*********************************************************************
2 *
3 * Filename: discovery.h
4 * Version:
5 * Description:
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Tue Apr 6 16:53:53 1999
9 * Modified at: Tue Oct 5 10:05:10 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
11 *
12 * Copyright (c) 1999 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com>
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 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * MA 02111-1307 USA
29 *
30 ********************************************************************/
31
32#ifndef DISCOVERY_H
33#define DISCOVERY_H
34
35#include <asm/param.h>
36
37#include <net/irda/irda.h>
38#include <net/irda/irqueue.h> /* irda_queue_t */
39#include <net/irda/irlap_event.h> /* LAP_REASON */
40
41#define DISCOVERY_EXPIRE_TIMEOUT (2*sysctl_discovery_timeout*HZ)
42#define DISCOVERY_DEFAULT_SLOTS 0
43
44/*
45 * This type is used by the protocols that transmit 16 bits words in
46 * little endian format. A little endian machine stores MSB of word in
47 * byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0]
48 * and LSB in byte[1].
49 *
50 * This structure is used in the code for things that are endian neutral
51 * but that fit in a word so that we can manipulate them efficiently.
52 * By endian neutral, I mean things that are really an array of bytes,
53 * and always used as such, for example the hint bits. Jean II
54 */
55typedef union {
56 __u16 word;
57 __u8 byte[2];
58} __u16_host_order;
59
60/* Same purpose, different application */
61#define u16ho(array) (* ((__u16 *) array))
62
63/* Types of discovery */
64typedef enum {
65 DISCOVERY_LOG, /* What's in our discovery log */
66 DISCOVERY_ACTIVE, /* Doing our own discovery on the medium */
67 DISCOVERY_PASSIVE, /* Peer doing discovery on the medium */
68 EXPIRY_TIMEOUT, /* Entry expired due to timeout */
69} DISCOVERY_MODE;
70
71#define NICKNAME_MAX_LEN 21
72
73/* Basic discovery information about a peer */
74typedef struct irda_device_info discinfo_t; /* linux/irda.h */
75
76/*
77 * The DISCOVERY structure is used for both discovery requests and responses
78 */
79typedef struct discovery_t {
80 irda_queue_t q; /* Must be first! */
81
82 discinfo_t data; /* Basic discovery information */
83 int name_len; /* Lenght of nickname */
84
85 LAP_REASON condition; /* More info about the discovery */
86 int gen_addr_bit; /* Need to generate a new device
87 * address? */
88 int nslots; /* Number of slots to use when
89 * discovering */
90 unsigned long timestamp; /* Last time discovered */
91 unsigned long firststamp; /* First time discovered */
92} discovery_t;
93
94void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *discovery);
95void irlmp_add_discovery_log(hashbin_t *cachelog, hashbin_t *log);
96void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force);
97struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn,
98 __u16 mask, int old_entries);
99
100#endif