mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-20 06:07:59 +00:00
eba22b7551
* Update links from forward rules only with forward rules and links from transport-routing rules only with transport-routing rules. Besides raising the performance of the code, this also fixes a former bug that allowed forward-rule links to falsely stay active because of a transport-routing rule that matched the client destination ip and port. * Don't use good-case exceptions for updating TCP/UDP links on re-configuration of the router. * Make conditions when to dismiss a forward rule easier to read. * Introduces != operator to the public Port class in the net library. * Fix unnecessary log message that a link was dismissed when only a potentially matching forward rule turned out to be not matching. * Apply Genode coding style to if statements with a single body statement. Fix #4728
61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
/*
|
|
* \brief Network port
|
|
* \author Martin Stein
|
|
* \date 2016-08-19
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2016-2017 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU Affero General Public License version 3.
|
|
*/
|
|
|
|
#ifndef _NET__PORT_H_
|
|
#define _NET__PORT_H_
|
|
|
|
/* Genode includes */
|
|
#include <base/stdint.h>
|
|
#include <base/output.h>
|
|
#include <util/string.h>
|
|
|
|
namespace Net {
|
|
class Port;
|
|
|
|
static inline Genode::size_t ascii_to(const char *, Net::Port &);
|
|
}
|
|
|
|
/**
|
|
* This class makes it clear what the port integer-value means at an interface
|
|
*/
|
|
struct Net::Port
|
|
{
|
|
Genode::uint16_t value;
|
|
|
|
explicit Port(Genode::uint16_t const value) : value(value) { }
|
|
|
|
bool operator == (Port const &other) const { return value == other.value; }
|
|
bool operator != (Port const &other) const { return value != other.value; }
|
|
|
|
void print(Genode::Output &out) const { Genode::print(out, value); }
|
|
}
|
|
__attribute__((packed));
|
|
|
|
|
|
/**
|
|
* Read port value from string
|
|
*
|
|
* \return number of consumed characters
|
|
*/
|
|
Genode::size_t Net::ascii_to(const char *s, Net::Port &result)
|
|
{
|
|
using namespace Genode;
|
|
|
|
uint16_t value = 0;
|
|
size_t const consumed = ascii_to_unsigned(s, value, 0);
|
|
result = Net::Port(value);
|
|
return consumed;
|
|
}
|
|
|
|
#endif /* _NET__PORT_H_ */
|