Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ip #355

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Ip #355

wants to merge 2 commits into from

Conversation

ArnaudD-FR
Copy link
Contributor

[IP] use IP header instead of array offsets

Description

  • less error prone

  • decrease code size to flash (save some bytes, see below)

  • introduce ethernet_header(), ethernet_payload(), ip_header(),
    ip_payload().... basic functions to retrieve headers and payloads

  • use ntoh and hton instead of manual multibytes adaptations.
    getBigEndianLong has been replaced by standard function ntohl.

Code size evolution depending on examples

Negative value: save size
Positive value: increase size

test old program size old data size new program size new data size program size delta data size delta
backSoon 8074 939 8100 939 26 0
getDHCPandDNS 10358 1246 10326 1246 -32 0
getStaticIP 9676 827 9674 827 -2 0
getViaDNS 10206 820 10168 820 -38 0
multipacket 7740 1279 7730 1279 -10 0
nanether 8034 1093 8020 1093 -14 0
noipClient 14706 1357 14666 1355 -40 -2
notifyMyAndroid 11238 1656 11204 1656 -34 0
ntpClient 9018 865 8984 865 -34 0
persistence 10910 823 10838 823 -72 0
pings 10110 1146 10054 1146 -56 0
rbbb_server 8514 881 8522 881 8 0
SSDP 9244 1153 9220 1153 -24 0
stashTest 7152 539 7152 539 0 0
testDHCP 7818 1099 7808 1101 -10 2
testDHCPOptions 7942 1113 7948 1113 6 0
thingspeak 14776 1380 14744 1380 -32 0
twitter 11122 1386 11086 1386 -36 0
udpClientSendOnly 8452 1156 8426 1156 -26 0
udpListener 8380 964 8376 964 -4 0
webClient 10346 1164 10314 1164 -32 0
xively 14838 1058 14806 1058 -32 0

Copy link
Contributor

@nuno-silva nuno-silva left a comment

Choose a reason for hiding this comment

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

Thank you for your work!

#define ETH_ARP_DST_MAC_P 0x20
#define ETH_ARP_DST_IP_P 0x26
// Ethernet II header
struct EthHeader
Copy link
Contributor

Choose a reason for hiding this comment

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

This struct should also be __attribute__((__packed__)), right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is EtherCard support something else than 8 bits controllers? If yes then we need this attribute

Copy link
Contributor

@nuno-silva nuno-silva Feb 7, 2019

Choose a reason for hiding this comment

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

I don't think so, but even if that's not the case, there's no harm in adding it for future proof :)

Copy link
Owner

Choose a reason for hiding this comment

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

I am aiming to add support for a wider range of devices, including the 32-bit ones, such as the Arduino M0.

The biggest blocker is the SPI interface - I have a half-complete branch using the Arduino SPI library - see #335.

Arnaud added 2 commits February 11, 2019 20:52
 * keep MAC/IP relations into an ARP 'store'.
 * fix issue when IP packet is received from local network: answer is
   no more broadcasted
 * define ETHERCARD_ARP_STORE_SIZE to set cache size
 * less error prone

 * decrease code size to flash

 * introduce ethernet_header(), ethernet_payload(), ip_header(),
   ip_payload().... basic functions to retrieve headers and payloads

 * use ntoh and hton instead of manual multibytes adaptations.
   getBigEndianLong has been replaced by standard function ntohl.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants