Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ng_protonum: Initial import of protocol number defines #2455

Merged
merged 1 commit into from
Feb 17, 2015

Conversation

miri64
Copy link
Member

@miri64 miri64 commented Feb 13, 2015

Imports protocol numbers as they are needed for IPv4 and IPv6.

@OlegHahm
Copy link
Member

Did you copy the list from somewhere or write it down yourself?

@miri64
Copy link
Member Author

miri64 commented Feb 13, 2015

I generated it from the IANA's CSV file with a quick-hacked Python script and adapted the result to my liking (renamed e.g. NG_PROTONUM_IPV6_ICMP to NG_PROTONUM_ICMPV6

* @ingroup net
* @brief Defines for the Protocol Numbers as they are used in the
* IPv4 protocol field and the IPv6 next header field
* (ng_ipv6_hdr_t::nh).
Copy link
Member

Choose a reason for hiding this comment

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

Please include "Last Updated 2015-01-06"

Copy link
Member Author

Choose a reason for hiding this comment

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

Done (s. l 18)

@OlegHahm
Copy link
Member

@authmillenon: Would you mind to share this script somehow so people might use it to update the list later?

@miri64
Copy link
Member Author

miri64 commented Feb 17, 2015

It's not that sophisticated and requires a lot of extra work later on, to achieve the list I created:

import csv
import re

with open("protocol-numbers-1.csv") as csvfile:
    r = csv.DictReader(csvfile, delimiter=",")
    for row in r:
        if (len(row["Keyword"].strip()) == 0):
            continue
        ext = ""
        if row["IPv6 Extension Header"] == "Y":
            ext = "IPV6_EXT_"
        macro = "NG_PROTNUM_" + ext + re.sub("[^A-Z0-9_]", "_", row["Keyword"].upper()).strip("_")
        comment = row["Protocol"]

        if len(comment) == 0:
            comment = row["Keyword"]
        print("#define " + macro + ((32 - len(macro)) * " ") + ("(%3d)" % int(row["Decimal"])) + "   /**< " + comment + " */")

I think for updates it is just best to add the new values by hand. Or does the IANA updates this list in bulk?

@OlegHahm
Copy link
Member

To be honest: no clue. But let's see...

@OlegHahm
Copy link
Member

ACK

@OlegHahm OlegHahm added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Feb 17, 2015
@OlegHahm
Copy link
Member

but no beer for this one.

@LudwigKnuepfer
Copy link
Member

@authmillenon please squash

@miri64 miri64 force-pushed the ng_protnum/feat/initial branch from 1f9d8da to c4e6504 Compare February 17, 2015 18:17
@miri64
Copy link
Member Author

miri64 commented Feb 17, 2015

Done

@OlegHahm OlegHahm removed the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Feb 17, 2015
OlegHahm added a commit that referenced this pull request Feb 17, 2015
ng_protonum: Initial import of protocol number defines
@OlegHahm OlegHahm merged commit a6e902f into RIOT-OS:master Feb 17, 2015
@miri64 miri64 deleted the ng_protnum/feat/initial branch February 17, 2015 19:18
@miri64 miri64 added the Area: network Area: Networking label Sep 30, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area: network Area: Networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants