ping.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef PING_H
  2. #define PING_H
  3. #include "wizchip_conf.h"
  4. #define BUF_LEN 32
  5. #define PING_REQUEST 8
  6. #define PING_REPLY 0
  7. #define CODE_ZERO 0
  8. #define SOCKET_ERROR 1
  9. #define TIMEOUT_ERROR 2
  10. #define PING_SUCCESS 3
  11. #define REPLY_ERROR 4
  12. #define FUNCTION_ERROR 5
  13. #define PING_DEBUG
  14. typedef struct pingmsg {
  15. uint8_t Type; // 0 - Ping Reply, 8 - Ping Request
  16. uint8_t Code; // Always 0
  17. int16_t CheckSum; // Check sum
  18. int16_t ID; // Identification
  19. int16_t SeqNum; // Sequence Number
  20. int8_t Data[BUF_LEN]; // Ping Data : 1452 = IP RAW MTU - sizeof(Type+Code+CheckSum+ID+SeqNum)
  21. } PINGMSGR;
  22. uint8_t ping_auto(uint8_t s, uint8_t* addr);
  23. uint8_t ping_count(uint8_t s, uint16_t pCount, uint8_t* addr);
  24. uint8_t ping_request(uint8_t s, uint8_t* addr);
  25. uint8_t ping_reply(uint8_t s, uint8_t* addr, uint16_t rlen);
  26. uint16_t checksum(uint8_t* data_buf, uint16_t len);
  27. uint16_t htons(
  28. uint16_t
  29. hostshort); /* htons function converts a unsigned short from host to TCP/IP network byte order (which is big-endian).*/
  30. void eth_printf(const char* format, ...);
  31. #endif /* PING_H */