diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2013-04-23 09:40:00 -0400 |
---|---|---|
committer | Antonio Quartulli <antonio@meshcoding.com> | 2013-10-09 15:22:28 -0400 |
commit | 3f4841ffb336075f74b05fe4a205e877bb22848d (patch) | |
tree | bcf704a6cc178d4fa9ceb5a7f5cfe5d24868564a | |
parent | 17cf0ea455f1a4a7e8436ef96236999e9c452a93 (diff) |
batman-adv: tvlv - add network coding container
Create network coding container to announce network coding
capabilities (if enabled).
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
-rw-r--r-- | net/batman-adv/network-coding.c | 63 | ||||
-rw-r--r-- | net/batman-adv/network-coding.h | 5 | ||||
-rw-r--r-- | net/batman-adv/packet.h | 2 | ||||
-rw-r--r-- | net/batman-adv/sysfs.c | 4 | ||||
-rw-r--r-- | net/batman-adv/types.h | 2 |
5 files changed, 75 insertions, 1 deletions
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 4ecc0b6bf8ab..23f611bedb0f 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c | |||
@@ -59,6 +59,59 @@ static void batadv_nc_start_timer(struct batadv_priv *bat_priv) | |||
59 | } | 59 | } |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * batadv_nc_tvlv_container_update - update the network coding tvlv container | ||
63 | * after network coding setting change | ||
64 | * @bat_priv: the bat priv with all the soft interface information | ||
65 | */ | ||
66 | static void batadv_nc_tvlv_container_update(struct batadv_priv *bat_priv) | ||
67 | { | ||
68 | char nc_mode; | ||
69 | |||
70 | nc_mode = atomic_read(&bat_priv->network_coding); | ||
71 | |||
72 | switch (nc_mode) { | ||
73 | case 0: | ||
74 | batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_NC, 1); | ||
75 | break; | ||
76 | case 1: | ||
77 | batadv_tvlv_container_register(bat_priv, BATADV_TVLV_NC, 1, | ||
78 | NULL, 0); | ||
79 | break; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | /** | ||
84 | * batadv_nc_status_update - update the network coding tvlv container after | ||
85 | * network coding setting change | ||
86 | * @net_dev: the soft interface net device | ||
87 | */ | ||
88 | void batadv_nc_status_update(struct net_device *net_dev) | ||
89 | { | ||
90 | struct batadv_priv *bat_priv = netdev_priv(net_dev); | ||
91 | batadv_nc_tvlv_container_update(bat_priv); | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * batadv_nc_tvlv_ogm_handler_v1 - process incoming nc tvlv container | ||
96 | * @bat_priv: the bat priv with all the soft interface information | ||
97 | * @orig: the orig_node of the ogm | ||
98 | * @flags: flags indicating the tvlv state (see batadv_tvlv_handler_flags) | ||
99 | * @tvlv_value: tvlv buffer containing the gateway data | ||
100 | * @tvlv_value_len: tvlv buffer length | ||
101 | */ | ||
102 | static void batadv_nc_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, | ||
103 | struct batadv_orig_node *orig, | ||
104 | uint8_t flags, | ||
105 | void *tvlv_value, | ||
106 | uint16_t tvlv_value_len) | ||
107 | { | ||
108 | if (flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND) | ||
109 | orig->capabilities &= ~BATADV_ORIG_CAPA_HAS_NC; | ||
110 | else | ||
111 | orig->capabilities |= BATADV_ORIG_CAPA_HAS_NC; | ||
112 | } | ||
113 | |||
114 | /** | ||
62 | * batadv_nc_mesh_init - initialise coding hash table and start house keeping | 115 | * batadv_nc_mesh_init - initialise coding hash table and start house keeping |
63 | * @bat_priv: the bat priv with all the soft interface information | 116 | * @bat_priv: the bat priv with all the soft interface information |
64 | */ | 117 | */ |
@@ -87,6 +140,10 @@ int batadv_nc_mesh_init(struct batadv_priv *bat_priv) | |||
87 | INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker); | 140 | INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker); |
88 | batadv_nc_start_timer(bat_priv); | 141 | batadv_nc_start_timer(bat_priv); |
89 | 142 | ||
143 | batadv_tvlv_handler_register(bat_priv, batadv_nc_tvlv_ogm_handler_v1, | ||
144 | NULL, BATADV_TVLV_NC, 1, | ||
145 | BATADV_TVLV_HANDLER_OGM_CIFNOTFND); | ||
146 | batadv_nc_tvlv_container_update(bat_priv); | ||
90 | return 0; | 147 | return 0; |
91 | 148 | ||
92 | err: | 149 | err: |
@@ -802,6 +859,10 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv, | |||
802 | if (!atomic_read(&bat_priv->network_coding)) | 859 | if (!atomic_read(&bat_priv->network_coding)) |
803 | goto out; | 860 | goto out; |
804 | 861 | ||
862 | /* check if orig node is network coding enabled */ | ||
863 | if (!(orig_node->capabilities & BATADV_ORIG_CAPA_HAS_NC)) | ||
864 | goto out; | ||
865 | |||
805 | /* accept ogms from 'good' neighbors and single hop neighbors */ | 866 | /* accept ogms from 'good' neighbors and single hop neighbors */ |
806 | if (!batadv_can_nc_with_orig(bat_priv, orig_node, ogm_packet) && | 867 | if (!batadv_can_nc_with_orig(bat_priv, orig_node, ogm_packet) && |
807 | !is_single_hop_neigh) | 868 | !is_single_hop_neigh) |
@@ -1735,6 +1796,8 @@ free_nc_packet: | |||
1735 | */ | 1796 | */ |
1736 | void batadv_nc_mesh_free(struct batadv_priv *bat_priv) | 1797 | void batadv_nc_mesh_free(struct batadv_priv *bat_priv) |
1737 | { | 1798 | { |
1799 | batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_NC, 1); | ||
1800 | batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_NC, 1); | ||
1738 | cancel_delayed_work_sync(&bat_priv->nc.work); | 1801 | cancel_delayed_work_sync(&bat_priv->nc.work); |
1739 | 1802 | ||
1740 | batadv_nc_purge_paths(bat_priv, bat_priv->nc.coding_hash, NULL); | 1803 | batadv_nc_purge_paths(bat_priv, bat_priv->nc.coding_hash, NULL); |
diff --git a/net/batman-adv/network-coding.h b/net/batman-adv/network-coding.h index ddfa618e80bf..d4fd315b5261 100644 --- a/net/batman-adv/network-coding.h +++ b/net/batman-adv/network-coding.h | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #ifdef CONFIG_BATMAN_ADV_NC | 23 | #ifdef CONFIG_BATMAN_ADV_NC |
24 | 24 | ||
25 | void batadv_nc_status_update(struct net_device *net_dev); | ||
25 | int batadv_nc_init(void); | 26 | int batadv_nc_init(void); |
26 | int batadv_nc_mesh_init(struct batadv_priv *bat_priv); | 27 | int batadv_nc_mesh_init(struct batadv_priv *bat_priv); |
27 | void batadv_nc_mesh_free(struct batadv_priv *bat_priv); | 28 | void batadv_nc_mesh_free(struct batadv_priv *bat_priv); |
@@ -47,6 +48,10 @@ int batadv_nc_init_debugfs(struct batadv_priv *bat_priv); | |||
47 | 48 | ||
48 | #else /* ifdef CONFIG_BATMAN_ADV_NC */ | 49 | #else /* ifdef CONFIG_BATMAN_ADV_NC */ |
49 | 50 | ||
51 | static inline void batadv_nc_status_update(struct net_device *net_dev) | ||
52 | { | ||
53 | } | ||
54 | |||
50 | static inline int batadv_nc_init(void) | 55 | static inline int batadv_nc_init(void) |
51 | { | 56 | { |
52 | return 0; | 57 | return 0; |
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index 8d470b2696ac..55deb4dea842 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h | |||
@@ -122,10 +122,12 @@ enum batadv_bla_claimframe { | |||
122 | * enum batadv_tvlv_type - tvlv type definitions | 122 | * enum batadv_tvlv_type - tvlv type definitions |
123 | * @BATADV_TVLV_GW: gateway tvlv | 123 | * @BATADV_TVLV_GW: gateway tvlv |
124 | * @BATADV_TVLV_DAT: distributed arp table tvlv | 124 | * @BATADV_TVLV_DAT: distributed arp table tvlv |
125 | * @BATADV_TVLV_NC: network coding tvlv | ||
125 | */ | 126 | */ |
126 | enum batadv_tvlv_type { | 127 | enum batadv_tvlv_type { |
127 | BATADV_TVLV_GW = 0x01, | 128 | BATADV_TVLV_GW = 0x01, |
128 | BATADV_TVLV_DAT = 0x02, | 129 | BATADV_TVLV_DAT = 0x02, |
130 | BATADV_TVLV_NC = 0x03, | ||
129 | }; | 131 | }; |
130 | 132 | ||
131 | /* the destination hardware field in the ARP frame is used to | 133 | /* the destination hardware field in the ARP frame is used to |
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index e1a826e43210..fbc1c251711d 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "sysfs.h" | 21 | #include "sysfs.h" |
22 | #include "translation-table.h" | 22 | #include "translation-table.h" |
23 | #include "distributed-arp-table.h" | 23 | #include "distributed-arp-table.h" |
24 | #include "network-coding.h" | ||
24 | #include "originator.h" | 25 | #include "originator.h" |
25 | #include "hard-interface.h" | 26 | #include "hard-interface.h" |
26 | #include "gateway_common.h" | 27 | #include "gateway_common.h" |
@@ -447,7 +448,8 @@ static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, | |||
447 | BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, BATADV_DBG_ALL, NULL); | 448 | BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, BATADV_DBG_ALL, NULL); |
448 | #endif | 449 | #endif |
449 | #ifdef CONFIG_BATMAN_ADV_NC | 450 | #ifdef CONFIG_BATMAN_ADV_NC |
450 | BATADV_ATTR_SIF_BOOL(network_coding, S_IRUGO | S_IWUSR, NULL); | 451 | BATADV_ATTR_SIF_BOOL(network_coding, S_IRUGO | S_IWUSR, |
452 | batadv_nc_status_update); | ||
451 | #endif | 453 | #endif |
452 | 454 | ||
453 | static struct batadv_attribute *batadv_mesh_attrs[] = { | 455 | static struct batadv_attribute *batadv_mesh_attrs[] = { |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 35ce83480685..fa5cb0d99ed5 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
@@ -188,9 +188,11 @@ struct batadv_orig_node { | |||
188 | /** | 188 | /** |
189 | * enum batadv_orig_capabilities - orig node capabilities | 189 | * enum batadv_orig_capabilities - orig node capabilities |
190 | * @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table enabled | 190 | * @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table enabled |
191 | * @BATADV_ORIG_CAPA_HAS_NC: orig node has network coding enabled | ||
191 | */ | 192 | */ |
192 | enum batadv_orig_capabilities { | 193 | enum batadv_orig_capabilities { |
193 | BATADV_ORIG_CAPA_HAS_DAT = BIT(0), | 194 | BATADV_ORIG_CAPA_HAS_DAT = BIT(0), |
195 | BATADV_ORIG_CAPA_HAS_NC = BIT(1), | ||
194 | }; | 196 | }; |
195 | 197 | ||
196 | /** | 198 | /** |