Skip to content

Commit

Permalink
net/gnrc_pktbuf: rm deprecated _pktbuf_get_iovec()
Browse files Browse the repository at this point in the history
  • Loading branch information
haukepetersen committed Mar 15, 2019
1 parent 71204d1 commit 9fb2f54
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 107 deletions.
17 changes: 0 additions & 17 deletions sys/include/net/gnrc/pktbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,23 +190,6 @@ static inline void gnrc_pktbuf_release(gnrc_pktsnip_t *pkt)
*/
gnrc_pktsnip_t *gnrc_pktbuf_start_write(gnrc_pktsnip_t *pkt);

/**
* @brief Create a IOVEC representation of the packet pointed to by *pkt*
*
* @pre `(len != NULL)`
*
* @details This function will create a new packet snip in the packet buffer,
* which points to the given *pkt* and contains a IOVEC representation
* of the referenced packet in its data section.
*
* @param[in] pkt Packet to export as IOVEC
* @param[out] len Number of elements in the IOVEC
*
* @return Pointer to the 'IOVEC packet snip'
* @return NULL, if packet is empty of the packet buffer is full
*/
gnrc_pktsnip_t *gnrc_pktbuf_get_iovec(gnrc_pktsnip_t *pkt, size_t *len);

/**
* @brief Deletes a snip from a packet and the packet buffer.
*
Expand Down
34 changes: 0 additions & 34 deletions sys/net/gnrc/pktbuf/gnrc_pktbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,6 @@

#include "net/gnrc/pktbuf.h"

gnrc_pktsnip_t *gnrc_pktbuf_get_iovec(gnrc_pktsnip_t *pkt, size_t *len)
{
size_t length;
gnrc_pktsnip_t *head;
struct iovec *vec;

assert(len != NULL);
if (pkt == NULL) {
*len = 0;
return NULL;
}

/* count the number of snips in the packet and allocate the IOVEC */
length = gnrc_pkt_count(pkt);
head = gnrc_pktbuf_add(pkt, NULL, (length * sizeof(struct iovec)),
GNRC_NETTYPE_IOVEC);
if (head == NULL) {
*len = 0;
return NULL;
}

assert(head->data != NULL);
vec = (struct iovec *)(head->data);
/* fill the IOVEC */
while (pkt != NULL) {
vec->iov_base = pkt->data;
vec->iov_len = pkt->size;
++vec;
pkt = pkt->next;
}
*len = length;
return head;
}

gnrc_pktsnip_t *gnrc_pktbuf_remove_snip(gnrc_pktsnip_t *pkt,
gnrc_pktsnip_t *snip)
{
Expand Down
56 changes: 0 additions & 56 deletions tests/unittests/tests-pktbuf/tests-pktbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,59 +811,6 @@ static void test_pktbuf_start_write__pkt_users_2(void)
TEST_ASSERT(gnrc_pktbuf_is_empty());
}

static void test_pktbuf_get_iovec__1_elem(void)
{
struct iovec *vec;
size_t len;
gnrc_pktsnip_t *snip = gnrc_pktbuf_add(NULL, TEST_STRING16, sizeof(TEST_STRING16),
GNRC_NETTYPE_UNDEF);
snip = gnrc_pktbuf_get_iovec(snip, &len);
vec = (struct iovec *)snip->data;

TEST_ASSERT_EQUAL_INT(sizeof(struct iovec), snip->size);
TEST_ASSERT_EQUAL_INT(1, len);
TEST_ASSERT(snip->next->data == vec[0].iov_base);
TEST_ASSERT_EQUAL_INT(snip->next->size, vec[0].iov_len);

gnrc_pktbuf_release(snip);
TEST_ASSERT(gnrc_pktbuf_is_empty());
}

static void test_pktbuf_get_iovec__3_elem(void)
{
struct iovec *vec;
size_t len;
gnrc_pktsnip_t *snip = gnrc_pktbuf_add(NULL, TEST_STRING16, sizeof(TEST_STRING16),
GNRC_NETTYPE_UNDEF);
snip = gnrc_pktbuf_add(snip, TEST_STRING8, sizeof(TEST_STRING8), GNRC_NETTYPE_UNDEF);
snip = gnrc_pktbuf_add(snip, TEST_STRING4, sizeof(TEST_STRING4), GNRC_NETTYPE_UNDEF);
snip = gnrc_pktbuf_get_iovec(snip, &len);
vec = (struct iovec *)snip->data;

TEST_ASSERT_EQUAL_INT((sizeof(struct iovec) * 3), snip->size);
TEST_ASSERT_EQUAL_INT(3, len);
TEST_ASSERT(snip->next->data == vec[0].iov_base);
TEST_ASSERT(snip->next->next->data == vec[1].iov_base);
TEST_ASSERT(snip->next->next->next->data == vec[2].iov_base);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING4), vec[0].iov_len);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING8), vec[1].iov_len);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING16), vec[2].iov_len);

gnrc_pktbuf_release(snip);
TEST_ASSERT(gnrc_pktbuf_is_empty());
}

static void test_pktbuf_get_iovec__null(void)
{
gnrc_pktsnip_t *res;
size_t len;

res = gnrc_pktbuf_get_iovec(NULL, &len);

TEST_ASSERT(res == NULL);
TEST_ASSERT_EQUAL_INT(0, len);
}

static void test_pktbuf_reverse_snips__too_full(void)
{
gnrc_pktsnip_t *pkt, *pkt_next, *pkt_huge;
Expand Down Expand Up @@ -953,9 +900,6 @@ Test *tests_pktbuf_tests(void)
new_TestFixture(test_pktbuf_start_write__NULL),
new_TestFixture(test_pktbuf_start_write__pkt_users_1),
new_TestFixture(test_pktbuf_start_write__pkt_users_2),
new_TestFixture(test_pktbuf_get_iovec__1_elem),
new_TestFixture(test_pktbuf_get_iovec__3_elem),
new_TestFixture(test_pktbuf_get_iovec__null),
new_TestFixture(test_pktbuf_reverse_snips__too_full),
new_TestFixture(test_pktbuf_reverse_snips__success),
};
Expand Down

0 comments on commit 9fb2f54

Please sign in to comment.