Commit Graph

53 Commits

Author SHA1 Message Date
Martin Stein cb6377355e sntp_client: report received transmit timestamp
For now in libports because it relies on contrib sources from musl doing
the time data conversion.

Ref #3448
Ref #3450
2019-08-21 12:37:02 +02:00
Ehmry - 4caffd79db Ethernet multicast support at nic_bridge
Fix #3282
2019-05-27 14:46:53 +02:00
Alexander Boettcher dbeb1b82a9 os: avoid warning in ethernet.h
issued by clang/llvm static analyzer
2019-01-07 12:25:45 +01:00
Martin Stein 734d174f33 net: get rid of unused mac_from_string method
Issue #2815
2018-05-30 13:36:36 +02:00
Martin Stein 342bdaf4a2 net: generic ascii_to for Netaddress template
Issue #2837
2018-05-30 13:36:32 +02:00
Martin Stein 980f3e9c5c net: use Size_guard for packet-data accessors
Instead of handing over the maximum available size to the packet data
accessors, hand over a size guard that keeps track of the packets
boundaries.

This commit also moves the size-guard utilitiy header of Ping and NIC
Router to the include/net directory making it a part of the net library.
It applies the new approach to all net-lib users in the basic repositories.

Ping looses its configurability regarding the ICMP data size as this would
require an additional method in the size guard which would be used only by
Ping.

The size guard was also re-worked to fit the fact that a packet can
bring a tail as well as a header (Ethernet).

Issue #2788
2018-05-30 13:36:11 +02:00
Martin Stein 11a297b557 net: consider tail of Ethernet frame
The Ethernet payload may be followed by padding of variable length and
the FCS (Frame Check Sequence). Thus, we should consider the value
"Ethernet-frame size minus Ethernet-header size" to be only the maximum
size of the encapsulated IP packet. But until now, we considered it to
be also the actual size of the encapsulated IP packet. This commit fixes
the problem for all affected components of the Genode base-repository.

Fixes #2775
2018-05-03 15:31:57 +02:00
Martin Stein 841d583678 net: implement Udp_packet::checksum_error
For checking the checksum of a UDP packet.

Issue #2775
2018-05-03 15:31:56 +02:00
Martin Stein 6b55790e73 net: use generic internet checksum
This reduces the redundant implementations of checksum calculation to
one generic implementation, makes the checksum interface conform over
all protocols, and brings performance optimizations. For instance,
the checksum is now calculated directly in big endian which saves us
most of the previously done byte-re-ordering.

Issue #2775
2018-05-03 15:31:56 +02:00
Martin Stein 373134c4e7 net: safer access to packet data
Replace packet method 'T *data' by the new methods 'T &reinterpret_data'
for parsing or modifying existing sub-protocol packets and 'T
&construct_at_data' for composing a new sub-protocol packet. This has
the advantage that, when composing a new packet, the default constructor
that zero-fills the packet is always called first.

Fixes #2751
2018-05-03 15:31:54 +02:00
Martin Stein f9af0e6f0c net: packed attribute for Icmp_packet 2018-04-10 13:03:26 +02:00
Martin Stein ca1751528d net: utilities for DHCP parameter-request lists
Issue #2738
2018-04-10 11:20:49 +02:00
Martin Stein 6edf9ccf5a net: get rid of static constructors 2018-04-10 11:20:44 +02:00
Martin Stein 365bd347a6 net: ICMP protocol
Packet format and common utilities for the Internet Control Message
Protocol.

Issue #2732
2018-04-10 11:11:52 +02:00
Martin Stein fbd545ae70 net: remove unused enums
Issue #465
2018-01-17 12:14:41 +01:00
Martin Stein 4f1d43ce21 net: remove placement new operators
They are not used any more.

Issue #465
2018-01-17 12:14:41 +01:00
Martin Stein f4a2d932e3 net: check packet data size in accessor
Instead of having a method validate_size in each packet class, check
sizes in the data accessor of the surrounding packet class. This packet
accessor is the one that casts the data pointer to the desired data type
so it is sensible that it also checks whether the desired type would
exceed the available RAM before doing the cast. This also fits nicely
the fact that for the top-level packet-class of a packet, the size must
not be checked (which was previously done).

Issue #465
2018-01-17 12:14:41 +01:00
Norman Feske eba9c15746 Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:

* A class with virtual functions can no longer publicly inherit base
  classed without a vtable. The inherited object may either be moved
  to a member variable, or inherited privately. The latter would be
  used for classes that inherit 'List::Element' or 'Avl_node'. In order
  to enable the 'List' and 'Avl_tree' to access the meta data, the
  'List' must become a friend.

* Instead of adding a virtual destructor to abstract base classes,
  we inherit the new 'Interface' class, which contains a virtual
  destructor. This way, single-line abstract base classes can stay
  as compact as they are now. The 'Interface' utility resides in
  base/include/util/interface.h.

* With the new warnings enabled, all member variables must be explicitly
  initialized. Basic types may be initialized with '='. All other types
  are initialized with braces '{ ... }' or as class initializers. If
  basic types and non-basic types appear in a row, it is nice to only
  use the brace syntax (also for basic types) and align the braces.

* If a class contains pointers as members, it must now also provide a
  copy constructor and assignment operator. In the most cases, one
  would make them private, effectively disallowing the objects to be
  copied. Unfortunately, this warning cannot be fixed be inheriting
  our existing 'Noncopyable' class (the compiler fails to detect that
  the inheriting class cannot be copied and still gives the error).
  For now, we have to manually add declarations for both the copy
  constructor and assignment operator as private class members. Those
  declarations should be prepended with a comment like this:

        /*
         * Noncopyable
         */
        Thread(Thread const &);
        Thread &operator = (Thread const &);

  In the future, we should revisit these places and try to replace
  the pointers with references. In the presence of at least one
  reference member, the compiler would no longer implicitly generate
  a copy constructor. So we could remove the manual declaration.

Issue #465
2018-01-17 12:14:35 +01:00
Martin Stein 70c5c31ec9 nic_router: better warnings on bad DHCP requests
Be more descriptive about why the NIC router thinks that a DHCP request
sent to him is bad.

Issue #2534
2017-12-21 15:01:38 +01:00
Martin Stein 0ca248551a net: move Ipv4_address_prefix to nic_router
As this tool is not used by any other component make it local to the
NIC router to keep the net-lib interface small.

Ref #2534
2017-11-06 13:57:21 +01:00
Martin Stein 50aba6f21b dhcp: support reading of some further option types
Client ID, maximum message size, IP lease time, and requested address.
All needed for the upcoming DHCP client.

Ref #2534
2017-11-06 13:57:21 +01:00
Martin Stein 30a96706cb nic_router: dhcp server functionality
One can configure the NIC router to act as DHCP server at interfaces of a
domain by adding the <dhcp> tag to the configuration of the domain like
this:

<domain name="vbox" interface="10.0.1.1/24">
    <dhcp-server ip_first="10.0.1.80"
                 ip_last="10.0.1.100"
                 ip_lease_time_sec="3600"
                 dns_server="10.0.0.2"/>
    ...
</domain>

The attributes ip_first and ip_last define the available IPv4 address
range while ip_lease_time_sec defines the lifetime of an IPv4 address
assignment in seconds. The IPv4 address range must be in the subnet
defined by the interface attribute of the domain tag and must not cover
the IPv4 address in this attribute. The dns_server attribute gives the
IPv4 address of the DNS server that might also be in another subnet.
The lifetime of an offered assignment is the configured round trip time of
the router while the ip_lease_time_sec is applied only if the offer is
requested by the client in time.

The ports/run/virtualbox_nic_router.run script is an example of how to
use the new DHCP server functionality.

Ref #2490
2017-10-19 13:31:15 +02:00
Martin Stein d63c40af3e dhcp: extend options utilities
Provide utilities for appending new options to an existing DHCP packet
and a utility for finding existing options that returns a typed option
object. Remove old version that return untyped options.

Ref #2490
2017-10-19 13:29:44 +02:00
Martin Stein 791fd9806f ipv4 address: conversion from and to integer
Ref #2490
2017-10-19 13:29:43 +02:00
Martin Stein d0f5838c61 net: clean up header fields and accessors
Apply the style rule that an accessor is named similar to the the underlying
value. Provide read and write accessors for each mandatory header attribute.
Fix some incorrect structure in the headers like with the flags field
in Ipv4_packet.

Ref #2490
2017-10-19 13:29:43 +02:00
Martin Stein 7b55d4d5d9 ethernet: rework type for ethernet type value
Encapsulate the enum into a struct so that it is named
Ethernet_frame::Type::Enum, give it the correct storage type
uint16_t, and remove those values that are (AFAIK) not used by
now (genode, world).

Ref #2490
2017-10-19 13:29:43 +02:00
Norman Feske 29b8d609c9 Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
Martin Stein 8d521036fb IPv4: fix buggy ascii_to implementations
Ref #2193
2017-01-13 13:05:47 +01:00
Martin Stein cd708b24db IPv4: treat 0.0.0.0/0 as valid IPv4 prefix
0.0.0.0/x is now only seen as invalid if x > 0.

Ref #2193
2017-01-13 13:05:46 +01:00
Martin Stein eef18e1ecd net: introduce and apply Net::Port type
Thereby fix bug in the NIC router that previously used uint8_t values for ports in
some places.

Ref #2193
2016-12-23 16:52:10 +01:00
Martin Stein 4eea2a058d net: let Net_address and Ipv4_address be packed
Ref #2139
2016-11-30 13:38:05 +01:00
Martin Stein 4281471a34 net: replace dump.h by modern print methods
Ref #2139
2016-11-30 13:38:05 +01:00
Martin Stein da925b9cd7 net/ipv4: Ipv4_address_prefix::prefix_matches
The new method checks whether a given IPv4 address matches the IPv4
address prefix.

Ref #2139
2016-11-30 13:38:04 +01:00
Martin Stein 6276daecab net/ipv4: convenience methods valid() and print()
Both methods are now available for Ipv4_address as well as for
Ipv4_address_prefix. An IPv4 address is invalid if it contains zeros only.
An IPv4 address prefix is invalid if its address is invalid and its
prefix is 32.

Ref #2139
2016-11-30 13:38:04 +01:00
Norman Feske 6a24d70120 Fix clang compile errors
Thanks Keiko Nakata for reporting!

Fixes #2164
2016-11-30 13:37:07 +01:00
Norman Feske e370e08e01 Define Genode::size_t as unsigned long
Fixes #2105
2016-10-21 12:39:29 +02:00
Martin Stein b3c877a8bf net: tcp packet class 2016-08-29 17:29:39 +02:00
Martin Stein 0ac37dfc6e net: address operator != and some UDP accessors 2016-08-29 17:29:39 +02:00
Martin Stein 53524be285 net/mac_address: mac_from_string function 2016-08-29 17:29:39 +02:00
Martin Stein b50fe705d9 net/eth: sized-eth-frame class for creating frames 2016-08-29 17:29:38 +02:00
Martin Stein 47bc5c9a8d net/arp: further write accessors and protocol type 2016-08-29 17:29:38 +02:00
Martin Stein 136b80b7b8 net/dump.h: dump header info of network packets
Ref #114
2016-08-29 17:29:38 +02:00
Martin Stein 0ce79f3a8a udp: rename method calc_checksum update_checksum
In other contexts (IPv4) 'calc_checksum' merely returns a new checksum that is
then installed via 'checksum'. Thus, the UDP 'calc_checksum' that calculates AND
installs a new checksum is misleading.

Ref #114
2016-08-29 17:29:38 +02:00
Martin Stein ee9c4679df net/ipv4: address prefix and print support 2016-08-29 17:29:38 +02:00
Martin Stein 0f8a39e5ac net: move MAC and IPV4 address to NET namespace
Ref #114
2016-08-29 17:29:38 +02:00
Stefan Kalkowski a145e6ad70 nic_bridge: transition to the new base API
* use Component::* instead of Server::*
* do not use old printf format anymore
* do not use old Genode::env()->heap() anymore
* avoid pointers where possible, and use references instead
* throw away the thread-safe variants of list and AVL tree,
  nic_bridge became single-threaded in the past
* introduce Ram_session_guard instead of Allocator_guard

Issue #1987
2016-06-28 11:09:23 +02:00
Johannes Schlatow 27a73b89f0 net: write accessors for Ipv4_packet
Also adds header-checksum calculation function.

Fixes #1915
2016-05-23 15:52:34 +02:00
Johannes Schlatow bed870ead4 net: fix header_length field in Ipv4_packet
Replace size_t by uint8_t in accessors for the IPv4 header fields
'version' and 'header_length' - uint8_t is the smallest integral type
for 4 bit of information. Note, as the _internet header length_ field is
defined to reflect the number of 32-bit words the header occupies, we
also stick to the specification with our accessor.

Issue #1915
2016-05-23 15:49:57 +02:00
Christian Helmuth abed38e8ac net: transform packet data accessor into template
Supports stronger typing of raw accesses and const correctness.

Issue #1915
2016-05-23 15:49:56 +02:00
Sebastian Sumpf 33bc63e7c3 os: rename 'bswap' to 'host_to_big_endian' 2015-05-20 17:52:58 +02:00