Commit 2e28582a authored by Alessandro Rubini's avatar Alessandro Rubini

syslog: add 'msg' subcommand

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent ae0d629c
...@@ -65,6 +65,6 @@ int check_dest_ip(unsigned char *buf); ...@@ -65,6 +65,6 @@ int check_dest_ip(unsigned char *buf);
void syslog_init(void); void syslog_init(void);
int syslog_poll(void); int syslog_poll(void);
void syslog_report(char *buf); void syslog_report(const char *buf);
#endif #endif
...@@ -32,6 +32,8 @@ void syslog_init(void) ...@@ -32,6 +32,8 @@ void syslog_init(void)
static int cmd_syslog(const char *args[]) static int cmd_syslog(const char *args[])
{ {
char b1[32], b2[32]; char b1[32], b2[32];
char *p;
int i;
if (args[0] && !strcmp(args[0], "off")) { if (args[0] && !strcmp(args[0], "off")) {
syslog_addr.daddr = 0; syslog_addr.daddr = 0;
...@@ -39,8 +41,19 @@ static int cmd_syslog(const char *args[]) ...@@ -39,8 +41,19 @@ static int cmd_syslog(const char *args[])
} }
if (!args[1]) { if (!args[1]) {
pp_printf("use: syslog <ipaddr> <macaddr> (or just \"off\"\n"); pp_printf("use: syslog <ipaddr> <macaddr> (or just \"off\"\n");
pp_printf(" or syslog msg ....\n");
return -1; return -1;
} }
if (!strcmp(args[0], "msg")) {
for (i = 0; args[i+1]; i++)
;
/* now, args[i] is the last argument; undo previous nulls */
for (p = (void *)args[i]; p > args[1]; p--) /* not "const"! */
if (*p == '\0')
*p = ' ';
syslog_report(args[1]);
return 0;
}
decode_ip(args[0], (void *)&syslog_addr.daddr); decode_ip(args[0], (void *)&syslog_addr.daddr);
decode_mac(args[1], syslog_mac); decode_mac(args[1], syslog_mac);
pp_printf("Syslog parameters: %s, %s\n", pp_printf("Syslog parameters: %s, %s\n",
...@@ -207,7 +220,7 @@ send: ...@@ -207,7 +220,7 @@ send:
} }
/* A report tool for others to call (used by ltest at least) */ /* A report tool for others to call (used by ltest at least) */
void syslog_report(char *msg) void syslog_report(const char *msg)
{ {
char buf[256]; char buf[256];
unsigned char ip[4]; unsigned char ip[4];
......
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