📄 tftp.lst
字号:
C51 COMPILER V7.09 TFTP 07/27/2007 15:17:42 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE TFTP
OBJECT MODULE PLACED IN tftp.obj
COMPILER INVOKED BY: F:\Keil\C51\BIN\C51.EXE tcp\tftp.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\tftp.lst) OBJECT(tftp.ob
-j)
line level source
1 #include "net.h"
2 #include "eth.h"
3 #include "ip.h"
4 #include "udp.h"
5 #include "tftp.h"
6 #include "utils.h"
7 #include "tftpput.h"
8
9 unsigned long volatile client_ip;
10 unsigned short volatile client_port;
11 unsigned short volatile client_block = 0;
12
13 extern unsigned char TFTP_BUF[];
14 extern unsigned char UDP_BUF[];
15
16 int tftp_send_ack(char *buf, int block)
17 {
18 1 tftphdr *tftp_ack;
19 1 tftp_ack = (tftphdr *)(buf+42);
20 1
21 1 tftp_ack->th_opcode = ACK;
22 1 tftp_ack->th_block = block;
23 1
24 1 #ifdef __LITTLEENDIAN__
tftp_ack->th_opcode = htons(tftp_ack->th_opcode);
tftp_ack->th_block = htons(tftp_ack->th_block);
#endif
28 1
29 1 // udp_send(skb, client_ip, TFTP, client_port);
30 1 udp_send((char*)(buf), TFTP_PORT, sizeof(tftphdr));
31 1
32 1 return 0;
33 1 }
34
35 int tftp_rcv_wrq(char *inbuf, int len)
36 {
37 1 struct tftphdr *tftp_hdr;
38 1
39 1 // client_ip = ip_get_source_ip(skb);
40 1 // client_port = udp_get_source_port(skb);
41 1
42 1 //adjust by qg
43 1 IP_HEADER * ip;
44 1 UDP_HEADER * udp;
45 1 ip = (IP_HEADER *)(inbuf + 14);
46 1 udp = (UDP_HEADER *)(inbuf + 34);
47 1 #ifdef __LITTLEENDIAN__
ip->source_ipaddr = ntohl(ip->source_ipaddr);
udp->source_port = ntohs(ip->source_port);
#endif
51 1 client_ip = ip->source_ipaddr;
52 1 client_port = udp->source_port;
53 1
54 1 tftp_hdr = (tftphdr *)inbuf;
C51 COMPILER V7.09 TFTP 07/27/2007 15:17:42 PAGE 2
*** WARNING C182 IN LINE 54 OF TCP\TFTP.C: pointer to different objects
55 1 tftp_send_ack((char*)tftp_hdr, 0);
56 1 client_block = 1;
57 1
58 1 // tftp_put_begin();//第一个包
59 1 // event_tftpput = 1;
60 1 udp_broadcast(UDP_BUF, 7001, 10);
61 1
62 1 return 0;
63 1 }
*** WARNING C280 IN LINE 35 OF TCP\TFTP.C: 'len': unreferenced local variable
64 //定时器中要进行event_tftpput复位工作,否则tcp连接会不正常;
65 int tftp_rcv_data(char* inbuf, int buflen)
66 {
67 1 tftphdr *tftp_hdr;
68 1 int len;
69 1
70 1 //adjust by qg
71 1 IP_HEADER * ip;
72 1 UDP_HEADER * udp;
73 1 ip = (IP_HEADER *)(inbuf + 14);
74 1 udp = (UDP_HEADER *)(inbuf + 34);
75 1 #ifdef __LITTLEENDIAN__
ip->source_ipaddr = ntohl(ip->source_ipaddr);
udp->source_port = ntohs(ip->source_port);
#endif
79 1
80 1 if (client_ip != ip->source_ipaddr)
81 1 return -1;
82 1 if (client_port != udp->source_port)
83 1 return -1;
84 1
85 1 tftp_hdr = (tftphdr *)(inbuf+42);
86 1 #ifdef __LITTLEENDIAN__
tftp_hdr->th_block = ntohs(tftp_hdr->th_block);
#endif
89 1 if (client_block == tftp_hdr->th_block)
90 1 {
91 2 len = udp->length - sizeof( tftphdr)-8;
92 2
93 2 //get put data in buf,do you want
94 2 tftp_put((unsigned char *)tftp_hdr+sizeof(tftphdr), len);
95 2
96 2 tftp_hdr = (tftphdr *)(TFTP_BUF);
97 2
98 2 tftp_send_ack((char*)tftp_hdr, client_block);
99 2 client_block++;
100 2
101 2 if (len < 512)
102 2 //tftp_put_end();
103 2 {//传输结束
104 3 // event_tftpput = 0;
105 3 }
106 2
107 2 } else if (client_block > tftp_hdr->th_block) {
108 2
109 2 tftp_send_ack(tftp_hdr, tftp_hdr->th_block);
*** WARNING C182 IN LINE 109 OF TCP\TFTP.C: pointer to different objects
110 2
111 2 } else {
112 2
113 2 tftp_send_ack(tftp_hdr, client_block);
C51 COMPILER V7.09 TFTP 07/27/2007 15:17:42 PAGE 3
*** WARNING C182 IN LINE 113 OF TCP\TFTP.C: pointer to different objects
114 2 }
115 1
116 1 return 0;
117 1 }
*** WARNING C280 IN LINE 65 OF TCP\TFTP.C: 'buflen': unreferenced local variable
118
119 int tftp_rcv_packet(char* buf, int len)
120 {
121 1 tftphdr *tftp_hdr;
122 1
123 1 tftp_hdr = (tftphdr *)(buf+42);
124 1
125 1 #ifdef __LITTLEENDIAN__
tftp_hdr->th_opcode = ntohs(tftp_hdr->th_opcode);
#endif
128 1
129 1 switch (tftp_hdr->th_opcode) {
130 2
131 2 case RRQ:
132 2 break;
133 2 case WRQ:
134 2 tftp_rcv_wrq(buf, len);
135 2 break;
136 2 case DATA:
137 2 tftp_rcv_data(buf, len);
138 2 break;
139 2 case ACK:
140 2 break;
141 2 case ERROR:
142 2 break;
143 2 default:
144 2 break;
145 2 }
146 1
147 1 return 0;
148 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 688 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 8 35
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 5 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -