tipc_bearer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * include/net/tipc/tipc_bearer.h: Include file for privileged access to TIPC bearers
  3. *
  4. * Copyright (c) 2003-2005, Ericsson Research Canada
  5. * Copyright (c) 2005, Wind River Systems
  6. * Copyright (c) 2005-2006, Ericsson AB
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are met:
  11. *
  12. * Redistributions of source code must retain the above copyright notice, this
  13. * list of conditions and the following disclaimer.
  14. * Redistributions in binary form must reproduce the above copyright notice,
  15. * this list of conditions and the following disclaimer in the documentation
  16. * and/or other materials provided with the distribution.
  17. * Neither the names of the copyright holders nor the names of its
  18. * contributors may be used to endorse or promote products derived from this
  19. * software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  25. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  26. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  27. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  29. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  30. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31. * POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #ifndef _NET_TIPC_BEARER_H_
  34. #define _NET_TIPC_BEARER_H_
  35. #ifdef __KERNEL__
  36. #include <linux/tipc_config.h>
  37. #include <linux/skbuff.h>
  38. #include <linux/spinlock.h>
  39. /*
  40. * Identifiers of supported TIPC media types
  41. */
  42. #define TIPC_MEDIA_TYPE_ETH 1
  43. struct tipc_media_addr {
  44. __u32 type;
  45. union {
  46. __u8 eth_addr[6]; /* Ethernet bearer */
  47. #if 0
  48. /* Prototypes for other possible bearer types */
  49. struct {
  50. __u16 sin_family;
  51. __u16 sin_port;
  52. struct {
  53. __u32 s_addr;
  54. } sin_addr;
  55. char pad[4];
  56. } addr_in; /* IP-based bearer */
  57. __u16 sock_descr; /* generic socket bearer */
  58. #endif
  59. } dev_addr;
  60. };
  61. /**
  62. * struct tipc_bearer - TIPC bearer info available to privileged users
  63. * @usr_handle: pointer to additional user-defined information about bearer
  64. * @mtu: max packet size bearer can support
  65. * @blocked: non-zero if bearer is blocked
  66. * @lock: spinlock for controlling access to bearer
  67. * @addr: media-specific address associated with bearer
  68. * @name: bearer name (format = media:interface)
  69. *
  70. * Note: TIPC initializes "name" and "lock" fields; user is responsible for
  71. * initialization all other fields when a bearer is enabled.
  72. */
  73. struct tipc_bearer {
  74. void *usr_handle;
  75. u32 mtu;
  76. int blocked;
  77. spinlock_t lock;
  78. struct tipc_media_addr addr;
  79. char name[TIPC_MAX_BEARER_NAME];
  80. };
  81. int tipc_register_media(u32 media_type,
  82. char *media_name,
  83. int (*enable)(struct tipc_bearer *),
  84. void (*disable)(struct tipc_bearer *),
  85. int (*send_msg)(struct sk_buff *,
  86. struct tipc_bearer *,
  87. struct tipc_media_addr *),
  88. char *(*addr2str)(struct tipc_media_addr *a,
  89. char *str_buf,
  90. int str_size),
  91. struct tipc_media_addr *bcast_addr,
  92. const u32 bearer_priority,
  93. const u32 link_tolerance, /* [ms] */
  94. const u32 send_window_limit);
  95. void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr);
  96. int tipc_block_bearer(const char *name);
  97. void tipc_continue(struct tipc_bearer *tb_ptr);
  98. int tipc_enable_bearer(const char *bearer_name, u32 bcast_scope, u32 priority);
  99. int tipc_disable_bearer(const char *name);
  100. #endif
  101. #endif