ucmd_netip.c 487 B

123456789101112131415161718192021222324252627
  1. /* netip: ring-3 command. Show or set the IPv4 address. */
  2. #include "ucmd_lib.h"
  3. void _start(const char *arg)
  4. {
  5. unsigned char ip[4];
  6. if (!arg || !arg[0]) {
  7. u_syscall1(SYS_NET_GET_IP, (int)ip);
  8. u_put_ip(ip);
  9. u_putc('\n');
  10. u_exit(0);
  11. }
  12. if (u_parse_ip(arg, ip) != 0) {
  13. u_puts("netip: usage netip <a.b.c.d>\n");
  14. u_exit(1);
  15. }
  16. u_syscall1(SYS_NET_SET_IP, (int)ip);
  17. u_puts("ip set to ");
  18. u_syscall1(SYS_NET_GET_IP, (int)ip);
  19. u_put_ip(ip);
  20. u_putc('\n');
  21. u_exit(0);
  22. }