0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #ifndef _TIPC_BEARER_H
0038 #define _TIPC_BEARER_H
0039
0040 #include "netlink.h"
0041 #include "core.h"
0042 #include "msg.h"
0043 #include <net/genetlink.h>
0044
0045 #define MAX_MEDIA 3
0046
0047
0048
0049
0050
0051
0052 #define TIPC_MEDIA_INFO_SIZE 32
0053 #define TIPC_MEDIA_TYPE_OFFSET 3
0054 #define TIPC_MEDIA_ADDR_OFFSET 4
0055
0056
0057
0058
0059 #define TIPC_MEDIA_TYPE_ETH 1
0060 #define TIPC_MEDIA_TYPE_IB 2
0061 #define TIPC_MEDIA_TYPE_UDP 3
0062
0063
0064 #define TIPC_MIN_BEARER_MTU (MAX_H_SIZE + INT_H_SIZE)
0065
0066
0067
0068 #define TIPC_BROADCAST_SUPPORT 1
0069 #define TIPC_REPLICAST_SUPPORT 2
0070
0071
0072
0073
0074
0075
0076
0077 struct tipc_media_addr {
0078 u8 value[TIPC_MEDIA_INFO_SIZE];
0079 u8 media_id;
0080 u8 broadcast;
0081 };
0082
0083 struct tipc_bearer;
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 struct tipc_media {
0105 int (*send_msg)(struct net *net, struct sk_buff *buf,
0106 struct tipc_bearer *b,
0107 struct tipc_media_addr *dest);
0108 int (*enable_media)(struct net *net, struct tipc_bearer *b,
0109 struct nlattr *attr[]);
0110 void (*disable_media)(struct tipc_bearer *b);
0111 int (*addr2str)(struct tipc_media_addr *addr,
0112 char *strbuf,
0113 int bufsz);
0114 int (*addr2msg)(char *msg, struct tipc_media_addr *addr);
0115 int (*msg2addr)(struct tipc_bearer *b,
0116 struct tipc_media_addr *addr,
0117 char *msg);
0118 int (*raw2addr)(struct tipc_bearer *b,
0119 struct tipc_media_addr *addr,
0120 const char *raw);
0121 u32 priority;
0122 u32 tolerance;
0123 u32 min_win;
0124 u32 max_win;
0125 u32 mtu;
0126 u32 type_id;
0127 u32 hwaddr_len;
0128 char name[TIPC_MAX_MEDIA_NAME];
0129 };
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156 struct tipc_bearer {
0157 void __rcu *media_ptr;
0158 u32 mtu;
0159 struct tipc_media_addr addr;
0160 char name[TIPC_MAX_BEARER_NAME];
0161 struct tipc_media *media;
0162 struct tipc_media_addr bcast_addr;
0163 struct packet_type pt;
0164 struct rcu_head rcu;
0165 u32 priority;
0166 u32 min_win;
0167 u32 max_win;
0168 u32 tolerance;
0169 u32 domain;
0170 u32 identity;
0171 struct tipc_discoverer *disc;
0172 char net_plane;
0173 unsigned long up;
0174 refcount_t refcnt;
0175 };
0176
0177 struct tipc_bearer_names {
0178 char media_name[TIPC_MAX_MEDIA_NAME];
0179 char if_name[TIPC_MAX_IF_NAME];
0180 };
0181
0182
0183
0184
0185
0186 void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b);
0187
0188
0189
0190
0191 extern struct tipc_media eth_media_info;
0192
0193 #ifdef CONFIG_TIPC_MEDIA_IB
0194 extern struct tipc_media ib_media_info;
0195 #endif
0196 #ifdef CONFIG_TIPC_MEDIA_UDP
0197 extern struct tipc_media udp_media_info;
0198 #endif
0199
0200 int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info);
0201 int __tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info);
0202 int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info);
0203 int __tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info);
0204 int tipc_nl_bearer_dump(struct sk_buff *skb, struct netlink_callback *cb);
0205 int tipc_nl_bearer_get(struct sk_buff *skb, struct genl_info *info);
0206 int tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info);
0207 int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info);
0208 int tipc_nl_bearer_add(struct sk_buff *skb, struct genl_info *info);
0209
0210 int tipc_nl_media_dump(struct sk_buff *skb, struct netlink_callback *cb);
0211 int tipc_nl_media_get(struct sk_buff *skb, struct genl_info *info);
0212 int tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info);
0213 int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info);
0214
0215 int tipc_media_set_priority(const char *name, u32 new_value);
0216 int tipc_media_set_window(const char *name, u32 new_value);
0217 int tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a);
0218 int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
0219 struct nlattr *attrs[]);
0220 bool tipc_bearer_hold(struct tipc_bearer *b);
0221 void tipc_bearer_put(struct tipc_bearer *b);
0222 void tipc_disable_l2_media(struct tipc_bearer *b);
0223 int tipc_l2_send_msg(struct net *net, struct sk_buff *buf,
0224 struct tipc_bearer *b, struct tipc_media_addr *dest);
0225
0226 void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest);
0227 void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest);
0228 struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name);
0229 int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id);
0230 struct tipc_media *tipc_media_find(const char *name);
0231 int tipc_bearer_setup(void);
0232 void tipc_bearer_cleanup(void);
0233 void tipc_bearer_stop(struct net *net);
0234 int tipc_bearer_mtu(struct net *net, u32 bearer_id);
0235 bool tipc_bearer_bcast_support(struct net *net, u32 bearer_id);
0236 void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id,
0237 struct sk_buff *skb,
0238 struct tipc_media_addr *dest);
0239 void tipc_bearer_xmit(struct net *net, u32 bearer_id,
0240 struct sk_buff_head *xmitq,
0241 struct tipc_media_addr *dst,
0242 struct tipc_node *__dnode);
0243 void tipc_bearer_bc_xmit(struct net *net, u32 bearer_id,
0244 struct sk_buff_head *xmitq);
0245 void tipc_clone_to_loopback(struct net *net, struct sk_buff_head *pkts);
0246 int tipc_attach_loopback(struct net *net);
0247 void tipc_detach_loopback(struct net *net);
0248
0249 static inline void tipc_loopback_trace(struct net *net,
0250 struct sk_buff_head *pkts)
0251 {
0252 if (unlikely(dev_nit_active(net->loopback_dev)))
0253 tipc_clone_to_loopback(net, pkts);
0254 }
0255
0256
0257 static inline bool tipc_mtu_bad(struct net_device *dev, unsigned int reserve)
0258 {
0259 if (dev->mtu >= TIPC_MIN_BEARER_MTU + reserve)
0260 return false;
0261 netdev_warn(dev, "MTU too low for tipc bearer\n");
0262 return true;
0263 }
0264
0265 #endif