discovery.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*********************************************************************
  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, see <http://www.gnu.org/licenses/>.
  27. *
  28. ********************************************************************/
  29. #ifndef DISCOVERY_H
  30. #define DISCOVERY_H
  31. #include <asm/param.h>
  32. #include <net/irda/irda.h>
  33. #include <net/irda/irqueue.h> /* irda_queue_t */
  34. #include <net/irda/irlap_event.h> /* LAP_REASON */
  35. #define DISCOVERY_EXPIRE_TIMEOUT (2*sysctl_discovery_timeout*HZ)
  36. #define DISCOVERY_DEFAULT_SLOTS 0
  37. /*
  38. * This type is used by the protocols that transmit 16 bits words in
  39. * little endian format. A little endian machine stores MSB of word in
  40. * byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0]
  41. * and LSB in byte[1].
  42. *
  43. * This structure is used in the code for things that are endian neutral
  44. * but that fit in a word so that we can manipulate them efficiently.
  45. * By endian neutral, I mean things that are really an array of bytes,
  46. * and always used as such, for example the hint bits. Jean II
  47. */
  48. typedef union {
  49. __u16 word;
  50. __u8 byte[2];
  51. } __u16_host_order;
  52. /* Types of discovery */
  53. typedef enum {
  54. DISCOVERY_LOG, /* What's in our discovery log */
  55. DISCOVERY_ACTIVE, /* Doing our own discovery on the medium */
  56. DISCOVERY_PASSIVE, /* Peer doing discovery on the medium */
  57. EXPIRY_TIMEOUT, /* Entry expired due to timeout */
  58. } DISCOVERY_MODE;
  59. #define NICKNAME_MAX_LEN 21
  60. /* Basic discovery information about a peer */
  61. typedef struct irda_device_info discinfo_t; /* linux/irda.h */
  62. /*
  63. * The DISCOVERY structure is used for both discovery requests and responses
  64. */
  65. typedef struct discovery_t {
  66. irda_queue_t q; /* Must be first! */
  67. discinfo_t data; /* Basic discovery information */
  68. int name_len; /* Length of nickname */
  69. LAP_REASON condition; /* More info about the discovery */
  70. int gen_addr_bit; /* Need to generate a new device
  71. * address? */
  72. int nslots; /* Number of slots to use when
  73. * discovering */
  74. unsigned long timestamp; /* Last time discovered */
  75. unsigned long firststamp; /* First time discovered */
  76. } discovery_t;
  77. void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *discovery);
  78. void irlmp_add_discovery_log(hashbin_t *cachelog, hashbin_t *log);
  79. void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force);
  80. struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn,
  81. __u16 mask, int old_entries);
  82. #endif