Commit graph

19 commits

Author SHA1 Message Date
Vito Caputo 313cefa1d9 tree-wide: make ++/-- usage consistent WRT spacing
Throughout the tree there's spurious use of spaces separating ++ and --
operators from their respective operands.  Make ++ and -- operator
consistent with the majority of existing uses; discard the spaces.
2016-02-22 20:32:04 -08:00
Beniamino Galvani 22805d9207 dhcp: make DHCP_OPTION_* enum public
libsystemd-network provides the public function
sd_dhcp_client_set_request_option() to enable the request of a given
DHCP option. However the enum defining such options is defined in the
internal header dhcp-protocol.h. Move the enum definition to the
public header sd-dhcp-client.h and properly namespace values.
2016-01-20 17:25:16 +01:00
Thomas Hindoe Paaboel Andersen cf0fbc49e6 tree-wide: sort includes
Sort the includes accoding to the new coding style.
2015-11-16 22:09:36 +01:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
Dan Williams 76253e73f9 sd-dhcp-client: support non-Ethernet hardware addresses
Like Infiniband.  See RFC 4390 section 2.1 for details on DHCP
and Infiniband; chaddr is zeroed, hlen is set to 0, and htype
is set to ARPHRD_INFINIBAND because IB hardware addresses
are 20 bytes in length.
2014-10-11 12:15:54 +02:00
Tom Gundersen 0bbc2c1f3b sd-dhcp: checksum - make endianess-neutral
For efficiency, we group bytes together before adding them up. This
is guaranteed to always work (regardless of the byte order) as long
as the i-th byte in each group lign up with the i-th byte in each
other group.

On big-endian machines this broke when handling the trailing few bytes
which did not make up a full group of 4 bytes. This patch fixes the
problem by explicitly creating a 4 byte zero-padded group out of the
trailing bytes.

Reported and tested by Thomas Ritter <th.ritter@gmx.at>.
2014-06-17 09:17:07 +02:00
Tom Gundersen 04b28be1a3 sd-dhcp: option_append - support falling back to 'sname' and 'file' 2014-05-21 16:09:05 +02:00
Tom Gundersen 20b958bf15 sd-dhcp: refactor dhcp_option_append
Store a pointer to the options in the DHCPMessage struct, and pass
this together with an offset around, rather than a uint8_t**.

This avoids us having to (re)compute the pointer; and changes
dhcp_option_append from adjusting both the pointer to the next
option and the remaining size of the options, to just adjusting
the current offset.

This makes the code a bit simpler to follow IMHO, but there should
be no functional change.
2014-05-20 23:31:22 +02:00
Tom Gundersen 85923f79e1 sd-dhcp: network - set TOS on outgoing packets
This should improve performance on busy wireless networks and the
like. Inspired by a similar change in dnsmasq.
2014-05-06 22:09:05 +02:00
Tom Gundersen aa6fc9b8c8 sd-dhcp-client: include client id in debug messages 2014-04-08 19:16:30 +02:00
Tom Gundersen d576127429 libsystemd-network: Speed up checksum computation using 64 bit integers
Improve the checksum computation by using 64 bit integers instead of the 16 bit
integers in the existing implementation. This change speeds up the computation
with approximately 78% both on 64 bit and 32 bit systems.

Please see RFC 1071 for details.
2014-04-07 15:39:21 +03:00
Tom Gundersen 0c79c68d93 sd-dhcp-client: eagerly drop too small packets
If they are too small to fit the IP+UDP+DHCP headers they can be of no use, so
don't waste resources parsing them. This is at the cost of losing some verbosity
in the logging.
2014-04-06 19:42:11 +02:00
Tom Gundersen 3b7ca119fd sd-dhcp-client: move magic cookie into DHCPMessage struct
Also move the checking of it to the main message handler, rather than the
options parser.

Fix a bug, so we now drop the packet if any of the magic bytes don't match.
Before we used to only drop the packet if they were all wrong.
2014-04-06 19:36:05 +02:00
Tom Gundersen 2ad7561f9f sd-dhcp: avoid checksum calculation if possible
When receiving lots of packets that are not meant for us, we waste a relatively large amount
of cpu time computing their checksums before discarding them. Move the checksum calculation last
so we never compute it for packets which would otherwise be discarded.
2014-03-30 20:46:40 +02:00
Tom Gundersen 6e34949d72 sd-dhcp: check for ipv4 packets 2014-03-30 20:46:40 +02:00
Umut Tezduyar Lindskog d454a6748c sd-dhcp: check for udp packets
Do not try to parse ICMP packets

[tomegun: slightly tweaked debug message]
2014-03-30 20:46:20 +02:00
Patrik Flykt a838c939a3 libsystemd-network: Export checksum function to test case
Remove identical checksum function implementation from the test
case code.
2014-03-19 10:52:40 +02:00
Tom Gundersen 63edaa623b sd-dhcp: generalise ip header generation
This will be needed for sd-dhcp-server.
2014-03-11 12:03:46 +01:00
Tom Gundersen fe8db0c5ee sd-network: add new library
This is similar to sd-login, but exposes the state of networkd rather than logind.

Include it in libsystemd-dhcp and rename it to libsystemd-network.
2014-02-28 01:01:13 +01:00
Renamed from src/libsystemd-dhcp/dhcp-packet.c (Browse further)