0001
0002
0003
0004
0005
0006
0007 #ifndef _NET_BATMAN_ADV_ORIGINATOR_H_
0008 #define _NET_BATMAN_ADV_ORIGINATOR_H_
0009
0010 #include "main.h"
0011
0012 #include <linux/compiler.h>
0013 #include <linux/if_ether.h>
0014 #include <linux/jhash.h>
0015 #include <linux/kref.h>
0016 #include <linux/netlink.h>
0017 #include <linux/skbuff.h>
0018 #include <linux/types.h>
0019
0020 bool batadv_compare_orig(const struct hlist_node *node, const void *data2);
0021 int batadv_originator_init(struct batadv_priv *bat_priv);
0022 void batadv_originator_free(struct batadv_priv *bat_priv);
0023 void batadv_purge_orig_ref(struct batadv_priv *bat_priv);
0024 void batadv_orig_node_release(struct kref *ref);
0025 struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
0026 const u8 *addr);
0027 struct batadv_hardif_neigh_node *
0028 batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
0029 const u8 *neigh_addr);
0030 void batadv_hardif_neigh_release(struct kref *ref);
0031 struct batadv_neigh_node *
0032 batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node,
0033 struct batadv_hard_iface *hard_iface,
0034 const u8 *neigh_addr);
0035 void batadv_neigh_node_release(struct kref *ref);
0036 struct batadv_neigh_node *
0037 batadv_orig_router_get(struct batadv_orig_node *orig_node,
0038 const struct batadv_hard_iface *if_outgoing);
0039 struct batadv_neigh_ifinfo *
0040 batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
0041 struct batadv_hard_iface *if_outgoing);
0042 struct batadv_neigh_ifinfo *
0043 batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh,
0044 struct batadv_hard_iface *if_outgoing);
0045 void batadv_neigh_ifinfo_release(struct kref *ref);
0046
0047 int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb);
0048
0049 struct batadv_orig_ifinfo *
0050 batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node,
0051 struct batadv_hard_iface *if_outgoing);
0052 struct batadv_orig_ifinfo *
0053 batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
0054 struct batadv_hard_iface *if_outgoing);
0055 void batadv_orig_ifinfo_release(struct kref *ref);
0056
0057 int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb);
0058 struct batadv_orig_node_vlan *
0059 batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
0060 unsigned short vid);
0061 struct batadv_orig_node_vlan *
0062 batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
0063 unsigned short vid);
0064 void batadv_orig_node_vlan_release(struct kref *ref);
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 static inline u32 batadv_choose_orig(const void *data, u32 size)
0075 {
0076 u32 hash = 0;
0077
0078 hash = jhash(data, ETH_ALEN, hash);
0079 return hash % size;
0080 }
0081
0082 struct batadv_orig_node *
0083 batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data);
0084
0085
0086
0087
0088
0089
0090 static inline void
0091 batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan)
0092 {
0093 if (!orig_vlan)
0094 return;
0095
0096 kref_put(&orig_vlan->refcount, batadv_orig_node_vlan_release);
0097 }
0098
0099
0100
0101
0102
0103
0104 static inline void
0105 batadv_neigh_ifinfo_put(struct batadv_neigh_ifinfo *neigh_ifinfo)
0106 {
0107 if (!neigh_ifinfo)
0108 return;
0109
0110 kref_put(&neigh_ifinfo->refcount, batadv_neigh_ifinfo_release);
0111 }
0112
0113
0114
0115
0116
0117
0118 static inline void
0119 batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh)
0120 {
0121 if (!hardif_neigh)
0122 return;
0123
0124 kref_put(&hardif_neigh->refcount, batadv_hardif_neigh_release);
0125 }
0126
0127
0128
0129
0130
0131
0132 static inline void batadv_neigh_node_put(struct batadv_neigh_node *neigh_node)
0133 {
0134 if (!neigh_node)
0135 return;
0136
0137 kref_put(&neigh_node->refcount, batadv_neigh_node_release);
0138 }
0139
0140
0141
0142
0143
0144
0145 static inline void
0146 batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo)
0147 {
0148 if (!orig_ifinfo)
0149 return;
0150
0151 kref_put(&orig_ifinfo->refcount, batadv_orig_ifinfo_release);
0152 }
0153
0154
0155
0156
0157
0158
0159 static inline void batadv_orig_node_put(struct batadv_orig_node *orig_node)
0160 {
0161 if (!orig_node)
0162 return;
0163
0164 kref_put(&orig_node->refcount, batadv_orig_node_release);
0165 }
0166
0167 #endif