aboutsummaryrefslogtreecommitdiff
path: root/eperd/ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'eperd/ping.c')
-rw-r--r--eperd/ping.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/eperd/ping.c b/eperd/ping.c
index 3f03bf8..583d512 100644
--- a/eperd/ping.c
+++ b/eperd/ping.c
@@ -26,7 +26,7 @@
#define DBQ(str) "\"" #str "\""
-#define PING_OPT_STRING ("!46rc:s:A:O:i:I:R:W:")
+#define PING_OPT_STRING ("!46rc:s:A:B:O:i:I:R:W:")
enum
{
@@ -94,6 +94,7 @@ struct pingstate
{
/* Parameters */
char *atlas;
+ char *bundle_id;
char *hostname;
char *interface;
int pingcount;
@@ -222,6 +223,8 @@ static void report(struct pingstate *state)
", " DBQ(time) ":%ld, ",
state->atlas, get_atlas_fw_version(), get_timesync(),
(long)time(NULL));
+ if (state->bundle_id)
+ fprintf(fh, DBQ(bundle) ":%s, ", state->bundle_id);
}
fprintf(fh, DBQ(dst_name) ":" DBQ(%s),
@@ -1097,6 +1100,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[],
sa_family_t af;
const char *hostname;
char *str_Atlas;
+ char *str_bundle;
char *out_filename;
char *interface;
char *response_in, *response_out;
@@ -1143,6 +1147,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[],
pingcount= 3;
size= 0;
str_Atlas= NULL;
+ str_bundle= NULL;
out_filename= NULL;
interval= DEFAULT_PING_INTERVAL;
interface= NULL;
@@ -1151,7 +1156,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[],
/* exactly one argument needed; -c NUM */
opt_complementary = "=1:c+:s+:i+";
opt = getopt32(argv, PING_OPT_STRING, &pingcount, &size,
- &str_Atlas, &out_filename, &interval, &interface,
+ &str_Atlas, &str_bundle, &out_filename, &interval, &interface,
&response_in, &response_out);
hostname = argv[optind];
@@ -1209,6 +1214,14 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[],
return NULL;
}
}
+ if (str_bundle)
+ {
+ if (!validate_atlas_id(str_bundle))
+ {
+ crondlog(LVL8 "bad bundle ID '%s'", str_bundle);
+ return NULL;
+ }
+ }
if (opt & opt_4)
af= AF_INET;
@@ -1254,7 +1267,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[],
state->af= af;
state->delay_name_res= delay_name_res;
state->interval= interval;
- state->interface= interface;
+ state->interface= interface ? strdup(interface) : NULL;
state->socket= -1;
state->response_in= response_in ? strdup(response_in) : NULL;
state->response_out= response_out ? strdup(response_out) : NULL;
@@ -1293,6 +1306,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[],
state->pingcount= pingcount;
state->atlas= str_Atlas ? strdup(str_Atlas) : NULL;
+ state->bundle_id= str_bundle ? strdup(str_bundle) : NULL;
state->hostname= strdup(hostname);
state->out_filename= out_filename ? strdup(out_filename) : NULL;
@@ -1599,6 +1613,10 @@ static int ping_delete(void *state)
free(pingstate->atlas);
pingstate->atlas= NULL;
+ free(pingstate->bundle_id);
+ pingstate->bundle_id= NULL;
+ free(pingstate->interface);
+ pingstate->interface= NULL;
free(pingstate->hostname);
pingstate->hostname= NULL;
free(pingstate->out_filename);