diff --git a/include/shell.h b/include/shell.h index 4d9ef7d30655cadb023631cda0b0a68e5880187e..7d804e5ea93f1a854f18fdb4890c4a59e6437573 100644 --- a/include/shell.h +++ b/include/shell.h @@ -14,6 +14,10 @@ extern int wrc_stat_running; const char *fromhex(const char *hex, int *v); const char *fromdec(const char *dec, int *v); +void decode_mac(const char *str, unsigned char *mac); +void print_mac(char *head, unsigned char *mac, char *tail); +void decode_ip(const char *str, unsigned char *ip); +void print_ip(char *head, unsigned char *ip, char *tail); struct wrc_shell_cmd { char *name; diff --git a/lib/ipv4.h b/lib/ipv4.h index 2c5a3dbe886327cc560a2ca270fb17136f412f2c..bc778a8b95df906089e76bc77b3314bdcc22e3e0 100644 --- a/lib/ipv4.h +++ b/lib/ipv4.h @@ -60,5 +60,7 @@ struct wr_udp_addr { void fill_udp(uint8_t * buf, int len, struct wr_udp_addr *uaddr); +void syslog_init(void); +void syslog_poll(void); #endif diff --git a/shell/cmd_ip.c b/shell/cmd_ip.c index a7167e2b019ebe36907dad66e0c842916cfa4f8f..732bd47b93c59eb453a5e4ab7849c0b08fee8db7 100644 --- a/shell/cmd_ip.c +++ b/shell/cmd_ip.c @@ -15,7 +15,7 @@ #include "shell.h" #include "../lib/ipv4.h" -static void decode_ip(const char *str, unsigned char *ip) +void decode_ip(const char *str, unsigned char *ip) { int i, x; @@ -28,6 +28,12 @@ static void decode_ip(const char *str, unsigned char *ip) } } +void print_ip(char *head, unsigned char *ip, char *tail) +{ + pp_printf("%s%d.%d.%d.%d%s", + head, ip[0], ip[1], ip[2], ip[3], tail); +} + static int cmd_ip(const char *args[]) { unsigned char ip[4]; @@ -44,8 +50,7 @@ static int cmd_ip(const char *args[]) if (needIP) { pp_printf("IP-address: in training\n"); } else { - pp_printf("IP-address: %d.%d.%d.%d\n", - ip[0], ip[1], ip[2], ip[3]); + print_ip("IP-address: ", ip, "\n"); } return 0; } diff --git a/shell/cmd_mac.c b/shell/cmd_mac.c index 8610b90929522bf0171d8e3aba6b8b180bfc3a56..f66e9a93c808efe657f0da22c5a56ce3940568ca 100644 --- a/shell/cmd_mac.c +++ b/shell/cmd_mac.c @@ -17,7 +17,7 @@ #include "endpoint.h" #include "../lib/ipv4.h" -static void decode_mac(const char *str, unsigned char *mac) +void decode_mac(const char *str, unsigned char *mac) { int i, x; @@ -30,6 +30,13 @@ static void decode_mac(const char *str, unsigned char *mac) } } +void print_mac(char *head, unsigned char *mac, char *tail) +{ + pp_printf("%s%02x:%02x:%02x:%02x:%02x:%02x%s", + head, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], tail); +} + + static int cmd_mac(const char *args[]) { unsigned char mac[6]; @@ -52,8 +59,7 @@ static int cmd_mac(const char *args[]) return -EINVAL; } - pp_printf("MAC-address: %02x:%02x:%02x:%02x:%02x:%02x\n", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + print_mac("MAC-address: ", mac, "\n"); return 0; }