net/pkt: Remove useless legacy net_pkt_pull function
Now that the stack uses the new API from net_pkt for pulling, no need to keep the legacy one around. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
c65304f088
commit
09b782a82d
|
@ -1901,21 +1901,6 @@ static inline bool net_pkt_insert_be32_timeout(struct net_pkt *pkt,
|
|||
int net_pkt_split(struct net_pkt *pkt, struct net_buf *frag, u16_t offset,
|
||||
struct net_buf **rest, s32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Remove data from the packet at arbitrary offset.
|
||||
*
|
||||
* @details This will remove the data from arbitrary offset. Original packet
|
||||
* will be modified.
|
||||
*
|
||||
* @param pkt Network packet
|
||||
* @param offset Arbitrary offset to packet
|
||||
* @param len Number of bytes to be removed
|
||||
*
|
||||
* @return 0 on success, <0 otherwise
|
||||
*
|
||||
*/
|
||||
int net_pkt_pull(struct net_pkt *pkt, u16_t offset, u16_t len);
|
||||
|
||||
/**
|
||||
* @brief Return the fragment and offset within it according to network
|
||||
* packet offset.
|
||||
|
|
|
@ -1720,100 +1720,6 @@ void net_pkt_get_info(struct k_mem_slab **rx,
|
|||
}
|
||||
}
|
||||
|
||||
int net_pkt_pull(struct net_pkt *pkt, u16_t offset, u16_t len)
|
||||
{
|
||||
struct net_buf *frag;
|
||||
struct net_buf *temp;
|
||||
struct net_buf *prev;
|
||||
u8_t avail;
|
||||
|
||||
if (!pkt || !len) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
prev = NULL;
|
||||
frag = pkt->frags;
|
||||
|
||||
while (1) {
|
||||
if (!frag) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (offset < frag->len) {
|
||||
break;
|
||||
}
|
||||
|
||||
offset -= frag->len;
|
||||
prev = frag;
|
||||
frag = frag->frags;
|
||||
}
|
||||
|
||||
/* Pull the data */
|
||||
while (frag && len) {
|
||||
if (!offset) {
|
||||
if (len > frag->len) {
|
||||
len -= frag->len;
|
||||
|
||||
temp = frag;
|
||||
frag = frag->frags;
|
||||
temp->frags = NULL;
|
||||
offset = 0U;
|
||||
|
||||
net_buf_unref(temp);
|
||||
|
||||
if (prev) {
|
||||
prev->frags = frag;
|
||||
} else {
|
||||
pkt->frags = frag;
|
||||
}
|
||||
} else {
|
||||
memmove(frag->data, frag->data + len,
|
||||
frag->len - len);
|
||||
frag->len -= len;
|
||||
len = 0U;
|
||||
|
||||
if (!frag->len) {
|
||||
temp = frag;
|
||||
frag = frag->frags;
|
||||
temp->frags = NULL;
|
||||
|
||||
net_buf_unref(temp);
|
||||
|
||||
if (prev) {
|
||||
prev->frags = frag;
|
||||
} else {
|
||||
pkt->frags = frag;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
avail = frag->len - offset;
|
||||
|
||||
if (len > avail) {
|
||||
frag->len = offset;
|
||||
|
||||
len -= avail;
|
||||
prev = frag;
|
||||
frag = frag->frags;
|
||||
offset = 0U;
|
||||
} else {
|
||||
memmove(frag->data + offset,
|
||||
frag->data + offset + len,
|
||||
avail - len);
|
||||
frag->len -= len;
|
||||
len = 0U;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (len) {
|
||||
NET_ERR("Could not pull given length out of net packet");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC)
|
||||
void net_pkt_print(void)
|
||||
{
|
||||
|
|
|
@ -962,66 +962,6 @@ static void test_fragment_split(void)
|
|||
net_buf_unref(rest);
|
||||
}
|
||||
|
||||
static const char pull_test_data[] =
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz "
|
||||
"abcdefghijklmnopqrstuvxyz ";
|
||||
|
||||
static void test_pkt_pull(void)
|
||||
{
|
||||
struct net_pkt *pkt;
|
||||
u16_t ret;
|
||||
int res;
|
||||
|
||||
pkt = net_pkt_get_reserve_rx(K_FOREVER);
|
||||
|
||||
ret = net_pkt_append(pkt, sizeof(pull_test_data), (u8_t *)
|
||||
pull_test_data, K_FOREVER);
|
||||
|
||||
zassert_false(!ret, "Failed to append data");
|
||||
|
||||
res = net_pkt_pull(pkt, 0, 10);
|
||||
|
||||
zassert_true(res == 0, "Failed to pull 10 bytes from offset 0");
|
||||
|
||||
res = net_pkt_pull(pkt, 10, 20);
|
||||
|
||||
zassert_true(res == 0, "Failed to pull 10 bytes from offset 0");
|
||||
|
||||
res = net_pkt_pull(pkt, 140, 150);
|
||||
|
||||
zassert_true(res == 0, "Failed to pull 10 bytes from offset 0");
|
||||
|
||||
res = net_pkt_pull(pkt, 42, 72);
|
||||
|
||||
zassert_true(res == 0, "Failed to pull 10 bytes from offset 0");
|
||||
|
||||
res = net_pkt_pull(pkt, 0, 42);
|
||||
|
||||
zassert_true(res == 0, "Failed to pull 10 bytes from offset 0");
|
||||
|
||||
res = net_pkt_pull(pkt, 138, 69);
|
||||
|
||||
zassert_true(res == 0, "Failed to pull 10 bytes from offset 0");
|
||||
}
|
||||
|
||||
static void test_net_pkt_append_memset(void)
|
||||
{
|
||||
struct net_pkt *pkt;
|
||||
|
@ -1093,7 +1033,6 @@ void test_main(void)
|
|||
ztest_unit_test(test_pkt_read_write_insert),
|
||||
ztest_unit_test(test_fragment_compact),
|
||||
ztest_unit_test(test_fragment_split),
|
||||
ztest_unit_test(test_pkt_pull),
|
||||
ztest_unit_test(test_net_pkt_append_memset),
|
||||
ztest_unit_test(test_net_pkt_frag_linearize)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue