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

📄 web.i

📁 凌阳单片机之以太网通讯模组模组
💻 I
📖 第 1 页 / 共 2 页
字号:

 

 

 



 
struct netif {
   
  struct netif *next;
   

  
   
  struct ip_addr ip_addr;
  struct ip_addr netmask;
  struct ip_addr gw;

   

  err_t (* input)(struct pbuf *p, struct netif *inp);
   


  err_t (* output)(struct netif *netif, struct pbuf *p,
		   struct ip_addr *ipaddr);
   


  err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
   

  void *state;




   
  unsigned char hwaddr_len;
   
  unsigned char hwaddr[3U ];
   
  u16_t mtu;
   
  char name[2];
   
  u8_t num;
   
  u8_t flags;
};

 
extern struct netif *netif_list;
 
extern struct netif *netif_default;

 
void netif_init(void);

struct netif *netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
			struct ip_addr *gw,
			void *state,
			err_t (* init)(struct netif *netif),
			err_t (* input)(struct pbuf *p, struct netif *netif));

void
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
	  struct ip_addr *gw);
void netif_remove(struct netif * netif);

 



struct netif *netif_find(char *name);

void netif_set_default(struct netif *netif);

void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
void netif_set_netmask(struct netif *netif, struct ip_addr *netmast);
void netif_set_gw(struct netif *netif, struct ip_addr *gw);


# 58 "..\\unip\\include\\lwipopts.h" 2

# 1 "..\\unip\\include\\lwip\\tcp.h" 1
 

































# 1 "..\\unip\\include\\lwip\\sys.h" 1
 








































 

typedef u8_t sys_sem_t;
typedef u8_t sys_mbox_t;
struct sys_timeout {u8_t dummy;};















# 131 "..\\unip\\include\\lwip\\sys.h"


 
 




 




# 174 "..\\unip\\include\\lwip\\sys.h"











# 35 "..\\unip\\include\\lwip\\tcp.h" 2





# 1 "..\\unip\\include\\lwip\\ip.h" 1
 









































struct netif;

void ip_init(void);
u8_t ip_lookup(void *header, struct netif *inp);
struct netif *ip_route(struct ip_addr *dest);
err_t ip_input(struct pbuf *p, struct netif *inp);
err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
		u8_t ttl, u8_t proto);
err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
		   u8_t ttl, u8_t proto,
		   struct netif *netif);








 










 
struct ip_hdr {
   
   u16_t _v_hl_tos  __attribute__((packed)) ;
   
   u16_t _len  __attribute__((packed)) ;
   
   u16_t _id  __attribute__((packed)) ;
   
   u16_t _offset  __attribute__((packed)) ;




   
   u16_t _ttl_proto  __attribute__((packed)) ;
   
   u16_t _chksum  __attribute__((packed)) ;
   
   struct ip_addr src  __attribute__((packed)) ;
   struct ip_addr dest  __attribute__((packed)) ; 
} __attribute__((packed)) ;
 





























# 40 "..\\unip\\include\\lwip\\tcp.h" 2

# 1 "..\\unip\\include\\lwip\\icmp.h" 1
 




















































enum icmp_dur_type {
  ICMP_DUR_NET = 0,     
  ICMP_DUR_HOST = 1,    
  ICMP_DUR_PROTO = 2,   
  ICMP_DUR_PORT = 3,    
  ICMP_DUR_FRAG = 4,    
  ICMP_DUR_SR = 5       
};

enum icmp_te_type {
  ICMP_TE_TTL = 0,      
  ICMP_TE_FRAG = 1      
};

void icmp_input(struct pbuf *p, struct netif *inp);

void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);




 
struct icmp_echo_hdr {
   u16_t _type_code  __attribute__((packed)) ;
   u16_t chksum  __attribute__((packed)) ;
   u16_t id  __attribute__((packed)) ;
   u16_t seqno  __attribute__((packed)) ;
} __attribute__((packed)) ;
 

 
struct icmp_dur_hdr {
   u16_t _type_code  __attribute__((packed)) ;
   u16_t chksum  __attribute__((packed)) ;
   u32_t unused  __attribute__((packed)) ;
} __attribute__((packed)) ;
 

 
struct icmp_te_hdr {
   u16_t _type_code  __attribute__((packed)) ;
   u16_t chksum  __attribute__((packed)) ;
   u32_t unused  __attribute__((packed)) ;
} __attribute__((packed)) ;
 











	  
# 41 "..\\unip\\include\\lwip\\tcp.h" 2






struct tcp_pcb;

 

 
void             tcp_init    (void);   

void             tcp_tmr     (void);   


 
struct tcp_pcb * tcp_new     (void);
struct tcp_pcb * tcp_alloc   (u8_t prio);

void             tcp_arg     (struct tcp_pcb *pcb, void *arg);
void             tcp_accept  (struct tcp_pcb *pcb,
			      err_t (* accept)(void *arg, struct tcp_pcb *newpcb,
					       err_t err));
void             tcp_recv    (struct tcp_pcb *pcb,
			      err_t (* recv)(void *arg, struct tcp_pcb *tpcb,
				  struct pbuf *p, err_t err));
void             tcp_sent    (struct tcp_pcb *pcb,
			      err_t (* sent)(void *arg, struct tcp_pcb *tpcb,
					     u16_t len));
void             tcp_poll    (struct tcp_pcb *pcb,
			      err_t (* poll)(void *arg, struct tcp_pcb *tpcb),
			      u8_t interval);
void             tcp_err     (struct tcp_pcb *pcb,
			      void (* err)(void *arg, err_t err));




void             tcp_recved  (struct tcp_pcb *pcb, u16_t len);
err_t            tcp_bind    (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
			      u16_t port);
err_t            tcp_connect (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
			      u16_t port, err_t (* connected)(void *arg,
							      struct tcp_pcb *tpcb,
							      err_t err));
struct tcp_pcb * tcp_listen  (struct tcp_pcb *pcb);
void             tcp_abort   (struct tcp_pcb *pcb);
err_t            tcp_close   (struct tcp_pcb *pcb);
err_t            tcp_write   (struct tcp_pcb *pcb, const void *dataptr, u16_t len,
			      u8_t copy);

void             tcp_setprio (struct tcp_pcb *pcb, u8_t prio);





 

void             tcp_slowtmr (void);
void             tcp_fasttmr (void);


 
void             tcp_input   (struct pbuf *p, struct netif *inp);
 
err_t            tcp_output  (struct tcp_pcb *pcb);
void             tcp_rexmit  (struct tcp_pcb *pcb);

















 



























 
struct tcp_hdr {
   u16_t src  __attribute__((packed)) ;
   u16_t dest  __attribute__((packed)) ;
   u32_t seqno  __attribute__((packed)) ;
   u32_t ackno  __attribute__((packed)) ;
   u16_t _offset_flags  __attribute__((packed)) ;
   u16_t wnd  __attribute__((packed)) ;
   u16_t chksum  __attribute__((packed)) ;
   u16_t urgp  __attribute__((packed)) ;
} __attribute__((packed)) ;
 













enum tcp_state {
  CLOSED      = 0,
  LISTEN      = 1,
  SYN_SENT    = 2,
  SYN_RCVD    = 3,
  ESTABLISHED = 4,
  FIN_WAIT_1  = 5,
  FIN_WAIT_2  = 6,
  CLOSE_WAIT  = 7,
  CLOSING     = 8,
  LAST_ACK    = 9,
  TIME_WAIT   = 10
};


 
struct tcp_pcb {
  struct tcp_pcb *next;    
  u8_t prio;
  void *callback_arg;

  struct ip_addr local_ip;
  u16_t local_port;
  enum tcp_state state;    
  
  struct ip_addr remote_ip;
  u16_t remote_port;
  
   
  u32_t rcv_nxt;    
  u16_t rcv_wnd;    
  
   
  u32_t tmr;
  u8_t polltmr, pollinterval;
  
   
  u16_t rtime;
  
  u16_t mss;    

  u8_t flags;






  
   
  u16_t rttest;  
  u32_t rtseq;   
  s16_t sa, sv;

  u16_t rto;     
  u8_t nrtx;     

   
  u32_t lastack;  
  u8_t dupacks;
  
   
  u16_t cwnd;  
  u16_t ssthresh;

   
  u32_t snd_nxt,        
    snd_max,        
    snd_wnd,        
    snd_wl1, snd_wl2,  

    snd_lbb;        

  u16_t acked;
  
  u16_t snd_buf;    
  u8_t snd_queuelen;  
  
  
   
  struct tcp_seg *unsent;    
  struct tcp_seg *unacked;   

  struct tcp_seg *ooseq;     



   
  err_t (* sent)(void *arg, struct tcp_pcb *pcb, u16_t space);
  
   
  err_t (* recv)(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);

   
  err_t (* connected)(void *arg, struct tcp_pcb *pcb, err_t err);

   
  err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err);

   
  err_t (* poll)(void *arg, struct tcp_pcb *pcb);

   
  void (* errf)(void *arg, err_t err);

};

struct tcp_pcb_listen {  
  struct tcp_pcb_listen *next;    
  u8_t prio;
  void *callback_arg;
  
  struct ip_addr local_ip;
  u16_t local_port; 
   


 
  enum tcp_state state;    


   
  err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err);

};

# 335 "..\\unip\\include\\lwip\\tcp.h"






















 
struct tcp_seg {
  struct tcp_seg *next;     
  struct pbuf *p;           
  void *dataptr;            
  u16_t len;                
  struct tcp_hdr *tcphdr;   
};

 
struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb);
void tcp_pcb_purge(struct tcp_pcb *pcb);
void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb);

u8_t tcp_segs_free(struct tcp_seg *seg);
u8_t tcp_seg_free(struct tcp_seg *seg);
struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg);












err_t tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags);
err_t tcp_enqueue(struct tcp_pcb *pcb, void *dataptr, u16_t len,
		u8_t flags, u8_t copy,
                u8_t *optdata, u8_t optlen);

void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);

void tcp_rst(u32_t seqno, u32_t ackno,
	     struct ip_addr *local_ip, struct ip_addr *remote_ip,
	     u16_t local_port, u16_t remote_port);

u32_t tcp_next_iss(void);

extern struct tcp_pcb *tcp_input_pcb;
extern u32_t tcp_ticks;

















 
extern struct tcp_pcb_listen *tcp_listen_pcbs;   
extern struct tcp_pcb *tcp_active_pcbs;   


extern struct tcp_pcb *tcp_tw_pcbs;       

extern struct tcp_pcb *tcp_tmp_pcb;       

 






 

# 467 "..\\unip\\include\\lwip\\tcp.h"







# 484 "..\\unip\\include\\lwip\\tcp.h"


extern  u16_t tcp_mss  ;
extern  u16_t tcp_window  ;
extern  u16_t tcp_maxrtx  ;
extern  u16_t tcp_synmaxrtx  ;





# 59 "..\\unip\\include\\lwipopts.h" 2

# 1 "..\\unip\\include\\lwip\\udp.h" 1
 











































struct udp_hdr {
   u16_t src  __attribute__((packed)) ;
   u16_t dest  __attribute__((packed)) ;   
   u16_t len  __attribute__((packed)) ;
   u16_t chksum  __attribute__((packed)) ;
} __attribute__((packed)) ;





struct udp_pcb {
  struct udp_pcb *next;

  struct ip_addr local_ip, remote_ip;
  u16_t local_port, remote_port;
  
  u8_t flags;
  u16_t chksum_len;
  
  void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
		struct ip_addr *addr, u16_t port);
  void *recv_arg;  
};

 

struct udp_pcb * udp_new        (void);
void             udp_remove     (struct udp_pcb *pcb);
err_t            udp_bind       (struct udp_pcb *pcb, struct ip_addr *ipaddr,
                 u16_t port);
err_t            udp_connect    (struct udp_pcb *pcb, struct ip_addr *ipaddr,
                 u16_t port);
void             udp_disconnect    (struct udp_pcb *pcb);
void             udp_recv       (struct udp_pcb *pcb,
				 void (* recv)(void *arg, struct udp_pcb *upcb,
					       struct pbuf *p,
					       struct ip_addr *addr,
					       u16_t port),
				 void *recv_arg);
err_t            udp_send       (struct udp_pcb *pcb, struct pbuf *p);





 
u8_t             udp_lookup     (struct ip_hdr *iphdr, struct netif *inp);
void             udp_input      (struct pbuf *p, struct netif *inp);
void             udp_init       (void);





# 60 "..\\unip\\include\\lwipopts.h" 2




# 1 "..\\unip\\include\\lwip\\memp.h" 1
 




































typedef enum {
  MEMP_PBUF,




  MEMP_TCP_PCB,
  MEMP_TCP_PCB_LISTEN,
  MEMP_TCP_SEG,









  MEMP_MAX
} memp_t;

struct memp {
  struct memp *next;
};

void memp_init(void);

void *memp_malloc(memp_t type);
void *memp_realloc(memp_t fromtype, memp_t totype, void *mem);
void memp_free(memp_t type, void *mem);

void *memp_mallocp(memp_t type);
void memp_freep(memp_t type, void *mem);



# 93 "..\\unip\\include\\lwip\\memp.h"

extern u16_t memp_num[];
















extern  u8_t memp_memory [] ;
# 146 "..\\unip\\include\\lwip\\memp.h"
					
					
extern  pbuf_num  ;
extern  udp_num  ;
extern  tcp_num  ;
extern  ltcp_num  ;
extern  tcp_seg_num  ;




	  
# 64 "..\\unip\\include\\lwipopts.h" 2

# 1 "..\\unip\\include\\lwip\\stats.h" 1
 









































struct stats_proto {
  u16_t xmit;     
  u16_t rexmit;   
  u16_t recv;     
  


  u16_t drop;     
  u16_t chkerr;   
  u16_t lenerr;   
  u16_t memerr;   
  u16_t rterr;    
  u16_t proterr;  
  u16_t opterr;   
  u16_t err;      
  


};

struct stats_mem {
  mem_size_t avail;
  mem_size_t used;
  mem_size_t max;  
  mem_size_t err;
};

struct stats_pbuf {
  u16_t avail;
  u16_t used;
  u16_t max;  
  u16_t err;
  u16_t alloc_locked;
  u16_t refresh_locked;
};

struct stats_syselem {
  u16_t used;
  u16_t max;
  u16_t err;
};

struct stats_sys {
  struct stats_syselem sem;
  struct stats_syselem mbox;
};

# 115 "..\\unip\\include\\lwip\\stats.h"


struct stats_ {
  


  
  


  
  



  struct stats_proto icmp;
  
  


  
  
  struct stats_proto tcp;
  
  struct stats_pbuf pbuf;
  struct stats_mem mem;
  struct stats_mem memp[MEMP_MAX];
  



};

 
extern  struct stats_ lwip_stats  ;
 

void stats_init(void);









# 65 "..\\unip\\include\\lwipopts.h" 2



# 1 "..\\unip\\include\\netif\\etharp.h" 1
 










































 
struct eth_addr {
  
 u16_t addr[3];
} __attribute__((packed)) ;
 

 
struct eth_hdr {
   struct eth_addr dest  __attribute__((packed)) ;
   struct eth_addr src  __attribute__((packed)) ;
   u16_t type  __attribute__((packed)) ;
} __attribute__((packed)) ;
 

 
 
struct etharp_hdr {
   struct eth_hdr ethhdr  __attribute__((packed)) ;
   u16_t hwtype  __attribute__((packed)) ;
   u16_t proto  __attribute__((packed)) ;
   u16_t _hwlen_protolen  __attribute__((packed)) ;
   u16_t opcode  __attribute__((packed)) ;
   struct eth_addr shwaddr  __attribute__((packed)) ;
   struct ip_addr sipaddr  __attribute__((packed)) ;
   struct eth_addr dhwaddr  __attribute__((packed)) ;
   struct ip_addr dipaddr  __attribute__((packed)) ;
} __attribute__((packed)) ;
 

 
struct ethip_hdr {
   struct eth_hdr eth  __attribute__((packed)) ;
   struct ip_hdr ip  __attribute__((packed)) ;
};









enum etharp_state {
  ETHARP_STATE_EMPTY,
  ETHARP_STATE_PENDING,
  ETHARP_STATE_STABLE
};

struct etharp_entry {
  struct ip_addr ipaddr;
  struct eth_addr ethaddr;
  enum etharp_state state;
 
  struct pbuf *p;
 
  u8_t ctime;
};

void etharp_init(void);
void etharp_tmr(void);
struct pbuf *etharp_ip_input(struct netif *netif, struct pbuf *p);
struct pbuf *etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
			   struct pbuf *p);
struct pbuf *etharp_output(struct netif *netif, struct ip_addr *ipaddr,
			   struct pbuf *q);
err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
struct eth_addr * etharp_lookup(struct ip_addr *ipaddr);


extern  struct etharp_entry arp_table [] ;
extern  u16_t arp_num  ;



# 68 "..\\unip\\include\\lwipopts.h" 2





# 1 "..\\unip\\include\\unsp\\include\\ethernet.h" 1
 
err_t ethernetif_init(struct netif *netif);
void etharp_timer(void *arg);
# 73 "..\\unip\\include\\lwipopts.h" 2




# 21 "..\\code\\include\\config.h" 2















# 10 "G:/\301\350\321\364\265\245\306\254\273\372/\320\302\275\250\316\304\274\376\274\320/9.\304\243\327\351\327\312\301\317/\322\324\314\253\315\370\315\250\321\266\304\243\327\351/\322\324\314\253\315\370DemoCode/DemoCode/code/Web.c" 2

# 1 "..\\code\\include\\httpd.h" 1
 

































void httpd_init(void);




struct webdata {
	 struct webdata *next;
     u16_t *payload;
     u16_t offset;
     u16_t len;
     u16_t attr;
     };

struct http_state {	
  struct webdata *web;
  u8_t  retries;
};



# 11 "G:/\301\350\321\364\265\245\306\254\273\372/\320\302\275\250\316\304\274\376\274\320/9.\304\243\327\351\327\312\301\317/\322\324\314\253\315\370\315\250\321\266\304\243\327\351/\322\324\314\253\315\370DemoCode/DemoCode/code/Web.c" 2

# 1 "..\\code\\include\\web.h" 1


 
# 1 "..\\code\\include\\fs.h" 1
 

































struct fs_file {
  unsigned int *data;
  int len;
};




 

int fs_open(char *name, struct fs_file *file);


# 4 "..\\code\\include\\web.h" 2

struct CGI_StaS{
   
  u16_t Hour;
  u16_t Min;
  u16_t Sec;
  u16_t* Input;
  u16_t* Output;
};

void    web_free(struct webdata *head);
struct  webdata  *Web_Init(struct fs_file *file,u16_t opt);
err_t   web_head_alloc(struct webdata *headw, struct webdata *web);
struct  webdata *Web_Request(char *req);


# 12 "G:/\301\350\321\364\265\245\306\254\273\372/\320\302\275\250\316\304\274\376\274\320/9.\304\243\327\351\327\312\301\317/\322\324\314\253\315\370\315\250\321\266\304\243\327\351/\322\324\314\253\315\370DemoCode/DemoCode/code/Web.c" 2



char s_open[] = "@开";
char s_close[] = "@关";

u16_t status[3] = {0,0,0};







struct webdata *Web_Request(char *req)
{
struct fs_file file;
char *tempstr = req;
struct webdata *tempweb,*retweb;
u16_t cur_dev = 0,device;
u16_t opt,oprate;
if (!(strcmp(tempstr, "/index.html")  && strcmp(tempstr, "/")))    
{
tempstr += strlen(tempstr) + 1;						  
   if (!strcmp(tempstr,"PD"))
    {
      tempstr += strlen(tempstr)+1;
      if (!strcmp(tempstr,"123456"))
        {
        fs_open("/opt.html", &file);
        retweb = Web_Init(&file,1);
        goto init0;
        }
        else 
          {
           fs_open("/err.htm",&file);
           retweb = Web_Init(&file,0); 
           }
         return(retweb);  
    }
    else if('H' == *tempstr)    
      {
       fs_open("/index.html",&file);
       return(Web_Init(&file,0)); 
       }
    else   
    { 
     fs_open("/invalid.htm",&file);
     return(Web_Init(&file,0));
    }
}
else if(!strcmp(tempstr, "/opt.html"))  
  {
   fs_open("/opt.html", &file);
   retweb = Web_Init(&file,1);
   tempstr += strlen(tempstr)+1;
   opt = StrToInt(tempstr);
   if (opt%2) oprate = (u16_t)s_close[0];
   else oprate = (u16_t)s_open[0];
   switch (opt)
   {
   case 10: ;
   case 11:device = 0 ; break;
   case 12: ;
   case 13:device = 1 ; break;
   case 14: ;
   case 15:device = 2 ; break;
   }
   status[device] = oprate;
   
   
init0:   
  for(tempweb = retweb ; tempweb!= ((void *)0) ; tempweb = tempweb->next)
   {
    if (tempweb->attr == 0x00U  )    
    {  
    if (status[cur_dev]!=0)
       tempweb->payload[0] = status[cur_dev];
       else tempweb->payload[0] = (u16_t)s_close[0];
       tempweb->len = 2;     
         cur_dev++;    
    }
   } 
   return(retweb);
   }
else 
  {
    	fs_open(tempstr,&file);
    	if( file.data == ((void *)0) )
    	   fs_open("/404.html", &file);  
    	return(Web_Init(&file,0));
    	} 
  return(((void *)0) );   
}

⌨️ 快捷键说明

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