summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusant Sahani <susant@redhat.com>2017-04-27 07:11:46 +0200
committerSusant Sahani <susant@redhat.com>2017-04-29 19:03:50 +0200
commit177d0b20321a4548f27ba769e35d44f747c10852 (patch)
treef0b3ef41977c28197157d55a7f1b313ef0173ae7
parentMerge pull request #5164 from Werkov/ordering-for-_netdev-devices (diff)
downloadsystemd-177d0b20321a4548f27ba769e35d44f747c10852.tar.xz
systemd-177d0b20321a4548f27ba769e35d44f747c10852.zip
config parser: Introduce config_parse_ip_port
Diffstat (limited to '')
-rw-r--r--src/shared/conf-parser.c37
-rw-r--r--src/shared/conf-parser.h1
2 files changed, 38 insertions, 0 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index d8393cbc8d..dae521ef9f 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -960,3 +960,40 @@ int config_parse_ifname(
return 0;
}
+
+int config_parse_ip_port(
+ 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) {
+
+ uint16_t *s = data;
+ uint16_t port;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ if (isempty(rvalue)) {
+ *s = 0;
+ return 0;
+ }
+
+ r = parse_ip_port(rvalue, &port);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse port '%s'.", rvalue);
+ return 0;
+ }
+
+ *s = port;
+
+ return 0;
+}
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 82ea5c1288..ce1113485d 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -140,6 +140,7 @@ int config_parse_log_level(const char *unit, const char *filename, unsigned line
int config_parse_signal(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);
int config_parse_personality(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);
int config_parse_ifname(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);
+int config_parse_ip_port(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);
#define DEFINE_CONFIG_PARSE_ENUM(function,name,type,msg) \
int function(const char *unit, \