Skip to content

pkt: simplify API#2342

Merged
miri64 merged 2 commits intoRIOT-OS:masterfrom
miri64:pkt/api/simplify
Feb 11, 2015
Merged

pkt: simplify API#2342
miri64 merged 2 commits intoRIOT-OS:masterfrom
miri64:pkt/api/simplify

Conversation

@miri64
Copy link
Copy Markdown
Member

@miri64 miri64 commented Jan 22, 2015

Simplifies pkt module API by unifying pkt_t and pkt_hlist_t to pktsnip_t and by changing how packets are viewed in the network stack in general.

A concatenated packet (it does not have to be concatenated ;-)) packet in the packet buffer would be annotated as follows:

                                                                  buffer
              +---------------------------+                      +------+
              | size = 14                 | data +-------------->|      |
              | type = PKT_PROTO_ETHERNET |------+               +------+
              +---------------------------+         +----------->|      |
                    | next                          |            |      |
                    v                               |            |      |
              +---------------------------+         |            +------+
              | size = 40                 | data    |  +-------->|      |
              | type = PKT_PROTO_IPV6     |---------+  |         +------+
              +---------------------------+            |  +----->|      |
                    | next                             |  |      +------+
                    v                                  |  |  +-->|      |
              +---------------------------+            |  |  |   |      |
              | size = 8                  | data       |  |  |   .      .
              | type = PKT_PROTO_UDP      |------------+  |  |   .      .
              +---------------------------+               |  |
                    | next                                |  |
                    v                                     |  |
              +---------------------------+               |  |
              | size = 5                  | data          |  |
              | type = PKT_PROTO_COAP     |---------------+  |
              +---------------------------+                  |
                    | next                                   |
                    v                                        |
              +---------------------------+                  |
              | size = 54                 | data             |
              | type = PKT_PROTO_UNKNOWN  |------------------+
              +---------------------------+

@miri64 miri64 added this to the Release NEXT MAJOR milestone Jan 22, 2015
@miri64 miri64 added Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Area: network Area: Networking Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Jan 22, 2015
@miri64 miri64 force-pushed the pkt/api/simplify branch 2 times, most recently from 31a6e67 to afa484a Compare January 30, 2015 13:48
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jan 30, 2015

Rebased to master

@OlegHahm OlegHahm modified the milestones: Release NEXT MAJOR, Network Stack Task Force Feb 6, 2015
@OlegHahm OlegHahm added NSTF and removed NSTF labels Feb 6, 2015
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 7, 2015

I included the changes discussed in the Network stack task force meeting and based it on #2397 now.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 7, 2015

Tests are not adapted, yet.

@miri64 miri64 mentioned this pull request Feb 7, 2015
36 tasks
@haukepetersen
Copy link
Copy Markdown
Contributor

I would strongly vote for renaming the module and header file to pktsnip and pktsnip.h! Also I would actually cut the module down to a single header file - I my opinion the included functions are not really bringing much benefits, so I would keep it simple and drop them.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 7, 2015

I'm against renaming the file or the module. The overall concept is abstracting packets. pktsnip_t is just a type to represent a node in the list of headers that is a packet. We don't named clist.h clist_node.h either, though the type is named clist_node_t.

The functions bring the benefit of reducing code duplication in every layer. I was sick of doing the same thing I did already for nomac and sixlowpan in IPv6 by basically copying 20 lines of code or so over every time.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 7, 2015

Since I recently discovered utlist the functions where really just wrappers for utlist macros, so I decided to remove most of them. The only remaining one, which is now inlined is the byte-counter function ng_pkt_len().

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. in the static ..

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… packet buffer. As seen in line below ;-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2015?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module was already included in 2014.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was once told that I should always update my copyrights to whenever I touched the file last - but I don't really care...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both, the first and last year of the copyright "application" are important to determine since, and until when it holds.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that would be 2014-15 then, but we don't do this anywhere else…

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure we do, also why not start now even if?

* Copyright (C) 2013 - 2015 Freie Universität Berlin

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ git grep -E "201[0-9].* 201[0-9]" | wc -l
33

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 10, 2015

Addressed comments

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 10, 2015

Rebased to current master

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 10, 2015

Disentangled: squashable commits that contained both changes to pkt and pktqueue

@haukepetersen
Copy link
Copy Markdown
Contributor

ACK when squashed.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 11, 2015

Squashed

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 11, 2015

Added fixup to doc

miri64 added a commit that referenced this pull request Feb 11, 2015
@miri64 miri64 merged commit cfc64ff into RIOT-OS:master Feb 11, 2015
@miri64 miri64 deleted the pkt/api/simplify branch February 11, 2015 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants