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

📄 httpd.lst

📁 ENC28J60 System HTTP
💻 LST
📖 第 1 页 / 共 5 页
字号:
   1               		.file	"httpd.c"
   2               	__SREG__ = 0x3f
   3               	__SP_H__ = 0x3e
   4               	__SP_L__ = 0x3d
   5               	__CCP__  = 0x34
   6               	__tmp_reg__ = 0
   7               	__zero_reg__ = 1
   8               		.global __do_copy_data
   9               		.global __do_clear_bss
  11               		.text
  12               	.Ltext0:
 115               	.global	httpd_init
 117               	httpd_init:
   1:net/httpd.c   **** /*
   2:net/httpd.c   **** ,-----------------------------------------------------------------------------------------.
   3:net/httpd.c   **** | net/httpd
   4:net/httpd.c   **** |-----------------------------------------------------------------------------------------
   5:net/httpd.c   **** | this file implements a very basic http server
   6:net/httpd.c   **** | - support for HTTP POST 
   7:net/httpd.c   **** | - support for http basic auuth (all /adm/.. file acces must be authorized)
   8:net/httpd.c   **** |
   9:net/httpd.c   **** | KNOWN PROBLEMS:
  10:net/httpd.c   **** | - somehow quick&dirty implementation ! sorry for that ;)
  11:net/httpd.c   **** | - uses some dirty hacks (content length detection etc)
  12:net/httpd.c   **** | - very big routines without function calls for memory/flash/speed reasons
  13:net/httpd.c   **** | - not really documented :-\
  14:net/httpd.c   **** | - http authorization does not work if browser request is split into two packets ! (-> always not 
  15:net/httpd.c   **** | - httpd_add_prog* only use 16bit as data offset ! -> biggest filesize in avr flash is 65k!!!
  16:net/httpd.c   **** |
  17:net/httpd.c   **** | Author   : {{removed according to contest rules}}
  18:net/httpd.c   **** |            -> circuitcellar.com avr design contest 2006
  19:net/httpd.c   **** |            -> Entry #AT2616
  20:net/httpd.c   **** |
  21:net/httpd.c   **** |-----------------------------------------------------------------------------------------
  22:net/httpd.c   **** | License:
  23:net/httpd.c   **** | This program is free software; you can redistribute it and/or modify it under
  24:net/httpd.c   **** | the terms of the GNU General Public License as published by the Free Software
  25:net/httpd.c   **** | Foundation; either version 2 of the License, or (at your option) any later
  26:net/httpd.c   **** | version.
  27:net/httpd.c   **** | This program is distributed in the hope that it will be useful, but
  28:net/httpd.c   **** |
  29:net/httpd.c   **** | WITHOUT ANY WARRANTY;
  30:net/httpd.c   **** |
  31:net/httpd.c   **** | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  32:net/httpd.c   **** | PURPOSE. See the GNU General Public License for more details.
  33:net/httpd.c   **** |
  34:net/httpd.c   **** | You should have received a copy of the GNU General Public License along with
  35:net/httpd.c   **** | this program; if not, write to the Free Software Foundation, Inc., 51
  36:net/httpd.c   **** | Franklin St, Fifth Floor, Boston, MA 02110, USA
  37:net/httpd.c   **** |
  38:net/httpd.c   **** | http://www.gnu.de/gpl-ger.html
  39:net/httpd.c   **** `-----------------------------------------------------------------------------------------*/
  40:net/httpd.c   **** 
  41:net/httpd.c   **** #include "httpd.h"
  42:net/httpd.c   **** 
  43:net/httpd.c   **** //ACTIVATE DEBUG by editing this file:
  44:net/httpd.c   **** #include "debug.h"
  45:net/httpd.c   **** 
  46:net/httpd.c   **** ///FIXME: include the .c file here !
  47:net/httpd.c   **** ///       without this sizeof() does not work !! -> is there another way to do this ?!
  48:net/httpd.c   **** #include "httpd_data.c"
  49:net/httpd.c   **** 
  50:net/httpd.c   **** 
  51:net/httpd.c   **** struct httpd_conn_struct {
  52:net/httpd.c   **** 	unsigned char state;
  53:net/httpd.c   **** 	unsigned char substate;
  54:net/httpd.c   **** 	unsigned int  file_id;
  55:net/httpd.c   **** 	unsigned long  seq_offset;
  56:net/httpd.c   **** 	unsigned int  data_ptr;
  57:net/httpd.c   **** 	unsigned long data_position;
  58:net/httpd.c   **** };
  59:net/httpd.c   **** 
  60:net/httpd.c   **** struct httpd_conn_struct httpd_conn[TCP_SOCKET_COUNT];
  61:net/httpd.c   **** 
  62:net/httpd.c   **** //initialise connection table
  63:net/httpd.c   **** void httpd_init(void){
 118               	
 119               	.LM0:
 120               	.LFBB1:
 121               	/* prologue: function */
 122               	/* frame size = 0 */
 124               	.LM1:
 125 0000 E0E0      		ldi r30,lo8(httpd_conn)
 126 0002 F0E0      		ldi r31,hi8(httpd_conn)
 127               	.L2:
 128               	.LBB60:
 129               	.LBB61:
 130               	.LBB62:
  64:net/httpd.c   **** up_conn(c);
  65:net/httpd.c   **** 	}
  66:net/httpd.c   **** }
  67:net/httpd.c   **** 
  68:net/httpd.c   **** //initialise/cleanup http conn
  69:net/httpd.c   **** void httpd_cleanup_conn(unsigned char i){
  70:net/httpd.c   **** 	if (i<TCP_SOCKET_COUNT){
  71:net/httpd.c   **** 		httpd_conn[i].state = HTTPD_STATE_IDLE;
  72:net/httpd.c   **** 		httpd_conn[i].data_position = 0;
 131               	,72,.LM2-.LFBB1
 132               	.LM2:
 133 0004 1082      		st Z,__zero_reg__
  73:net/httpd.c   **** eturn: how many data bytes should be transferred ?
 134               	tabn	68,0,73,.LM3-.LFBB1
 135               	.LM3:
 136 0006 1286      		std Z+10,__zero_reg__
 137 0008 1386      		std Z+11,__zero_reg__
 138 000a 1486      		std Z+12,__zero_reg__
 139 000c 1586      		std Z+13,__zero_reg__
 140 000e 3E96      		adiw r30,14
 141               	.LBE62:
 142               	.LBE61:
 144               	.LM4:
 145 0010 80E0      		ldi r24,hi8(httpd_conn+140)
 146 0012 E030      		cpi r30,lo8(httpd_conn+140)
 147 0014 F807      		cpc r31,r24
 148 0016 01F4      		brne .L2
 149               	/* epilogue start */
 150               	.LBE60:
 152               	.LM5:
 153 0018 0895      		ret
 155               	.Lscope1:
 158               	.global	httpd_cleanup_conn
 160               	httpd_cleanup_conn:
 162               	.LM6:
 163               	.LFBB2:
 164               	/* prologue: function */
 165               	/* frame size = 0 */
 166 001a 282F      		mov r18,r24
 168               	.LM7:
 169 001c 8A30      		cpi r24,lo8(10)
 170 001e 00F4      		brsh .L7
 172               	.LM8:
 173 0020 90E0      		ldi r25,lo8(0)
 174 0022 880F      		lsl r24
 175 0024 991F      		rol r25
 176 0026 FC01      		movw r30,r24
 177 0028 43E0      		ldi r20,3
 178 002a EE0F      	1:	lsl r30
 179 002c FF1F      		rol r31
 180 002e 4A95      		dec r20
 181 0030 01F4      		brne 1b
 182 0032 E81B      		sub r30,r24
 183 0034 F90B      		sbc r31,r25
 184 0036 E050      		subi r30,lo8(-(httpd_conn))
 185 0038 F040      		sbci r31,hi8(-(httpd_conn))
 186 003a 1082      		st Z,__zero_reg__
 188               	.LM9:
 189 003c 822F      		mov r24,r18
 190 003e 90E0      		ldi r25,lo8(0)
 191 0040 880F      		lsl r24
 192 0042 991F      		rol r25
 193 0044 FC01      		movw r30,r24
 194 0046 23E0      		ldi r18,3
 195 0048 EE0F      	1:	lsl r30
 196 004a FF1F      		rol r31
 197 004c 2A95      		dec r18
 198 004e 01F4      		brne 1b
 199 0050 E81B      		sub r30,r24
 200 0052 F90B      		sbc r31,r25
 201 0054 E050      		subi r30,lo8(-(httpd_conn))
 202 0056 F040      		sbci r31,hi8(-(httpd_conn))
 203 0058 1286      		std Z+10,__zero_reg__
 204 005a 1386      		std Z+11,__zero_reg__
 205 005c 1486      		std Z+12,__zero_reg__
 206 005e 1586      		std Z+13,__zero_reg__
 207               	.L7:
 208 0060 0895      		ret
 210               	.Lscope2:
 217               	.global	httpd_add_progmem_data_bin
 219               	httpd_add_progmem_data_bin:
  74:net/httpd.c   **** nsigned int httpd_data_in(unsigned char *buffer, unsigned int datapos, unsigned int datalen, unsign
  75:net/httpd.c   **** 	unsigned int pos;
  76:net/httpd.c   **** 	unsigned char file_name[8+6+1];
  77:net/httpd.c   **** 	unsigned char file_ext[3+1];
  78:net/httpd.c   **** 	unsigned char f;
  79:net/httpd.c   **** 	unsigned int ret;
  80:net/httpd.c   **** 	unsigned long offset;
  81:net/httpd.c   **** 	unsigned char authorized;
  82:net/httpd.c   **** 
  83:net/httpd.c   **** 	pos = 0;
  84:net/httpd.c   **** 
  85:net/httpd.c   **** 	#if HTTPD_DEBUG2
  86:net/httpd.c   **** 	softuart_puts_progmem("HTTP: SEQ-SEQ_OFFSET_DATA = ");
  87:net/httpd.c   **** 	softuart_put_uint16((tcp_sockets[socketnum].seq-httpd_conn[socketnum].seq_offset)&0xFFFF);
  88:net/httpd.c   **** 	softuart_puts_progmem("\r\n");
  89:net/httpd.c   **** 	#endif
  90:net/httpd.c   **** 
  91:net/httpd.c   ****   //initialise filename:
  92:net/httpd.c   **** 	for (f=0; f<8+6+1; f++)
  93:net/httpd.c   **** 		file_name[f] = 0;
  94:net/httpd.c   **** 	for (f=0; f<3+1; f++)
  95:net/httpd.c   **** 		file_ext[f] = 0;
  96:net/httpd.c   **** 
  97:net/httpd.c   **** 	switch(httpd_conn[socketnum].state){
  98:net/httpd.c   **** 		case(HTTPD_STATE_IDLE):
  99:net/httpd.c   **** 		//case(HTTPD_STATE_IDLE_r):
 100:net/httpd.c   **** 		//case(HTTPD_STATE_IDLE_rn):
 101:net/httpd.c   **** 		//case(HTTPD_STATE_IDLE_rnr):
 102:net/httpd.c   **** 		//case(HTTPD_STATE_IDLE_rnrn):
 103:net/httpd.c   **** 			//new request, scan for GET/POST:
 104:net/httpd.c   **** 			if ((buffer[datapos + 0] == 'G') && 
 105:net/httpd.c   **** 			    (buffer[datapos + 1] == 'E') && 
 106:net/httpd.c   **** 			    (buffer[datapos + 2] == 'T')){
 107:net/httpd.c   **** 				//get request !
 108:net/httpd.c   **** 				pos = datapos + 3;
 109:net/httpd.c   **** 				
 110:net/httpd.c   **** 				f = 0;
 111:net/httpd.c   **** 
 112:net/httpd.c   **** 				//find start of requested url
 113:net/httpd.c   **** 				while(buffer[pos] == ' ')
 114:net/httpd.c   **** 					pos++;
 115:net/httpd.c   **** 
 116:net/httpd.c   **** 				while((buffer[pos] != ' ')  && (buffer[pos] != '\r') && (buffer[pos] != '\n')  && (buffer[pos] 
 117:net/httpd.c   **** 					//read requested file,
 118:net/httpd.c   **** 					//read filename:
 119:net/httpd.c   **** 					file_name[f] = buffer[pos];
 120:net/httpd.c   **** 
 121:net/httpd.c   **** 					//read file extension:
 122:net/httpd.c   **** 					/*if (!((file_ext[2] == ' ') || (file_ext[2] == '?'))){
 123:net/httpd.c   **** 						file_ext[0] = file_ext[1];
 124:net/httpd.c   **** 						file_ext[1] = file_ext[2];
 125:net/httpd.c   **** 						file_ext[2] = buffer[pos];
 126:net/httpd.c   **** 					}*/
 127:net/httpd.c   **** 					if (buffer[pos] == '.'){
 128:net/httpd.c   **** 						file_ext[0] = buffer[pos+1];
 129:net/httpd.c   **** 						file_ext[1] = buffer[pos+2];
 130:net/httpd.c   **** 						file_ext[2] = buffer[pos+3];
 131:net/httpd.c   **** 						file_name[f] = 0;
 132:net/httpd.c   **** 						break;
 133:net/httpd.c   **** 					}
 134:net/httpd.c   **** 
 135:net/httpd.c   **** 					if (file_name[f] == '.')
 136:net/httpd.c   **** 						file_name[f] = 0;
 137:net/httpd.c   **** 					
 138:net/httpd.c   **** 					if (f<8+6)
 139:net/httpd.c   **** 						f++;
 140:net/httpd.c   **** 	
 141:net/httpd.c   **** 					//remove first /
 142:net/httpd.c   **** 					if (file_name[0] == '/')
 143:net/httpd.c   **** 						f=0;
 144:net/httpd.c   **** 
 145:net/httpd.c   **** 					pos++;
 146:net/httpd.c   **** 				}
 147:net/httpd.c   **** 				//if (file_name[f]=='.')
 148:net/httpd.c   **** 				//	file_name[f] = 0;
 149:net/httpd.c   **** 
 150:net/httpd.c   **** 				#if HTTPD_DEBUG
 151:net/httpd.c   **** 				softuart_puts_progmem("HTTP: GET <");				
 152:net/httpd.c   **** 				for(f=0;f<8+6 && file_name[f];f++)
 153:net/httpd.c   **** 					softuart_putc(file_name[f]);

⌨️ 快捷键说明

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