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.
This commit is contained in:
parent
e8650f5b9a
commit
b83430aa62
@ -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);
|
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.
|
* @brief Merge pktsnip chain to single pktsnip.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -295,54 +295,4 @@ static gnrc_pktsnip_t *_create_snip(gnrc_pktsnip_t *next, const void *data, size
|
|||||||
return pkt;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|||||||
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user