net.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* Minimal network stack: ARP + ICMP echo (ping) over the NE2000 driver.
  2. Parsing, decoding, reply generation, and the card's IPv4 address. */
  3. #ifndef NET_H
  4. #define NET_H
  5. /* Ethernet ethertypes. */
  6. #define ET_IPV4 0x0800
  7. #define ET_ARP 0x0806
  8. #define ET_IPV6 0x86DD
  9. /* IPv4 protocol numbers. */
  10. #define IPPROTO_ICMP 1
  11. #define IPPROTO_UDP 17
  12. #define IPPROTO_TCP 6
  13. /* ICMP message types. */
  14. #define ICMP_ECHO_REPLY 0
  15. #define ICMP_ECHO_REQUEST 8
  16. void net_set_ip(const unsigned char ip[4]);
  17. void net_get_ip(unsigned char ip[4]);
  18. int net_parse_ip(const char *s, unsigned char ip[4]); /* 0 on success, -1 on error */
  19. void net_print_ip(void);
  20. const char *net_ethertype_name(unsigned short et);
  21. /* Print one decoded frame summary line (dst/src/ethertype + ARP/IP/ICMP). */
  22. void net_decode_frame(const unsigned char *frame, unsigned int len);
  23. /* Build a reply to an ARP request or ICMP echo request addressed to us.
  24. Returns reply length (> 0) or 0 if the frame needs no reply. */
  25. int net_build_reply(const unsigned char *frame, unsigned int len,
  26. unsigned char *out, unsigned int maxout);
  27. #endif