📄 uip_arch.lst
字号:
C51 COMPILER V8.15 UIP_ARCH 08/11/2009 15:07:53 PAGE 1
C51 COMPILER V8.15, COMPILATION OF MODULE UIP_ARCH
OBJECT MODULE PLACED IN .\debug\uip_arch.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE uip_arch.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\debug\uip_arch.lst) OBJE
-CT(.\debug\uip_arch.obj)
line level source
1 /*
2 * Copyright (c) 2001, Adam Dunkels.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote
14 * products derived from this software without specific prior
15 * written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * This file is part of the uIP TCP/IP stack.
30 *
31 * $Id: uip_arch.c,v 1.2.2.1 2003/10/04 22:54:17 adam Exp $
32 *
33 */
34
35
36 #include "uip.h"
37 #include "uip_arch.h"
38
39 #define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
40 #define IP_PROTO_TCP 6
41
42 /*-----------------------------------------------------------------------------------*/
43 void
44 uip_add32(u8_t *op32, u16_t op16)
45 {
46 1
47 1 uip_acc32[3] = op32[3] + (op16 & 0xff);
48 1 uip_acc32[2] = op32[2] + (op16 >> 8);
49 1 uip_acc32[1] = op32[1];
50 1 uip_acc32[0] = op32[0];
51 1
52 1 if(uip_acc32[2] < (op16 >> 8)) {
53 2 ++uip_acc32[1];
54 2 if(uip_acc32[1] == 0) {
C51 COMPILER V8.15 UIP_ARCH 08/11/2009 15:07:53 PAGE 2
55 3 ++uip_acc32[0];
56 3 }
57 2 }
58 1
59 1
60 1 if(uip_acc32[3] < (op16 & 0xff)) {
61 2 ++uip_acc32[2];
62 2 if(uip_acc32[2] == 0) {
63 3 ++uip_acc32[1];
64 3 if(uip_acc32[1] == 0) {
65 4 ++uip_acc32[0];
66 4 }
67 3 }
68 2 }
69 1 }
70 /*-----------------------------------------------------------------------------------*/
71 u16_t
72 uip_chksum(u16_t *sdata, u16_t len)
73 {
74 1 u16_t acc;
75 1
76 1 for(acc = 0; len > 1; len -= 2) {
77 2 acc += *sdata;
78 2 if(acc < *sdata) {
79 3 /* Overflow, so we add the carry to acc (i.e., increase by
80 3 one). */
81 3 ++acc;
82 3 }
83 2 ++sdata;
84 2 }
85 1
86 1 /* add up any odd byte */
87 1 if(len == 1) {
88 2 acc += htons(((u16_t)(*(u8_t *)sdata)) << 8);
89 2 if(acc < htons(((u16_t)(*(u8_t *)sdata)) << 8)) {
90 3 ++acc;
91 3 }
92 2 }
93 1
94 1 return acc;
95 1 }
96 /*-----------------------------------------------------------------------------------*/
97 u16_t
98 uip_ipchksum(void)
99 {
100 1 return uip_chksum((u16_t *)&uip_buf[UIP_LLH_LEN], 20);
101 1 }
102 /*-----------------------------------------------------------------------------------*/
103 u16_t
104 uip_tcpchksum(void)
105 {
106 1 u16_t hsum, sum;
107 1
108 1
109 1 /* Compute the checksum of the TCP header. */
110 1 hsum = uip_chksum((u16_t *)&uip_buf[20 + UIP_LLH_LEN], 20);
111 1
112 1 /* Compute the checksum of the data in the TCP packet and add it to
113 1 the TCP header checksum. */
114 1 sum = uip_chksum((u16_t *)uip_appdata,
115 1 (u16_t)(((((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - 40)));
116 1
C51 COMPILER V8.15 UIP_ARCH 08/11/2009 15:07:53 PAGE 3
117 1 if((sum += hsum) < hsum) {
118 2 ++sum;
119 2 }
120 1
121 1 if((sum += BUF->srcipaddr[0]) < BUF->srcipaddr[0]) {
122 2 ++sum;
123 2 }
124 1 if((sum += BUF->srcipaddr[1]) < BUF->srcipaddr[1]) {
125 2 ++sum;
126 2 }
127 1 if((sum += BUF->destipaddr[0]) < BUF->destipaddr[0]) {
128 2 ++sum;
129 2 }
130 1 if((sum += BUF->destipaddr[1]) < BUF->destipaddr[1]) {
131 2 ++sum;
132 2 }
133 1 if((sum += (u16_t)htons((u16_t)IP_PROTO_TCP)) < (u16_t)htons((u16_t)IP_PROTO_TCP)) {
134 2 ++sum;
135 2 }
136 1
137 1 hsum = (u16_t)htons((((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - 20);
138 1
139 1 if((sum += hsum) < hsum) {
140 2 ++sum;
141 2 }
142 1
143 1 return sum;
144 1 }
145 /*-----------------------------------------------------------------------------------*/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 744 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- 13
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 + -