⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udp.h

📁 STR912 arm9实现的以太网通信程序
💻 H
字号:
#include "uipopt.h"

struct uip_udp_conn {
  u16_t ripaddr[2];   
  u16_t lport;      
  u16_t rport;        
};

struct uip_eth_addr {
  u8_t addr[6];
};

struct uip_eth_hdr{
  struct uip_eth_addr dest;
  struct uip_eth_addr src;
  u16_t type;
};

struct arp_hdr {
  struct uip_eth_hdr ethhdr;
  u16_t hwtype;
  u16_t protocol;
  u8_t hwlen;
  u8_t protolen;
  u16_t opcode;
  struct uip_eth_addr shwaddr;
  u16_t sipaddr[2];
  struct uip_eth_addr dhwaddr;
  u16_t dipaddr[2];
};

struct ethip_hdr {
  struct uip_eth_hdr ethhdr;
  u8_t vhl,
    tos,
    len[2],
    ipid[2],
    ipoffset[2],
    ttl,
    proto;
  u16_t ipchksum;
  u16_t srcipaddr[2],
    destipaddr[2];
};

struct uip_udpip_hdr{
  /* IP header. */
  u8_t vhl,
    tos,
    len[2],
    ipid[2],
    ipoffset[2],
    ttl,
    proto;
  u16_t ipchksum;
  u16_t srcipaddr[2],
    destipaddr[2];

  /* UDP header. */
  u16_t srcport,
    destport;
  u16_t udplen;
  u16_t udpchksum;
};

struct uip_icmpip_hdr{
  /* IP header. */
  u8_t vhl,
    tos,
    len[2],
    ipid[2],
    ipoffset[2],
    ttl,
    proto;
  u16_t ipchksum;
  u16_t srcipaddr[2],
    destipaddr[2];
  /* ICMP (echo) header. */
  u8_t type, icode;
  u16_t icmpchksum;
  u16_t id, seqno;
};

struct arp_entry {
  u16_t ipaddr[2];
  struct uip_eth_addr ethaddr;
  u8_t time;
};
#define UDP_DATA 1
#define UIP_UDP_TIMER 3
#define UIP_PROTO_UDP   17
#define UIP_PROTO_ICMP  1
#define UIP_ETHTYPE_ARP 0x0806
#define UIP_ETHTYPE_IP  0x0800
#define UIP_ETHTYPE_IP6 0x86dd
#define UDPDATA ((u8_t *)&uip_buf[UIP_LLH_LEN + 20 + 8])	
void udp_process(void);

void udp_init(void);

struct uip_udp_conn *uip_udp_new(u16_t *ripaddr, u16_t rport);

u16_t uip_chksum(u16_t *buf, u16_t len);

void udp_appcall(void);

u16_t uip_ipchksum(void);

u16_t htons(u16_t val);

void uip_arp_init(void);

void uip_arp_arpin(void);

void uip_arp_ipin(void);

void uip_arp_out(void);

void uip_arp_timer(void);

void uip_udp_periodic(void);

#define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0];\
                              uip_ethaddr.addr[1] = eaddr.addr[1];\
                              uip_ethaddr.addr[2] = eaddr.addr[2];\
                              uip_ethaddr.addr[3] = eaddr.addr[3];\
                              uip_ethaddr.addr[4] = eaddr.addr[4];\
                              uip_ethaddr.addr[5] = eaddr.addr[5];} while(0)
#define UIP_POLL      8
#define UIP_NEWDATA   2  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -