ucmd_netsend.c 913 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* netsend: ring-3 command. Broadcast a 64-byte test frame. */
  2. #include "ucmd_lib.h"
  3. void _start(const char *arg)
  4. {
  5. unsigned char frame[64], mac[6];
  6. unsigned int i;
  7. (void)arg;
  8. if (u_syscall1(SYS_NET_MAC, (int)mac) != 0) {
  9. u_puts("netsend: no NIC found\n");
  10. u_exit(1);
  11. }
  12. /* dst=ff:ff:ff:ff:ff:ff, src=our MAC, ethertype 0x88B5 (local
  13. * experimental), payload "NEBS". */
  14. for (i = 0; i < 6; i++)
  15. frame[i] = 0xFF;
  16. for (i = 0; i < 6; i++)
  17. frame[6 + i] = mac[i];
  18. frame[12] = 0x88;
  19. frame[13] = 0xB5;
  20. frame[14] = 'N';
  21. frame[15] = 'E';
  22. frame[16] = 'B';
  23. frame[17] = 'S';
  24. for (i = 18; i < 64; i++)
  25. frame[i] = 0x00;
  26. u_syscall0(SYS_NET_ACQUIRE);
  27. if (u_syscall2(SYS_NET_TX, (int)frame, sizeof(frame)) != 0) {
  28. u_puts("netsend: transmit failed\n");
  29. u_syscall0(SYS_NET_RELEASE);
  30. u_exit(1);
  31. }
  32. u_syscall0(SYS_NET_RELEASE);
  33. u_puts("netsend: sent 64-byte broadcast frame\n");
  34. u_exit(0);
  35. }