Commit 010285e8 authored by Linus Nordberg's avatar Linus Nordberg

Add configuration options for F-Ticks logging.

parent fb2fa29c
...@@ -3002,11 +3002,76 @@ int setprotoopts(uint8_t type, char **listenargs, char *sourcearg) { ...@@ -3002,11 +3002,76 @@ int setprotoopts(uint8_t type, char **listenargs, char *sourcearg) {
return 1; return 1;
} }
int configure_fticks(char **reporting, char **mac, char **key) {
int r = 0;
if (*reporting == NULL)
goto out;
if (strcasecmp(*reporting, "None") == 0)
options.fticks_reporting = RSP_FTICKS_REPORTING_NONE;
else if (strcasecmp(*reporting, "Basic") == 0)
options.fticks_reporting = RSP_FTICKS_REPORTING_BASIC;
else if (strcasecmp(*reporting, "Full") == 0)
options.fticks_reporting = RSP_FTICKS_REPORTING_FULL;
else {
debugx(1, DBG_ERR, "config error: invalid F-Ticks-Reporting value: %s",
*reporting);
r = 1;
goto out;
}
if (strcasecmp(*mac, "Static") == 0)
options.fticks_mac = RSP_FTICKS_MAC_STATIC;
else if (strcasecmp(*mac, "Original") == 0)
options.fticks_mac = RSP_FTICKS_MAC_ORIGINAL;
else if (strcasecmp(*mac, "VendorHashed") == 0)
options.fticks_mac = RSP_FTICKS_MAC_VENDOR_HASHED;
else if (strcasecmp(*mac, "VendorKeyHashed") == 0)
options.fticks_mac = RSP_FTICKS_MAC_VENDOR_KEY_HASHED;
else if (strcasecmp(*mac, "FullyHashed") == 0)
options.fticks_mac = RSP_FTICKS_MAC_FULLY_HASHED;
else if (strcasecmp(*mac, "FullyKeyHashed") == 0)
options.fticks_mac = RSP_FTICKS_MAC_FULLY_KEY_HASHED;
else {
debugx(1, DBG_ERR, "config error: invalid F-Ticks-MAC value: %s", *mac);
r = 1;
goto out;
}
if (*key == NULL
&& (options.fticks_mac == RSP_FTICKS_MAC_VENDOR_KEY_HASHED
|| options.fticks_mac == RSP_FTICKS_MAC_FULLY_KEY_HASHED)) {
debugx(1, DBG_ERR,
"config error: F-Ticks-MAC %s requires an F-Ticks-Key", *mac);
options.fticks_mac = RSP_FTICKS_MAC_STATIC;
r = 1;
goto out;
}
if (*key != NULL)
options.fticks_key = *key;
out:
if (*reporting != NULL) {
free(*reporting);
*reporting = NULL;
}
if (*mac != NULL) {
free(*mac);
*mac = NULL;
}
return r;
}
void getmainconfig(const char *configfile) { void getmainconfig(const char *configfile) {
long int addttl = LONG_MIN, loglevel = LONG_MIN; long int addttl = LONG_MIN, loglevel = LONG_MIN;
struct gconffile *cfs; struct gconffile *cfs;
char **listenargs[RAD_PROTOCOUNT]; char **listenargs[RAD_PROTOCOUNT];
char *sourcearg[RAD_PROTOCOUNT]; char *sourcearg[RAD_PROTOCOUNT];
char *fticks_reporting_str = NULL;
char *fticks_mac_str = NULL;
char *fticks_key_str = NULL;
int i; int i;
cfs = openconfigfile(configfile); cfs = openconfigfile(configfile);
...@@ -3060,6 +3125,9 @@ void getmainconfig(const char *configfile) { ...@@ -3060,6 +3125,9 @@ void getmainconfig(const char *configfile) {
"TLS", CONF_CBK, conftls_cb, NULL, "TLS", CONF_CBK, conftls_cb, NULL,
#endif #endif
"Rewrite", CONF_CBK, confrewrite_cb, NULL, "Rewrite", CONF_CBK, confrewrite_cb, NULL,
"F-Ticks-Reporting", CONF_STR, &fticks_reporting_str,
"F-Ticks-MAC", CONF_STR, &fticks_mac_str,
"F-Ticks-Key", CONF_STR, &fticks_key_str,
NULL NULL
)) ))
debugx(1, DBG_ERR, "configuration error"); debugx(1, DBG_ERR, "configuration error");
...@@ -3077,6 +3145,8 @@ void getmainconfig(const char *configfile) { ...@@ -3077,6 +3145,8 @@ void getmainconfig(const char *configfile) {
if (!setttlattr(&options, DEFAULT_TTL_ATTR)) if (!setttlattr(&options, DEFAULT_TTL_ATTR))
debugx(1, DBG_ERR, "Failed to set TTLAttribute, exiting"); debugx(1, DBG_ERR, "Failed to set TTLAttribute, exiting");
configure_fticks(&fticks_reporting_str, &fticks_mac_str, &fticks_key_str);
for (i = 0; i < RAD_PROTOCOUNT; i++) for (i = 0; i < RAD_PROTOCOUNT; i++)
if (listenargs[i] || sourcearg[i]) if (listenargs[i] || sourcearg[i])
setprotoopts(i, listenargs[i], sourcearg[i]); setprotoopts(i, listenargs[i], sourcearg[i]);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#SourceTCP *:33000 #SourceTCP *:33000
#SourceTLS *:33001 #SourceTLS *:33001
#SourceDTLS *:33001 #SourceDTLS *:33001
# Optional log level. 3 is default, 1 is less, 5 is more # Optional log level. 3 is default, 1 is less, 5 is more
#LogLevel 3 #LogLevel 3
# Optional LogDestination, else stderr used for logging # Optional LogDestination, else stderr used for logging
...@@ -28,6 +29,30 @@ ...@@ -28,6 +29,30 @@
#LogDestination x-syslog:/// #LogDestination x-syslog:///
#LogDestination x-syslog:///log_local2 #LogDestination x-syslog:///log_local2
# For generating log entries conforming to the F-Ticks system, specify
# F-Ticks-Reporting with one of
# None -- Do not log in F-Ticks format. This is the default.
# Basic -- Do log in F-Ticks format but do not log VISINST.
# Full -- Do log in F-Ticks format and do log VISINST.
# You can optionally specify F-Ticks-MAC in order to determine if and
# how Calling-Station-Id is logged.
# Static -- Use a static string as a placeholder for
# Calling-Station-Id. This is the default.
# Original -- Log Calling-Station-Id as-is.
# VendorHashed -- Keep first three segments as-is, hash the rest.
# VendorKeyHashed -- Like VendorHashed but salt with F-Ticks-Key.
# FullyHashed -- Hash the entire string.
# FullyKeyHashed -- Like FullyHashed but salt with F-Ticks-Key.
# In order to use F-Ticks-MAC with one of VendorKeyHashed or
# FullyKeyHashed, specify a key with F-Ticks-Key.
# F-Ticks-Key <key>
# Default F-Ticks configuration:
#F-Ticks-Reporting None
#F-Ticks-Mac FullyKeyHashed
# There is an option for doing some simple loop prevention. Note that # There is an option for doing some simple loop prevention. Note that
# the LoopPrevention directive can be used in server blocks too, # the LoopPrevention directive can be used in server blocks too,
# overriding what's set here in the basic settings. # overriding what's set here in the basic settings.
......
...@@ -33,6 +33,21 @@ ...@@ -33,6 +33,21 @@
#define RAD_DTLS 3 #define RAD_DTLS 3
#define RAD_PROTOCOUNT 4 #define RAD_PROTOCOUNT 4
enum rsp_fticks_reporting_type {
RSP_FTICKS_REPORTING_NONE = 0, /* Default. */
RSP_FTICKS_REPORTING_BASIC,
RSP_FTICKS_REPORTING_FULL
};
enum rsp_fticks_mac_type {
RSP_FTICKS_MAC_STATIC = 0, /* Default. */
RSP_FTICKS_MAC_ORIGINAL,
RSP_FTICKS_MAC_VENDOR_HASHED,
RSP_FTICKS_MAC_VENDOR_KEY_HASHED,
RSP_FTICKS_MAC_FULLY_HASHED,
RSP_FTICKS_MAC_FULLY_KEY_HASHED
};
struct options { struct options {
char *logdestination; char *logdestination;
char *ttlattr; char *ttlattr;
...@@ -40,6 +55,9 @@ struct options { ...@@ -40,6 +55,9 @@ struct options {
uint8_t addttl; uint8_t addttl;
uint8_t loglevel; uint8_t loglevel;
uint8_t loopprevention; uint8_t loopprevention;
enum rsp_fticks_reporting_type fticks_reporting;
enum rsp_fticks_mac_type fticks_mac;
char *fticks_key;
}; };
struct commonprotoopts { struct commonprotoopts {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment