📄 icmp.lst
字号:
C51 COMPILER V7.07 ICMP 01/14/2009 14:46:40 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE ICMP
OBJECT MODULE PLACED IN .\icmp.obj
COMPILER INVOKED BY: D:\KEIL\C51\BIN\C51.EXE ..\TCPIP\icmp.c BROWSE DEBUG OBJECTEXTEND PRINT(.\icmp.lst) OBJECT(.\icmp.o
-bj)
stmt level source
1 /*
2 * Copyright (c) 2003 Electric Application Laboratory of NAN KAI University
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 * OF SUCH DAMAGE.
26 *
27 * Author: Li Zhanglin <wzzlin@nankai.edu.cn>
28 *
29 */
30
31 #include "..\GloblDef\GloblDef.h"
32 #include "..\TCPIP\TCPIPmem.h"
33 #include "..\TCPIP\IP.h"
34 #include "..\TCPIP\icmp.h"
35
36 #if ICMP_EN
37 /* MemHead->pStart is point to ICMP head */
38 void ICMPInput(struct SMemHead DT_XDATA *MemHead) REENTRANT_MUL
39 {
40 1 IP_ADDR ipaddr;
41 1 struct SIPHead DT_XDATA *pIPHead;
42 1
43 1 /* which type of icmp */
44 1 switch(((struct SICMPEchoHead DT_XDATA *)(MemHead->pStart))->type)
45 1 {
46 2 case ICMP_TYPE_QUERY:
47 2
48 2 /* chage type */
49 2 ((struct SICMPEchoHead DT_XDATA *)(MemHead->pStart))->type = ICMP_TYPE_REPLY;
50 2
51 2 /* adjust checksum. refer to lwip: if change type from 8 to 0,
52 2 for checksum, that is increasing 0x8000 and add flowed hight bit
53 2 to bit 0.*/
54 2 if (((struct SICMPEchoHead DT_XDATA *)(MemHead->pStart))->CheckSum >= htons(0xffff - (((WORD)ICMP_TYPE_Q
C51 COMPILER V7.07 ICMP 01/14/2009 14:46:40 PAGE 2
-UERY) << 8)))
55 2 ((struct SICMPEchoHead DT_XDATA *)(MemHead->pStart))->CheckSum += htons(((WORD)ICMP_TYPE_QUERY) << 8) +
- 1;
56 2 else
57 2 ((struct SICMPEchoHead DT_XDATA *)(MemHead->pStart))->CheckSum += htons(((WORD)ICMP_TYPE_QUERY) << 8);
58 2
59 2 /*
60 2 *send this packet back, first fill some of IPHead field
61 2 */
62 2
63 2 /* dec pStart and get ip head */
64 2 pIPHead = (struct SIPHead DT_XDATA *)(MemHead->pStart -= IP_HEAD_MIN_LEN);
65 2
66 2 /* exchange ipdest and ipscr */
67 2 ipaddr = pIPHead->IPDest;
68 2 pIPHead->IPDest = pIPHead->IPScr;
69 2 pIPHead->IPScr = ipaddr;
70 2
71 2 /* ip total length not change */
72 2
73 2 /* protocol */
74 2 pIPHead->Protocol = IP_PROTOCOL_ICMP;
75 2
76 2 IPOutput(MemHead);
77 2
78 2 /* whether send success or not free this packet */
79 2 MemFree(MemHead);
80 2
81 2 break;
82 2 default:
83 2 MemFree(MemHead);
84 2 }
85 1 }
86
87 #endif
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 272 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 6
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 + -