Skip to content

Commit

Permalink
[SQUASH ME] take out some frighting verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Mar 10, 2015
1 parent 0b09f34 commit 055fe19
Showing 1 changed file with 13 additions and 128 deletions.
141 changes: 13 additions & 128 deletions sys/include/net/ng_pktbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,134 +65,18 @@ extern "C" {
* members of the resulting ng_pktsnip_t can be very different after
* execution of this function depending on what parameters you use:
*
* * @p pkt = NULL, @p data = NULL, @p size = 0:
* * no assumption about transmission direction
* * only the ng_pktsnip_t struct will be added to the packet buffer
* * ng_pktsnip_t::next = NULL
* * ng_pktsnip_t::data = NULL
* * ng_pktsnip_t::size = 0
* * ng_pktsnip_t::type = @p type
* * @p pkt = NULL, data = NULL, size > 0:
* * no assumption about transmission direction
* * ng_pktsnip_t struct and range of size @p size `mem` will be added to the
* packet buffer
* * ng_pktsnip_t::next = NULL
* * ng_pktsnip_t::data = `mem`
* * ng_pktsnip_t::size = @p size
* * ng_pktsnip_t::type = @p type
* * @p pkt = NULL, @p data != NULL, @p size = 0:
* * no assumption about transmission direction
* * only ng_pktsnip_t struct will be added to the packet buffer, data pointer
* will be set to @p data regardless if it is actually in the packet buffer or
* not.
* * ng_pktsnip_t::next = NULL
* * ng_pktsnip_t::data = @p data
* * ng_pktsnip_t::size = 0
* * ng_pktsnip_t::type = @p type
* * if @p data was from outside the packet buffer you can change both
* ng_pktsnip_t::data and ng_pktsnip_t::size of the result, since you do
* not touch any data pointers from within the packet buffer. If @p data was
* from within the range of the packet buffer, changing these members
* **will create memory leaks**.
* * @p pkt = NULL, @p data != NULL, @p size > 0:
* * no assumption about transmission direction
* * ng_pktsnip_t struct and range of size @p size `mem` will be added to the
* packet buffer
* * @p data will be copied into `mem`
* * ng_pktsnip_t::next = NULL
* * ng_pktsnip_t::data = `mem`
* * ng_pktsnip_t::size = @p size
* * ng_pktsnip_t::type = @p type
* * @p pkt != NULL, @p data = NULL, @p size = 0:
* * send direction assumed
* * only the ng_pktsnip_t struct will be added to the packet buffer
* * ng_pktsnip_t::next = @p pkt
* * ng_pktsnip_t::data = NULL
* * ng_pktsnip_t::size = 0
* * ng_pktsnip_t::type = @p type
* * @p pkt != NULL, @p data = NULL, @p size > 0:
* * send direction assumed
* * ng_pktsnip_t struct and range of size @p size `mem` will be added to the
* packet buffer
* * ng_pktsnip_t::next = @p pkt
* * ng_pktsnip_t::data = `mem`
* * ng_pktsnip_t::size = @p size
* * ng_pktsnip_t::type = @p type
* * @p pkt != NULL, @p data != NULL, @p size = 0:
* * @p data is from outside the packet:
* * no assumption about transmission direction
* * only ng_pktsnip_t struct will be added to the packet buffer, data
* pointer will be set to @p data
* * ng_pktsnip_t::next = @p pkt
* * ng_pktsnip_t::data = @p data
* * ng_pktsnip_t::size = 0
* * ng_pktsnip_t::type = @p type
* * you can change both ng_pktsnip_t::data and ng_pktsnip_t::size of the
* result, since you do not touch any data pointers from within the
* packet buffer.
* * @p data is from within the packet and `data != pkt->data`:
* * send direction assumed
* * only ng_pktsnip_t struct will be added to the packet buffer, data
* pointer will be set to @p data
* * ng_pktsnip_t::next = NULL
* * ng_pktsnip_t::data = @p data
* * ng_pktsnip_t::size = 0
* * ng_pktsnip_t::type = @p type
* * **do not** change the ng_pktsnip_t::data and ng_pktsnip_t::size of the
* result. This will most likely create memory leaks.
* * @p data is from within the packet and `data == pkt->data`:
* * receive direction assumed
* * only ng_pktsnip_t struct `new_pktsnip` will be added to the packet
* buffer, data pointer will be set to @p data
* * ng_pktsnip_t::next of @p pkt = `new_pktsnip`
* * ng_pktsnip_t::data of @p pkt = @p data
* * ng_pktsnip_t::size of @p pkt = 0
* * ng_pktsnip_t::type of @p pkt = (unchanged)
* * ng_pktsnip_t::next of `new_pktsnip` = NULL
* * ng_pktsnip_t::data of `new_pktsnip` = @p data
* * ng_pktsnip_t::size of `new_pktsnip` = old ng_pktsnip_t::size of @p pkt
* * ng_pktsnip_t::type of `new_pktsnip` = @p type
* * **do not** change the ng_pktsnip_t::data and ng_pktsnip_t::size of the
* result. This will most likely create memory leaks.
* * @p pkt = NULL, @p data != NULL, @p size > 0:
* * @p data is from outside the packet:
* * send direction assumed
* * ng_pktsnip_t struct and range of size @p size `mem` will be added to the
* packet buffer
* * ng_pktsnip_t::next = @p pkt
* * ng_pktsnip_t::data = `mem`
* * ng_pktsnip_t::size = @p size
* * ng_pktsnip_t::type = @p type
* * you can change both ng_pktsnip_t::data and ng_pktsnip_t::size of the
* result, since you do not touch any data pointers from within the
* packet buffer.
* * @p data is from within the packet and `data != pkt->data`:
* * send direction assumed
* * only ng_pktsnip_t struct will be added to the packet buffer, data
* pointer will be set to @p data
* * ng_pktsnip_t::next = @p pkt
* * ng_pktsnip_t::data = @p data
* * ng_pktsnip_t::size = @p size
* * ng_pktsnip_t::type = @p type
* * **do not** change the ng_pktsnip_t::data and ng_pktsnip_t::size of the
* result. This will most likely create memory leaks.
* * @p data is from within the packet and `data == pkt->data`:
* * receive direction assumed
* * only ng_pktsnip_t struct `new_pktsnip` will be added to the packet
* buffer, data pointer will be set to @p data
* * ng_pktsnip_t::next of @p pkt = `new_pktsnip`
* * ng_pktsnip_t::data of @p pkt = @p data
* * ng_pktsnip_t::size of @p pkt = @p size
* * ng_pktsnip_t::type of @p pkt = (unchanged)
* * ng_pktsnip_t::next of `new_pktsnip` = NULL
* * ng_pktsnip_t::data of `new_pktsnip` = @p data + @p size
* * ng_pktsnip_t::size of `new_pktsnip` = old ng_pktsnip_t::size of @p pkt - @p size
* * ng_pktsnip_t::type of `new_pktsnip` = @p type
* * **do not** change the ng_pktsnip_t::data and ng_pktsnip_t::size of the
* result. This will most likely create memory leaks.
* * for the last to cases with @p data = `pkt->data` the memory representation
* of a packet changes as follows (for all other cases the values of @p pkt
* will not be touched):
* * for most cases the result will be pretty straight forward and the
* packet is either assumed to be in sending direction or for creation
* (@p pkt == NULL) there will be made no assumtions about direction at all.
* * if @p pkt != NULL, @p data = `pkt->data`, @p size < `pkt->size` receiving
* direction is assumed and the following values will be set:
* * ng_pktsnip_t::next of result = NULL
* * ng_pktsnip_t::data of result = @p data
* * ng_pktsnip_t::size of result = @p size
* * ng_pktsnip_t::next of @p pkt = result
* * ng_pktsnip_t::data of @p pkt = @p data + @p size
* * ng_pktsnip_t::size of @p pkt = old size value - @p size
* * graphically this can be represented as follows:
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Before After
Expand Down Expand Up @@ -224,6 +108,7 @@ extern "C" {
*
* @return Pointer to the packet part that represents the new ng_pktsnip_t.
* @return NULL, if no space is left in the packet buffer.
* @return NULL, if @p pkt != NULL, @data = `pkt->data`, and @size > `pkt->data`.
*/
ng_pktsnip_t *ng_pktbuf_add(ng_pktsnip_t *pkt, void *data, size_t size,
ng_nettype_t type);
Expand Down

0 comments on commit 055fe19

Please sign in to comment.