Lines Matching +full:packet +full:- +full:based
1 // SPDX-License-Identifier: GPL-2.0
34 * batadv_tvlv_handler_release() - release tvlv handler from lists and queue for
47 * batadv_tvlv_handler_put() - decrement the tvlv container refcounter and
56 kref_put(&tvlv_handler->refcount, batadv_tvlv_handler_release); in batadv_tvlv_handler_put()
60 * batadv_tvlv_handler_get() - retrieve tvlv handler from the tvlv handler list
61 * based on the provided type and version (both need to match)
75 &bat_priv->tvlv.handler_list, list) { in batadv_tvlv_handler_get()
76 if (tvlv_handler_tmp->type != type) in batadv_tvlv_handler_get()
79 if (tvlv_handler_tmp->version != version) in batadv_tvlv_handler_get()
82 if (!kref_get_unless_zero(&tvlv_handler_tmp->refcount)) in batadv_tvlv_handler_get()
94 * batadv_tvlv_container_release() - release tvlv from lists and free
106 * batadv_tvlv_container_put() - decrement the tvlv container refcounter and
115 kref_put(&tvlv->refcount, batadv_tvlv_container_release); in batadv_tvlv_container_put()
119 * batadv_tvlv_container_get() - retrieve tvlv container from the tvlv container
120 * list based on the provided type and version (both need to match)
135 lockdep_assert_held(&bat_priv->tvlv.container_list_lock); in batadv_tvlv_container_get()
137 hlist_for_each_entry(tvlv_tmp, &bat_priv->tvlv.container_list, list) { in batadv_tvlv_container_get()
138 if (tvlv_tmp->tvlv_hdr.type != type) in batadv_tvlv_container_get()
141 if (tvlv_tmp->tvlv_hdr.version != version) in batadv_tvlv_container_get()
144 kref_get(&tvlv_tmp->refcount); in batadv_tvlv_container_get()
153 * batadv_tvlv_container_list_size() - calculate the size of the tvlv container
167 lockdep_assert_held(&bat_priv->tvlv.container_list_lock); in batadv_tvlv_container_list_size()
169 hlist_for_each_entry(tvlv, &bat_priv->tvlv.container_list, list) { in batadv_tvlv_container_list_size()
171 tvlv_len += ntohs(tvlv->tvlv_hdr.len); in batadv_tvlv_container_list_size()
178 * batadv_tvlv_container_remove() - remove tvlv container from the tvlv
189 lockdep_assert_held(&bat_priv->tvlv.container_list_lock); in batadv_tvlv_container_remove()
194 hlist_del(&tvlv->list); in batadv_tvlv_container_remove()
202 * batadv_tvlv_container_unregister() - unregister tvlv container based on the
213 spin_lock_bh(&bat_priv->tvlv.container_list_lock); in batadv_tvlv_container_unregister()
216 spin_unlock_bh(&bat_priv->tvlv.container_list_lock); in batadv_tvlv_container_unregister()
220 * batadv_tvlv_container_register() - register tvlv type, version and content
244 tvlv_new->tvlv_hdr.version = version; in batadv_tvlv_container_register()
245 tvlv_new->tvlv_hdr.type = type; in batadv_tvlv_container_register()
246 tvlv_new->tvlv_hdr.len = htons(tvlv_value_len); in batadv_tvlv_container_register()
248 memcpy(tvlv_new + 1, tvlv_value, ntohs(tvlv_new->tvlv_hdr.len)); in batadv_tvlv_container_register()
249 INIT_HLIST_NODE(&tvlv_new->list); in batadv_tvlv_container_register()
250 kref_init(&tvlv_new->refcount); in batadv_tvlv_container_register()
252 spin_lock_bh(&bat_priv->tvlv.container_list_lock); in batadv_tvlv_container_register()
256 kref_get(&tvlv_new->refcount); in batadv_tvlv_container_register()
257 hlist_add_head(&tvlv_new->list, &bat_priv->tvlv.container_list); in batadv_tvlv_container_register()
258 spin_unlock_bh(&bat_priv->tvlv.container_list_lock); in batadv_tvlv_container_register()
265 * batadv_tvlv_realloc_packet_buff() - reallocate packet buffer to accommodate
266 * requested packet size
267 * @packet_buff: packet buffer
268 * @packet_buff_len: packet buffer size
269 * @min_packet_len: requested packet minimum size
270 * @additional_packet_len: requested additional packet size on top of minimum
273 * Return: true of the packet buffer could be changed to the requested size,
298 * batadv_tvlv_container_ogm_append() - append tvlv container content to given
299 * OGM packet buffer
301 * @packet_buff: ogm packet buffer
302 * @packet_buff_len: ogm packet buffer size including ogm header and tvlv
306 * The ogm packet might be enlarged or shrunk depending on the current size
307 * and the size of the to-be-appended tvlv containers.
321 spin_lock_bh(&bat_priv->tvlv.container_list_lock); in batadv_tvlv_container_ogm_append()
335 hlist_for_each_entry(tvlv, &bat_priv->tvlv.container_list, list) { in batadv_tvlv_container_ogm_append()
337 tvlv_hdr->type = tvlv->tvlv_hdr.type; in batadv_tvlv_container_ogm_append()
338 tvlv_hdr->version = tvlv->tvlv_hdr.version; in batadv_tvlv_container_ogm_append()
339 tvlv_hdr->len = tvlv->tvlv_hdr.len; in batadv_tvlv_container_ogm_append()
341 memcpy(tvlv_value, tvlv + 1, ntohs(tvlv->tvlv_hdr.len)); in batadv_tvlv_container_ogm_append()
342 tvlv_value = (u8 *)tvlv_value + ntohs(tvlv->tvlv_hdr.len); in batadv_tvlv_container_ogm_append()
346 spin_unlock_bh(&bat_priv->tvlv.container_list_lock); in batadv_tvlv_container_ogm_append()
351 * batadv_tvlv_call_handler() - parse the given tvlv buffer to call the
355 * @packet_type: indicates for which packet type the TVLV handler is called
356 * @orig_node: orig node emitting the ogm packet
380 if (!tvlv_handler->ogm_handler) in batadv_tvlv_call_handler()
386 tvlv_handler->ogm_handler(bat_priv, orig_node, in batadv_tvlv_call_handler()
389 tvlv_handler->flags |= BATADV_TVLV_HANDLER_OGM_CALLED; in batadv_tvlv_call_handler()
395 if (!tvlv_handler->unicast_handler) in batadv_tvlv_call_handler()
398 src = ((struct batadv_unicast_tvlv_packet *)skb->data)->src; in batadv_tvlv_call_handler()
399 dst = ((struct batadv_unicast_tvlv_packet *)skb->data)->dst; in batadv_tvlv_call_handler()
401 return tvlv_handler->unicast_handler(bat_priv, src, in batadv_tvlv_call_handler()
408 if (!tvlv_handler->mcast_handler) in batadv_tvlv_call_handler()
411 tvlv_offset = (unsigned char *)tvlv_value - skb->data; in batadv_tvlv_call_handler()
415 return tvlv_handler->mcast_handler(bat_priv, skb); in batadv_tvlv_call_handler()
422 * batadv_tvlv_containers_process() - parse the given tvlv buffer to call the
425 * @packet_type: indicates for which packet type the TVLV handler is called
426 * @orig_node: orig node emitting the ogm packet
448 tvlv_value_cont_len = ntohs(tvlv_hdr->len); in batadv_tvlv_containers_process()
450 tvlv_value_len -= sizeof(*tvlv_hdr); in batadv_tvlv_containers_process()
456 tvlv_hdr->type, in batadv_tvlv_containers_process()
457 tvlv_hdr->version); in batadv_tvlv_containers_process()
465 tvlv_value_len -= tvlv_value_cont_len; in batadv_tvlv_containers_process()
474 &bat_priv->tvlv.handler_list, list) { in batadv_tvlv_containers_process()
475 if (!tvlv_handler->ogm_handler) in batadv_tvlv_containers_process()
478 if ((tvlv_handler->flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND) && in batadv_tvlv_containers_process()
479 !(tvlv_handler->flags & BATADV_TVLV_HANDLER_OGM_CALLED)) in batadv_tvlv_containers_process()
480 tvlv_handler->ogm_handler(bat_priv, orig_node, in batadv_tvlv_containers_process()
483 tvlv_handler->flags &= ~BATADV_TVLV_HANDLER_OGM_CALLED; in batadv_tvlv_containers_process()
491 * batadv_tvlv_ogm_receive() - process an incoming ogm and call the appropriate
494 * @batadv_ogm_packet: ogm packet containing the tvlv containers
495 * @orig_node: orig node emitting the ogm packet
507 tvlv_value_len = ntohs(batadv_ogm_packet->tvlv_len); in batadv_tvlv_ogm_receive()
518 * batadv_tvlv_handler_register() - register tvlv handler based on the provided
525 * source & destination of the unicast packet as well as the tvlv content
527 * @mptr: multicast packet tvlv handler callback function. This function
551 spin_lock_bh(&bat_priv->tvlv.handler_list_lock); in batadv_tvlv_handler_register()
555 spin_unlock_bh(&bat_priv->tvlv.handler_list_lock); in batadv_tvlv_handler_register()
562 spin_unlock_bh(&bat_priv->tvlv.handler_list_lock); in batadv_tvlv_handler_register()
566 tvlv_handler->ogm_handler = optr; in batadv_tvlv_handler_register()
567 tvlv_handler->unicast_handler = uptr; in batadv_tvlv_handler_register()
568 tvlv_handler->mcast_handler = mptr; in batadv_tvlv_handler_register()
569 tvlv_handler->type = type; in batadv_tvlv_handler_register()
570 tvlv_handler->version = version; in batadv_tvlv_handler_register()
571 tvlv_handler->flags = flags; in batadv_tvlv_handler_register()
572 kref_init(&tvlv_handler->refcount); in batadv_tvlv_handler_register()
573 INIT_HLIST_NODE(&tvlv_handler->list); in batadv_tvlv_handler_register()
575 kref_get(&tvlv_handler->refcount); in batadv_tvlv_handler_register()
576 hlist_add_head_rcu(&tvlv_handler->list, &bat_priv->tvlv.handler_list); in batadv_tvlv_handler_register()
577 spin_unlock_bh(&bat_priv->tvlv.handler_list_lock); in batadv_tvlv_handler_register()
584 * batadv_tvlv_handler_unregister() - unregister tvlv handler based on the
600 spin_lock_bh(&bat_priv->tvlv.handler_list_lock); in batadv_tvlv_handler_unregister()
601 hlist_del_rcu(&tvlv_handler->list); in batadv_tvlv_handler_unregister()
602 spin_unlock_bh(&bat_priv->tvlv.handler_list_lock); in batadv_tvlv_handler_unregister()
607 * batadv_tvlv_unicast_send() - send a unicast packet with tvlv payload to the
610 * @src: source mac address of the unicast packet
611 * @dst: destination mac address of the unicast packet
639 skb->priority = TC_PRIO_CONTROL; in batadv_tvlv_unicast_send()
643 unicast_tvlv_packet->packet_type = BATADV_UNICAST_TVLV; in batadv_tvlv_unicast_send()
644 unicast_tvlv_packet->version = BATADV_COMPAT_VERSION; in batadv_tvlv_unicast_send()
645 unicast_tvlv_packet->ttl = BATADV_TTL; in batadv_tvlv_unicast_send()
646 unicast_tvlv_packet->reserved = 0; in batadv_tvlv_unicast_send()
647 unicast_tvlv_packet->tvlv_len = htons(tvlv_len); in batadv_tvlv_unicast_send()
648 unicast_tvlv_packet->align = 0; in batadv_tvlv_unicast_send()
649 ether_addr_copy(unicast_tvlv_packet->src, src); in batadv_tvlv_unicast_send()
650 ether_addr_copy(unicast_tvlv_packet->dst, dst); in batadv_tvlv_unicast_send()
654 tvlv_hdr->version = version; in batadv_tvlv_unicast_send()
655 tvlv_hdr->type = type; in batadv_tvlv_unicast_send()
656 tvlv_hdr->len = htons(tvlv_value_len); in batadv_tvlv_unicast_send()