mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
network: make FooOverUDP.Protocol= support name of ipproto
This commit is contained in:
parent
881c74bd64
commit
7df5c6ba90
|
@ -5,6 +5,7 @@
|
|||
#include <linux/ip.h>
|
||||
|
||||
#include "conf-parser.h"
|
||||
#include "ip-protocol-list.h"
|
||||
#include "missing.h"
|
||||
#include "netdev/fou-tunnel.h"
|
||||
#include "netlink-util.h"
|
||||
|
@ -112,6 +113,43 @@ static int netdev_fou_tunnel_create(NetDev *netdev) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_ip_protocol(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
uint8_t *protocol = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(section);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
assert_cc(IPPROTO_MAX-1 <= UINT8_MAX);
|
||||
|
||||
r = parse_ip_protocol(rvalue);
|
||||
if (r < 0) {
|
||||
r = safe_atou8(rvalue, protocol);
|
||||
if (r < 0)
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to parse IP protocol '%s' for Foo over UDP tunnel, "
|
||||
"ignoring assignment: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*protocol = r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int netdev_fou_tunnel_verify(NetDev *netdev, const char *filename) {
|
||||
FouTunnel *t;
|
||||
|
||||
|
|
|
@ -34,3 +34,4 @@ const char *fou_encap_type_to_string(FooOverUDPEncapType d) _const_;
|
|||
FooOverUDPEncapType fou_encap_type_from_string(const char *d) _pure_;
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_fou_encap_type);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_ip_protocol);
|
||||
|
|
|
@ -75,7 +75,7 @@ Tunnel.IPv6RapidDeploymentPrefix, config_parse_6rd_prefix, 0,
|
|||
Tunnel.ERSPANIndex, config_parse_uint32, 0, offsetof(Tunnel, erspan_index)
|
||||
Tunnel.SerializeTunneledPackets, config_parse_tristate, 0, offsetof(Tunnel, gre_erspan_sequence)
|
||||
Tunnel.ISATAP, config_parse_tristate, 0, offsetof(Tunnel, isatap)
|
||||
FooOverUDP.Protocol, config_parse_uint8, 0, offsetof(FouTunnel, fou_protocol)
|
||||
FooOverUDP.Protocol, config_parse_ip_protocol, 0, offsetof(FouTunnel, fou_protocol)
|
||||
FooOverUDP.Encapsulation, config_parse_fou_encap_type, 0, offsetof(FouTunnel, fou_encap_type)
|
||||
FooOverUDP.Port, config_parse_ip_port, 0, offsetof(FouTunnel, port)
|
||||
L2TP.TunnelId, config_parse_l2tp_tunnel_id, 0, offsetof(L2tpTunnel, tunnel_id)
|
||||
|
|
Loading…
Reference in a new issue