blob: df7b9145a59941099284c768af029d84b90fa482 [file] [log] [blame]
Per Lidenb97bf3f2006-01-02 19:04:38 +01001/*
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
34#ifndef _NET_TIPC_BEARER_H_
35#define _NET_TIPC_BEARER_H_
36
37#ifdef __KERNEL__
38
Per Lidenea714cc2006-01-11 12:28:47 +010039#include <linux/tipc_config.h>
Per Lidenb97bf3f2006-01-02 19:04:38 +010040#include <linux/skbuff.h>
41#include <linux/spinlock.h>
42
Per Lidenea714cc2006-01-11 12:28:47 +010043/*
44 * Identifiers of supported TIPC media types
45 */
46
47#define TIPC_MEDIA_TYPE_ETH 1
48
49struct tipc_media_addr {
50 __u32 type;
51 union {
52 __u8 eth_addr[6]; /* Ethernet bearer */
53#if 0
54 /* Prototypes for other possible bearer types */
55
56 struct {
57 __u16 sin_family;
58 __u16 sin_port;
59 struct {
60 __u32 s_addr;
61 } sin_addr;
62 char pad[4];
63 } addr_in; /* IP-based bearer */
64 __u16 sock_descr; /* generic socket bearer */
65#endif
66 } dev_addr;
67};
68
Per Lidenb97bf3f2006-01-02 19:04:38 +010069/**
70 * struct tipc_bearer - TIPC bearer info available to privileged users
71 * @usr_handle: pointer to additional user-defined information about bearer
72 * @mtu: max packet size bearer can support
73 * @blocked: non-zero if bearer is blocked
74 * @lock: spinlock for controlling access to bearer
75 * @addr: media-specific address associated with bearer
76 * @name: bearer name (format = media:interface)
77 *
78 * Note: TIPC initializes "name" and "lock" fields; user is responsible for
79 * initialization all other fields when a bearer is enabled.
80 */
81
82struct tipc_bearer {
83 void *usr_handle;
84 u32 mtu;
85 int blocked;
86 spinlock_t lock;
87 struct tipc_media_addr addr;
88 char name[TIPC_MAX_BEARER_NAME];
89};
90
91
92int tipc_register_media(u32 media_type,
93 char *media_name,
94 int (*enable)(struct tipc_bearer *),
95 void (*disable)(struct tipc_bearer *),
96 int (*send_msg)(struct sk_buff *,
97 struct tipc_bearer *,
98 struct tipc_media_addr *),
99 char *(*addr2str)(struct tipc_media_addr *a,
100 char *str_buf,
101 int str_size),
102 struct tipc_media_addr *bcast_addr,
103 const u32 bearer_priority,
104 const u32 link_tolerance, /* [ms] */
105 const u32 send_window_limit);
106
107void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr);
108
109int tipc_block_bearer(const char *name);
110void tipc_continue(struct tipc_bearer *tb_ptr);
111
112int tipc_enable_bearer(const char *bearer_name, u32 bcast_scope, u32 priority);
113int tipc_disable_bearer(const char *name);
114
115
116#endif
117
118#endif