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

📄 uip.lst

📁 我修改的可以用串口访问的webserver(51平台)
💻 LST
📖 第 1 页 / 共 5 页
字号:
 864   2                                      If the application wishes to send any data, this data should be
 865   2                                      put into the uip_appdata and the length of the data should be
 866   2                                      put into uip_len. If the application don't have any data to
 867   2                              send, uip_len must be set to 0. */
 868   2                              if(uip_flags & (UIP_NEWDATA | UIP_ACKDATA)) 
 869   2                              {
 870   3                                      UIP_APPCALL();
 871   3                                      
 872   3      appsend:
 873   3                                      if(uip_flags & UIP_ABORT) 
 874   3                                      {
 875   4                                              uip_conn->tcpstateflags = CLOSED;
 876   4                                              BUF->flags = TCP_RST | TCP_ACK;
 877   4                                              goto tcp_send_nodata;
 878   4                                      }
 879   3                                      
 880   3                                      if(uip_flags & UIP_CLOSE) 
 881   3                                      {
 882   4                                              uip_add_ack_nxt(1);
 883   4                                              uip_conn->tcpstateflags = FIN_WAIT_1 | UIP_OUTSTANDING;
 884   4                                              uip_conn->nrtx = 0;
 885   4                                              BUF->flags = TCP_FIN | TCP_ACK;
 886   4                                              goto tcp_send_nodata;   
 887   4                                      }
 888   3                                      
 889   3                                      /* If uip_len > 0, the application has data to be sent, in which
 890   3                                      case we set the UIP_OUTSTANDING flag in the connection
 891   3                                      structure. But we cannot send data if the application already
 892   3                                      has outstanding data. */
 893   3                                      if(uip_len > 0 &&
 894   3                                              !(uip_conn->tcpstateflags & UIP_OUTSTANDING)) {
 895   4                                              uip_conn->tcpstateflags |= UIP_OUTSTANDING;
 896   4                                              uip_conn->nrtx = 0;
 897   4                                              uip_add_ack_nxt(uip_len);
 898   4                                      } else {
 899   4                                              uip_len = 0;
 900   4                                      }
 901   3      apprexmit:
 902   3                                      /* If the application has data to be sent, or if the incoming
 903   3                                      packet had new data in it, we must send out a packet. */
 904   3                                      if(uip_len > 0 || (uip_flags & UIP_NEWDATA)) {
 905   4                                              /* Add the length of the IP and TCP headers. */
 906   4                                              uip_len = uip_len + 40;
 907   4                                              /* We always set the ACK flag in response packets. */
 908   4                                              BUF->flags = TCP_ACK;
 909   4                                              /* Send the packet. */
 910   4                                              goto tcp_send_noopts;
 911   4                                      }
 912   3                              }
 913   2                              goto drop;
 914   2                      case LAST_ACK:
 915   2                      /* We can close this connection if the peer has acknowledged our
 916   2                              FIN. This is indicated by the UIP_ACKDATA flag. */     
 917   2                              if(uip_flags & UIP_ACKDATA) {
 918   3                                      uip_conn->tcpstateflags = CLOSED;
 919   3                              }
 920   2                              break;
 921   2                              
 922   2                      case FIN_WAIT_1:
 923   2                      /* The application has closed the connection, but the remote host
C51 COMPILER V7.10   UIP                                                                   09/03/2004 09:33:15 PAGE 16  

 924   2                      hasn't closed its end yet. Thus we do nothing but wait for a
 925   2                              FIN from the other side. */
 926   2                              if(uip_len > 0) {
 927   3                                      uip_add_rcv_nxt(uip_len);
 928   3                              }
 929   2                              if(BUF->flags & TCP_FIN) {
 930   3                                      if(uip_flags & UIP_ACKDATA) {
 931   4                                              uip_conn->tcpstateflags = TIME_WAIT;
 932   4                                              uip_conn->timer = 0;
 933   4                                      } else {
 934   4                                              uip_conn->tcpstateflags = CLOSING | UIP_OUTSTANDING;
 935   4                                      }
 936   3                                      uip_add_rcv_nxt(1);
 937   3                                      goto tcp_send_ack;
 938   3                              } else if(uip_flags & UIP_ACKDATA) {
 939   3                                      uip_conn->tcpstateflags = FIN_WAIT_2;
 940   3                                      goto drop;
 941   3                              }
 942   2                              if(uip_len > 0) {
 943   3                                      goto tcp_send_ack;
 944   3                              }
 945   2                              goto drop;
 946   2                              
 947   2                      case FIN_WAIT_2:
 948   2                              if(uip_len > 0) {
 949   3                                      uip_add_rcv_nxt(uip_len);
 950   3                              }
 951   2                              if(BUF->flags & TCP_FIN) {
 952   3                                      uip_conn->tcpstateflags = TIME_WAIT;
 953   3                                      uip_conn->timer = 0;
 954   3                                      uip_add_rcv_nxt(1);
 955   3                                      goto tcp_send_ack;
 956   3                              }
 957   2                              if(uip_len > 0) {
 958   3                                      goto tcp_send_ack;
 959   3                              }
 960   2                              goto drop;
 961   2                              
 962   2                      case TIME_WAIT:
 963   2                              goto tcp_send_ack;
 964   2                              
 965   2                      case CLOSING:
 966   2                              if(uip_flags & UIP_ACKDATA) {
 967   3                                      uip_conn->tcpstateflags = TIME_WAIT;
 968   3                                      uip_conn->timer = 0;
 969   3                      }
 970   2              }  
 971   1              goto drop;
 972   1        
 973   1        
 974   1        /* We jump here when we are ready to send the packet, and just want
 975   1        to set the appropriate TCP sequence numbers in the TCP header. */
 976   1      tcp_send_ack:
 977   1              BUF->flags = TCP_ACK;
 978   1      tcp_send_nodata:
 979   1              uip_len = 40;
 980   1      tcp_send_noopts:
 981   1              BUF->tcpoffset = 5 << 4;
 982   1      
 983   1      tcp_send:
 984   1      /* We're done with the input processing. We are now ready to send a
 985   1      reply. Our job is to fill in all the fields of the TCP and IP
C51 COMPILER V7.10   UIP                                                                   09/03/2004 09:33:15 PAGE 17  

 986   1      headers before calculating the checksum and finally send the
 987   1        packet. */    
 988   1              BUF->ackno[0] = uip_conn->rcv_nxt[0];
 989   1              BUF->ackno[1] = uip_conn->rcv_nxt[1];
 990   1              BUF->ackno[2] = uip_conn->rcv_nxt[2];
 991   1              BUF->ackno[3] = uip_conn->rcv_nxt[3];
 992   1      
 993   1              BUF->seqno[0] = uip_conn->snd_nxt[0];
 994   1              BUF->seqno[1] = uip_conn->snd_nxt[1];
 995   1              BUF->seqno[2] = uip_conn->snd_nxt[2];
 996   1              BUF->seqno[3] = uip_conn->snd_nxt[3];
 997   1      
 998   1              BUF->srcport  = uip_conn->lport;
 999   1              BUF->destport = uip_conn->rport;
1000   1        
1001   1      #if BYTE_ORDER == BIG_ENDIAN  
1002   1              BUF->srcipaddr[0] = ((UIP_IPADDR0 << 8) | UIP_IPADDR1);
1003   1              BUF->srcipaddr[1] = ((UIP_IPADDR2 << 8) | UIP_IPADDR3);
1004   1      #else
                      BUF->srcipaddr[0] = ((UIP_IPADDR1 << 8) | UIP_IPADDR0);
                      BUF->srcipaddr[1] = ((UIP_IPADDR3 << 8) | UIP_IPADDR2);
              #endif /* BYTE_ORDER == BIG_ENDIAN */
1008   1        
1009   1              BUF->destipaddr[0] = uip_conn->ripaddr[0];
1010   1              BUF->destipaddr[1] = uip_conn->ripaddr[1];
1011   1        
1012   1              if(uip_conn->tcpstateflags & UIP_STOPPED) {
1013   2              /* If the connection has issued uip_stop(), we advertise a zero
1014   2                window so that the remote host will stop sending data. */
1015   2                      BUF->wnd[0] = BUF->wnd[1] = 0;
1016   2              } else {
1017   2      #if (UIP_TCP_MSS) > 255
1018   2                      BUF->wnd[0] = (uip_conn->mss >> 8);
1019   2      #else
                              BUF->wnd[0] = 0;
              #endif /* UIP_MSS */
1022   2                      BUF->wnd[1] = (uip_conn->mss & 0xff); 
1023   2        }
1024   1        
1025   1      tcp_send_noconn:
1026   1        
1027   1              BUF->vhl = 0x45;
1028   1              BUF->tos = 0;
1029   1              BUF->ipoffset[0] = BUF->ipoffset[1] = 0;
1030   1              BUF->ttl  = UIP_TTL;
1031   1              BUF->proto = IP_PROTO_TCP;
1032   1        
1033   1      #if UIP_BUFSIZE > 255
1034   1              BUF->len[0] = (uip_len >> 8);
1035   1              BUF->len[1] = (uip_len & 0xff);
1036   1      #else
                      BUF->len[0] = 0;
                      BUF->len[1] = uip_len;
              #endif /* UIP_BUFSIZE > 255 */
1040   1        
1041   1              ++ipid;
1042   1              BUF->ipid[0] = ipid >> 8;
1043   1              BUF->ipid[1] = ipid & 0xff;
1044   1      
1045   1              /* Calculate IP and TCP checksums. */
1046   1              BUF->ipchksum = 0;
1047   1              BUF->ipchksum = ~(uip_ipchksum());
C51 COMPILER V7.10   UIP                                                                   09/03/2004 09:33:15 PAGE 18  

1048   1              BUF->tcpchksum = 0;
1049   1              BUF->tcpchksum = ~(uip_tcpchksum());
1050   1      
1051   1              UIP_STAT(++uip_stat.tcp.sent);
1052   1      send:
1053   1              UIP_STAT(++uip_stat.ip.sent);
1054   1              /* The data that should be sent is not present in the uip_buf, and
1055   1              the length of the data is in the variable uip_len. It is not our
1056   1              responsibility to do the actual sending of the data however. That
1057   1              is taken care of by the wrapper code, and only if uip_len > 0. */
1058   1              return;
1059   1      drop:
1060   1              uip_len = 0;
1061   1              return;
1062   1      }
1063          /*-----------------------------------------------------------------------------------*/


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   3741    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =    529    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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