41 static int (*batadv_rx_handler[256])(
struct sk_buff *,
50 static void batadv_recv_handler_init(
void);
52 static int __init batadv_init(
void)
57 batadv_recv_handler_init();
63 if (!batadv_event_workqueue)
71 pr_info(
"B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n",
77 static void __exit batadv_exit(
void)
85 batadv_event_workqueue =
NULL;
92 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
108 INIT_LIST_HEAD(&bat_priv->
tt.changes_list);
109 INIT_LIST_HEAD(&bat_priv->
tt.req_list);
110 INIT_LIST_HEAD(&bat_priv->
tt.roam_list);
143 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
182 if (batadv_compare_eth(hard_iface->
net_dev->dev_addr, addr)) {
191 static int batadv_recv_unhandled_packet(
struct sk_buff *
skb,
219 if (
unlikely(!pskb_may_pull(skb, 2)))
229 bat_priv = netdev_priv(hard_iface->
soft_iface);
238 batadv_ogm_packet = (
struct batadv_ogm_packet *)skb->
data;
242 "Drop packet: incompatible batman version (%i)\n",
243 batadv_ogm_packet->
header.version);
250 idx = batadv_ogm_packet->
header.packet_type;
251 ret = (*batadv_rx_handler[
idx])(skb, hard_iface);
268 static void batadv_recv_handler_init(
void)
272 for (i = 0; i <
ARRAY_SIZE(batadv_rx_handler); i++)
273 batadv_rx_handler[i] = batadv_recv_unhandled_packet;
293 int (*recv_handler)(
struct sk_buff *,
296 if (batadv_rx_handler[packet_type] != &batadv_recv_unhandled_packet)
299 batadv_rx_handler[packet_type] = recv_handler;
305 batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet;
314 if (
strcmp(bat_algo_ops_tmp->name, name) != 0)
317 bat_algo_ops = bat_algo_ops_tmp;
329 bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->
name);
330 if (bat_algo_ops_tmp) {
331 pr_info(
"Trying to register already registered routing algorithm: %s\n",
344 pr_info(
"Routing algo '%s' does not implement required ops\n",
350 INIT_HLIST_NODE(&bat_algo_ops->
list);
351 hlist_add_head(&bat_algo_ops->
list, &batadv_algo_list);
363 bat_algo_ops = batadv_algo_get(name);
379 seq_printf(seq,
"Available routing algorithms:\n");
388 static int batadv_param_set_ra(
const char *
val,
const struct kernel_param *kp)
391 char *algo_name = (
char *)val;
394 if (algo_name[name_len - 1] ==
'\n')
395 algo_name[name_len - 1] =
'\0';
397 bat_algo_ops = batadv_algo_get(algo_name);
399 pr_err(
"Routing algorithm '%s' is not supported\n", algo_name);
407 .set = batadv_param_set_ra,
416 module_param_cb(routing_algo, &batadv_param_ops_ra, &batadv_param_string_ra,