📄 http__server_8c-source.html
字号:
00393 00394 00395 <span class="keywordflow">return</span>(1); 00396 00397 00398 }00399 00400 00401 <span class="keywordflow">return</span>(1);00402 00403 00404 <span class="keywordflow">case</span> <a class="code" href="tcp__ip_8h.html#a59">TCP_EVENT_REGENERATE</a>:00405 00406 <span class="keywordflow">if</span>(session < 0)00407 <span class="keywordflow">return</span>(-1);00408 00409 <span class="keywordflow">if</span>(https[session].<a class="code" href="structhttp__server__state.html#m0">state</a> != <a class="code" href="http__server_8h.html#a4">HTTPS_STATE_ACTIVE</a>)00410 <span class="keywordflow">return</span>(-1);00411 00412 i = <a class="code" href="https__callbacks_8c.html#a2">https_loadbuffer</a>(session, &net_buf[<a class="code" href="tcp__ip_8h.html#a61">TCP_APP_OFFSET</a>], (UINT16)par1);00413 00414 <span class="keywordflow">if</span>(i<0)00415 <span class="keywordflow">return</span>(-1);00416 00417 <a class="code" href="tcp_8c.html#a7">tcp_send</a>(https[session].ownersocket, &net_buf[<a class="code" href="tcp__ip_8h.html#a61">TCP_APP_OFFSET</a>], <a class="code" href="group__opentcp__config.html#a4">NETWORK_TX_BUFFER_SIZE</a> - <a class="code" href="tcp__ip_8h.html#a61">TCP_APP_OFFSET</a>, i); 00418 00419 <span class="keywordflow">return</span>(i);00420 00421 00422 <span class="keywordflow">default</span>:00423 <span class="keywordflow">return</span>(-1);00424 } 00425 00426 }00427 00428 00429 <span class="keywordtype">void</span> https_deletesession (UINT8 ses)00430 {00431 https[ses].<a class="code" href="structhttp__server__state.html#m0">state</a> = <a class="code" href="http__server_8h.html#a2">HTTPS_STATE_FREE</a>;00432 https[ses].<a class="code" href="structhttp__server__state.html#m2">fstart</a> = 0;00433 https[ses].<a class="code" href="structhttp__server__state.html#m4">fpoint</a> = 0;00434 https[ses].<a class="code" href="structhttp__server__state.html#m3">flen</a> = 0;00435 https[ses].<a class="code" href="structhttp__server__state.html#m5">funacked</a> = 0;00436 00437 }00438 00439 INT16 https_searchsession (UINT8 soch)00440 {00441 UINT8 i;00442 00443 <span class="keywordflow">for</span>(i=0; i<NO_OF_HTTP_SESSIONS; i++)00444 {00445 <span class="keywordflow">if</span>(https[i].<a class="code" href="structhttp__server__state.html#m1">ownersocket</a> == soch)00446 <span class="keywordflow">return</span>(i);00447 00448 }00449 00450 <span class="keywordflow">return</span>(-1);00451 00452 }00453 00454 INT16 https_bindsession (UINT8 soch)00455 {00456 UINT8 i;00457 00458 <span class="keywordflow">for</span>(i=0; i<NO_OF_HTTP_SESSIONS; i++)00459 {00460 <span class="keywordflow">if</span>(https[i].<a class="code" href="structhttp__server__state.html#m1">ownersocket</a> == soch)00461 {00462 <span class="keywordflow">if</span>(https[i].<a class="code" href="structhttp__server__state.html#m0">state</a> == <a class="code" href="http__server_8h.html#a2">HTTPS_STATE_FREE</a>)00463 {00464 https[i].<a class="code" href="structhttp__server__state.html#m0">state</a> = <a class="code" href="http__server_8h.html#a3">HTTPS_STATE_RESERVED</a>;00465 <span class="keywordflow">return</span>(i);00466 } 00467 } 00468 00469 }00470 00471 00472 <span class="keywordflow">return</span>(-1);00473 00474 }00475 00476 <span class="keywordtype">void</span> https_activatesession (UINT8 ses)00477 {00478 https[ses].<a class="code" href="structhttp__server__state.html#m0">state</a> = <a class="code" href="http__server_8h.html#a4">HTTPS_STATE_ACTIVE</a>;00479 00480 }00481 00482 <span class="comment">/* read two encoded bytes from HTTP URI and return</span>00483 <span class="comment"> * decoded byte</span>00484 <span class="comment"> */</span>00485 UINT8 https_read_encoded(<span class="keywordtype">void</span>)00486 {00487 UINT8 temp,ch;00488 00489 temp = <a class="code" href="system_8h.html#a9">RECEIVE_NETWORK_B</a>();00490 <span class="keywordflow">if</span>((temp>=<span class="charliteral">'0'</span>)&&(temp<=<span class="charliteral">'9'</span>)){00491 ch = (temp-<span class="charliteral">'0'</span>)<<4;00492 }<span class="keywordflow">else</span>{00493 <span class="keywordflow">if</span>((temp>=<span class="charliteral">'a'</span>)&&(temp<=<span class="charliteral">'f'</span>)){00494 ch = (temp-<span class="charliteral">'a'</span>+10)<<4;00495 }<span class="keywordflow">else</span>{00496 ch = (temp-<span class="charliteral">'A'</span>+10)<<4;00497 }00498 }00499 00500 temp = <a class="code" href="system_8h.html#a9">RECEIVE_NETWORK_B</a>();00501 <span class="keywordflow">if</span>((temp>=<span class="charliteral">'0'</span>)&&(temp<=<span class="charliteral">'9'</span>)){00502 ch |= (temp-<span class="charliteral">'0'</span>);00503 }<span class="keywordflow">else</span>{00504 <span class="keywordflow">if</span>((temp>=<span class="charliteral">'a'</span>)&&(temp<=<span class="charliteral">'f'</span>)){00505 ch |= (temp-<span class="charliteral">'a'</span>+10);00506 }<span class="keywordflow">else</span>{00507 ch |= (temp-<span class="charliteral">'A'</span>+10);00508 }00509 }00510 <span class="keywordflow">return</span> ch;00511 }00512 00513 INT16 https_calculatehash (UINT32 len)00514 {00515 UINT8 hash=0;00516 UINT8 ch;00517 UINT8 i;00518 00519 00520 <span class="comment">/* Read Max 60 characters */</span>00521 00522 <span class="keywordflow">if</span>(len > 60)00523 len = 60;00524 00525 <span class="keywordflow">for</span>( i=0; i<len; i++)00526 {00527 ch = <a class="code" href="system_8h.html#a9">RECEIVE_NETWORK_B</a>();00528 00529 <span class="keywordflow">if</span>( ch ==<span class="charliteral">' '</span>) <span class="comment">/* End reached? */</span>00530 <span class="keywordflow">break</span>;00531 00532 <span class="comment">/* encoded HTTP URI ? */</span>00533 <span class="keywordflow">if</span>( ch == <span class="charliteral">'%'</span>){00534 ch = https_read_encoded();00535 00536 <span class="comment">/* is this UNICODE char encoded? (for now allow only</span>00537 <span class="comment"> * one byte encoded UNICODE chars)</span>00538 <span class="comment"> */</span>00539 <span class="keywordflow">if</span>( ( ch & 0xe0 ) == 0xc0){00540 <span class="comment">/* yes */</span>00541 ch = ( ch & 0x1F ) << 6; 00542 <a class="code" href="system_8h.html#a9">RECEIVE_NETWORK_B</a>(); <span class="comment">/* skip first % */</span>00543 ch |= (https_read_encoded() & 0x3F);00544 }00545 }00546 00547 hash *= 37;00548 hash += ch;00549 00550 }00551 00552 <span class="keywordflow">if</span>(i==len)00553 <span class="keywordflow">return</span>(-1);00554 00555 <span class="comment">/* construct address for Hash table */</span>00556 00557 <span class="keywordflow">if</span>(hash == 0) <span class="comment">/* User asked defaul file */</span>00558 {00559 <span class="comment">/* Set hash to index.html value */</span>00560 00561 hash = 0x0B;00562 00563 }00564 00565 <span class="comment">/* Now we have hash value calculated */</span>00566 00567 <span class="keywordflow">return</span>( hash );00568 00569 }00570 00571 </pre></div><hr><address style="align: right;"><small>Generated on Sun Aug 3 20:32:59 2003 for OpenTCP by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.18 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -