Lines Matching defs:tvlv

31 #include "tvlv.h"
34 * batadv_tvlv_handler_release() - release tvlv handler from lists and queue for
36 * @ref: kref pointer of the tvlv
47 * batadv_tvlv_handler_put() - decrement the tvlv container refcounter and
49 * @tvlv_handler: the tvlv handler to free
60 * batadv_tvlv_handler_get() - retrieve tvlv handler from the tvlv handler list
63 * @type: tvlv handler type to look for
64 * @version: tvlv handler version to look for
66 * Return: tvlv handler if found or NULL otherwise.
75 &bat_priv->tvlv.handler_list, list) {
94 * batadv_tvlv_container_release() - release tvlv from lists and free
95 * @ref: kref pointer of the tvlv
99 struct batadv_tvlv_container *tvlv;
101 tvlv = container_of(ref, struct batadv_tvlv_container, refcount);
102 kfree(tvlv);
106 * batadv_tvlv_container_put() - decrement the tvlv container refcounter and
108 * @tvlv: the tvlv container to free
110 static void batadv_tvlv_container_put(struct batadv_tvlv_container *tvlv)
112 if (!tvlv)
115 kref_put(&tvlv->refcount, batadv_tvlv_container_release);
119 * batadv_tvlv_container_get() - retrieve tvlv container from the tvlv container
122 * @type: tvlv container type to look for
123 * @version: tvlv container version to look for
126 * (tvlv.container_list_lock).
128 * Return: tvlv container if found or NULL otherwise.
133 struct batadv_tvlv_container *tvlv_tmp, *tvlv = NULL;
135 lockdep_assert_held(&bat_priv->tvlv.container_list_lock);
137 hlist_for_each_entry(tvlv_tmp, &bat_priv->tvlv.container_list, list) {
145 tvlv = tvlv_tmp;
149 return tvlv;
153 * batadv_tvlv_container_list_size() - calculate the size of the tvlv container
158 * (tvlv.container_list_lock).
160 * Return: size of all currently registered tvlv containers in bytes.
164 struct batadv_tvlv_container *tvlv;
167 lockdep_assert_held(&bat_priv->tvlv.container_list_lock);
169 hlist_for_each_entry(tvlv, &bat_priv->tvlv.container_list, list) {
171 tvlv_len += ntohs(tvlv->tvlv_hdr.len);
178 * batadv_tvlv_container_remove() - remove tvlv container from the tvlv
181 * @tvlv: the to be removed tvlv container
184 * (tvlv.container_list_lock).
187 struct batadv_tvlv_container *tvlv)
189 lockdep_assert_held(&bat_priv->tvlv.container_list_lock);
191 if (!tvlv)
194 hlist_del(&tvlv->list);
197 batadv_tvlv_container_put(tvlv);
198 batadv_tvlv_container_put(tvlv);
202 * batadv_tvlv_container_unregister() - unregister tvlv container based on the
205 * @type: tvlv container type to unregister
206 * @version: tvlv container type to unregister
211 struct batadv_tvlv_container *tvlv;
213 spin_lock_bh(&bat_priv->tvlv.container_list_lock);
214 tvlv = batadv_tvlv_container_get(bat_priv, type, version);
215 batadv_tvlv_container_remove(bat_priv, tvlv);
216 spin_unlock_bh(&bat_priv->tvlv.container_list_lock);
220 * batadv_tvlv_container_register() - register tvlv type, version and content
223 * @type: tvlv container type
224 * @version: tvlv container version
225 * @tvlv_value: tvlv container content
226 * @tvlv_value_len: tvlv container content length
252 spin_lock_bh(&bat_priv->tvlv.container_list_lock);
257 hlist_add_head(&tvlv_new->list, &bat_priv->tvlv.container_list);
258 spin_unlock_bh(&bat_priv->tvlv.container_list_lock);
298 * batadv_tvlv_container_ogm_append() - append tvlv container content to given
302 * @packet_buff_len: ogm packet buffer size including ogm header and tvlv
307 * and the size of the to-be-appended tvlv containers.
309 * Return: size of all appended tvlv containers in bytes.
315 struct batadv_tvlv_container *tvlv;
321 spin_lock_bh(&bat_priv->tvlv.container_list_lock);
335 hlist_for_each_entry(tvlv, &bat_priv->tvlv.container_list, list) {
337 tvlv_hdr->type = tvlv->tvlv_hdr.type;
338 tvlv_hdr->version = tvlv->tvlv_hdr.version;
339 tvlv_hdr->len = tvlv->tvlv_hdr.len;
341 memcpy(tvlv_value, tvlv + 1, ntohs(tvlv->tvlv_hdr.len));
342 tvlv_value = (u8 *)tvlv_value + ntohs(tvlv->tvlv_hdr.len);
346 spin_unlock_bh(&bat_priv->tvlv.container_list_lock);
351 * batadv_tvlv_call_handler() - parse the given tvlv buffer to call the
354 * @tvlv_handler: tvlv callback function handling the tvlv content
355 * @ogm_source: flag indicating whether the tvlv is an ogm or a unicast packet
359 * @tvlv_value: tvlv content
360 * @tvlv_value_len: tvlv content length
405 * batadv_tvlv_containers_process() - parse the given tvlv buffer to call the
408 * @ogm_source: flag indicating whether the tvlv is an ogm or a unicast packet
412 * @tvlv_value: tvlv content
413 * @tvlv_value_len: tvlv content length
458 &bat_priv->tvlv.handler_list, list) {
475 * @batadv_ogm_packet: ogm packet containing the tvlv containers
499 * batadv_tvlv_handler_register() - register tvlv handler based on the provided
500 * type and version (both need to match) for ogm tvlv payload and/or unicast
503 * @optr: ogm tvlv handler callback function. This function receives the orig
504 * node, flags and the tvlv content as argument to process.
505 * @uptr: unicast tvlv handler callback function. This function receives the
506 * source & destination of the unicast packet as well as the tvlv content
508 * @type: tvlv handler type to be registered
509 * @version: tvlv handler version to be registered
526 spin_lock_bh(&bat_priv->tvlv.handler_list_lock);
530 spin_unlock_bh(&bat_priv->tvlv.handler_list_lock);
537 spin_unlock_bh(&bat_priv->tvlv.handler_list_lock);
550 hlist_add_head_rcu(&tvlv_handler->list, &bat_priv->tvlv.handler_list);
551 spin_unlock_bh(&bat_priv->tvlv.handler_list_lock);
558 * batadv_tvlv_handler_unregister() - unregister tvlv handler based on the
561 * @type: tvlv handler type to be unregistered
562 * @version: tvlv handler version to be unregistered
574 spin_lock_bh(&bat_priv->tvlv.handler_list_lock);
576 spin_unlock_bh(&bat_priv->tvlv.handler_list_lock);
581 * batadv_tvlv_unicast_send() - send a unicast packet with tvlv payload to the
586 * @type: tvlv type
587 * @version: tvlv version
588 * @tvlv_value: tvlv content
589 * @tvlv_value_len: tvlv content length