From b83430aa625a1d42f11f9badf5e5cfbb8efacd99 Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Wed, 3 Jul 2019 15:08:23 +0200 Subject: [PATCH] gnrc_pktbuf: remove gnrc_pktbuf_duplicate_upto The removal of this function was already announced for the 2019.04 release. So it is safe to remove it. --- sys/include/net/gnrc/pktbuf.h | 55 ------------------- .../gnrc/pktbuf_malloc/gnrc_pktbuf_malloc.c | 50 ----------------- .../gnrc/pktbuf_static/gnrc_pktbuf_static.c | 51 ----------------- 3 files changed, 156 deletions(-) diff --git a/sys/include/net/gnrc/pktbuf.h b/sys/include/net/gnrc/pktbuf.h index cc60001c9dad..ca825aeae0c3 100644 --- a/sys/include/net/gnrc/pktbuf.h +++ b/sys/include/net/gnrc/pktbuf.h @@ -229,61 +229,6 @@ gnrc_pktsnip_t *gnrc_pktbuf_replace_snip(gnrc_pktsnip_t *pkt, gnrc_pktsnip_t *ol */ gnrc_pktsnip_t *gnrc_pktbuf_reverse_snips(gnrc_pktsnip_t *pkt); -/** - * @brief Duplicates pktsnip chain upto (including) a snip with the given type - * as a continuous snip. - * - * Example: - * Input: - * buffer - * +---------------------------+ +------+ - * | size = 8 | data +-------->| | - * | type = NETTYPE_IPV6_EXT |------------+ +------+ - * +---------------------------+ . . - * | next . . - * v . . - * +---------------------------+ +------+ - * | size = 40 | data +----------->| | - * | type = NETTYPE_IPV6 |---------+ +------+ - * +---------------------------+ . . - * | next . . - * v - * +---------------------------+ +------+ - * | size = 14 | data +-------------->| | - * | type = NETTYPE_NETIF |------+ +------+ - * +---------------------------+ . . - * - * - * Output: - * buffer - * +---------------------------+ +------+ - * | size = 48 | data +-------->| | - * | type = NETTYPE_IPV6 |------------+ | | - * +---------------------------+ | | - * | +------+ - * | . . - * | next . . - * v - * +---------------------------+ +------+ - * | size = 14 | data +-------------->| | - * | type = NETTYPE_NETIF |------+ +------+ - * +---------------------------+ . . - * - * The original snip is keeped as is except `users` decremented. - * - * @deprecated This function breaks the abstraction of `gnrc_pktbuf` and its - * only user within the RIOT code base `gnrc_ipv6_ext` was reworked - * so it isn't needed anymore. - * It will be removed after the 2019.04 release. - * - * @param[in,out] pkt The snip to duplicate. - * @param[in] type The type of snip to stop duplication. - * - * @return The duplicated snip, if succeeded. - * @return NULL, if no space is left in the packet buffer. - */ -gnrc_pktsnip_t *gnrc_pktbuf_duplicate_upto(gnrc_pktsnip_t *pkt, gnrc_nettype_t type); - /** * @brief Merge pktsnip chain to single pktsnip. * diff --git a/sys/net/gnrc/pktbuf_malloc/gnrc_pktbuf_malloc.c b/sys/net/gnrc/pktbuf_malloc/gnrc_pktbuf_malloc.c index de07bb7c968b..76fef9e3566e 100644 --- a/sys/net/gnrc/pktbuf_malloc/gnrc_pktbuf_malloc.c +++ b/sys/net/gnrc/pktbuf_malloc/gnrc_pktbuf_malloc.c @@ -295,54 +295,4 @@ static gnrc_pktsnip_t *_create_snip(gnrc_pktsnip_t *next, const void *data, size return pkt; } -gnrc_pktsnip_t *gnrc_pktbuf_duplicate_upto(gnrc_pktsnip_t *pkt, gnrc_nettype_t type) -{ - mutex_lock(&_mutex); - - bool is_shared = pkt->users > 1; - size_t size = gnrc_pkt_len_upto(pkt, type); - - DEBUG("ipv6_ext: duplicating %d octets\n", (int) size); - - gnrc_pktsnip_t *tmp; - gnrc_pktsnip_t *target = gnrc_pktsnip_search_type(pkt, type); - gnrc_pktsnip_t *next = (target == NULL) ? NULL : target->next; - gnrc_pktsnip_t *new = _create_snip(next, NULL, size, type); - - if (new == NULL) { - mutex_unlock(&_mutex); - - return NULL; - } - - /* copy payloads */ - for (tmp = pkt; tmp != NULL; tmp = tmp->next) { - uint8_t *dest = ((uint8_t *)new->data) + (size - tmp->size); - - memcpy(dest, tmp->data, tmp->size); - - size -= tmp->size; - - if (tmp->type == type) { - break; - } - } - - /* decrements reference counters */ - - if (target != NULL) { - target->next = NULL; - } - - _release_error_locked(pkt, GNRC_NETERR_SUCCESS); - - if (is_shared && (target != NULL)) { - target->next = next; - } - - mutex_unlock(&_mutex); - - return new; -} - /** @} */ diff --git a/sys/net/gnrc/pktbuf_static/gnrc_pktbuf_static.c b/sys/net/gnrc/pktbuf_static/gnrc_pktbuf_static.c index 0c9a43fb118c..ba2101e1dfd1 100644 --- a/sys/net/gnrc/pktbuf_static/gnrc_pktbuf_static.c +++ b/sys/net/gnrc/pktbuf_static/gnrc_pktbuf_static.c @@ -485,55 +485,4 @@ static void _pktbuf_free(void *data, size_t size) } } - -gnrc_pktsnip_t *gnrc_pktbuf_duplicate_upto(gnrc_pktsnip_t *pkt, gnrc_nettype_t type) -{ - mutex_lock(&_mutex); - - bool is_shared = pkt->users > 1; - size_t size = gnrc_pkt_len_upto(pkt, type); - - DEBUG("ipv6_ext: duplicating %d octets\n", (int) size); - - gnrc_pktsnip_t *tmp; - gnrc_pktsnip_t *target = gnrc_pktsnip_search_type(pkt, type); - gnrc_pktsnip_t *next = (target == NULL) ? NULL : target->next; - gnrc_pktsnip_t *new = _create_snip(next, NULL, size, type); - - if (new == NULL) { - mutex_unlock(&_mutex); - - return NULL; - } - - /* copy payloads */ - for (tmp = pkt; tmp != NULL; tmp = tmp->next) { - uint8_t *dest = ((uint8_t *)new->data) + (size - tmp->size); - - memcpy(dest, tmp->data, tmp->size); - - size -= tmp->size; - - if (tmp->type == type) { - break; - } - } - - /* decrements reference counters */ - - if (target != NULL) { - target->next = NULL; - } - - _release_error_locked(pkt, GNRC_NETERR_SUCCESS); - - if (is_shared && (target != NULL)) { - target->next = next; - } - - mutex_unlock(&_mutex); - - return new; -} - /** @} */