📄 tcp_8c.html
字号:
</tr></table><a name="a13" doxytag="tcp.c::tcp_init"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> INT8 tcp_init </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><dl compact><dt><b>Author: </b></dt><dd> <ul><li> Jari Lahti (<a href="mailto:jari.lahti@violasystems.com">jari.lahti@violasystems.com</a>) </ul></dl><dl compact><dt><b>Date: </b></dt><dd>21.07.2002 </dl><dl compact><dt><b>Returns: </b></dt><dd> <ul><li> -1 - error <li> >0 - number of sockets initialized </ul></dl><dl compact><dt><b>Warning: </b></dt><dd> <ul><li> This function <b>must</b> be invoked at startup before any other TCP functions are invoked.</ul></dl>This function initializes all sockets and corresponding tcbs to known state. Timers are also allocated for each socket and everything is brought to a predefined state. <p>Definition at line <a class="el" href="tcp_8c-source.html#l01154">1154</a> of file <a class="el" href="tcp_8c-source.html">tcp.c</a>.<p>References <a class="el" href="structtcb.html#m16">tcb::event_listener</a>, <a class="el" href="tcp__ip_8h-source.html#l00622">tcb::flags</a>, <a class="el" href="timers_8c-source.html#l00131">get_timer()</a>, <a class="el" href="timers_8c-source.html#l00194">init_timer()</a>, <a class="el" href="tcp__ip_8h-source.html#l00625">tcb::locport</a>, <a class="el" href="tcp__ip_8h-source.html#l00627">tcb::myflags</a>, <a class="el" href="tcp__ip_8h-source.html#l00633">tcb::persist_timerh</a>, <a class="el" href="tcp__ip_8h-source.html#l00623">tcb::rem_ip</a>, <a class="el" href="tcp__ip_8h-source.html#l00624">tcb::remport</a>, <a class="el" href="tcp__ip_8h-source.html#l00634">tcb::retransmit_timerh</a>, <a class="el" href="tcp__ip_8h-source.html#l00635">tcb::retries_left</a>, <a class="el" href="tcp__ip_8h-source.html#l00629">tcb::send_mtu</a>, <a class="el" href="tcp__ip_8h-source.html#l00609">tcb::state</a>, <a class="el" href="tcp__ip_8h-source.html#l00333">TCP_STATE_FREE</a>, <a class="el" href="tcp__ip_8h-source.html#l00300">TCP_TYPE_NONE</a>, <a class="el" href="tcp__ip_8h-source.html#l00631">tcb::tos</a>, <a class="el" href="tcp__ip_8h-source.html#l00630">tcb::tout</a>, and <a class="el" href="tcp__ip_8h-source.html#l00621">tcb::type</a>. </td> </tr></table><a name="a14" doxytag="tcp.c::process_tcp_in"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> INT16 process_tcp_in </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">struct <a class="el" href="structip__frame.html">ip_frame</a> * </td> <td class="mdname" nowrap> <em>frame</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>UINT16 </td> <td class="mdname" nowrap> <em>len</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><dl compact><dt><b>Author: </b></dt><dd> <ul><li> Jari Lahti (<a href="mailto:jari.lahti@violasystems.com">jari.lahti@violasystems.com</a>) </ul></dl><dl compact><dt><b>Date: </b></dt><dd>12.07.2002 </dl><dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>frame</em> </td><td>pointer to received <a class="el" href="structip__frame.html">ip_frame</a> structure </td></tr><tr><td valign=top><em>len</em> </td><td>length of data contained in IP datagram (in bytes) </td></tr></table></dl><dl compact><dt><b>Returns: </b></dt><dd> <ul><li> -1 - Error (packet not OK, or not TCP,or something else) <li> >0 - Packet OK</ul></dl>Invoke this function to process received TCP frames. See <a class="el" href="main__demo_8c.html">main_demo.c</a> for an example on how to accomplish this. <p>Definition at line <a class="el" href="tcp_8c-source.html#l01250">1250</a> of file <a class="el" href="tcp_8c-source.html">tcp.c</a>.<p>References <a class="el" href="tcp__ip_8h-source.html#l00569">tcp_frame::ackno</a>, <a class="el" href="tcp__ip_8h-source.html#l00575">tcp_frame::buf_index</a>, <a class="el" href="ip_8h-source.html#l00126">ip_frame::buf_index</a>, <a class="el" href="tcp__ip_8h-source.html#l00572">tcp_frame::checksum</a>, <a class="el" href="tcp__ip_8h-source.html#l00567">tcp_frame::dport</a>, <a class="el" href="structtcb.html#m16">tcb::event_listener</a>, <a class="el" href="tcp__ip_8h-source.html#l00622">tcb::flags</a>, <a class="el" href="tcp__ip_8h-source.html#l00570">tcp_frame::hlen_flags</a>, <a class="el" href="ip_8h-source.html#l00074">IP_TCP</a>, <a class="el" href="tcp__ip_8h-source.html#l00627">tcb::myflags</a>, <a class="el" href="system_8h-source.html#l00270">NETWORK_RECEIVE_INITIALIZE</a>, <a class="el" href="tcp__ip_8h-source.html#l00574">tcp_frame::opt</a>, <a class="el" href="ip_8h-source.html#l00121">ip_frame::protocol</a>, <a class="el" href="system_8h-source.html#l00210">RECEIVE_NETWORK_B</a>, <a class="el" href="tcp__ip_8h-source.html#l00632">tcb::receive_next</a>, <a class="el" href="tcp__ip_8h-source.html#l00623">tcb::rem_ip</a>, <a class="el" href="tcp__ip_8h-source.html#l00624">tcb::remport</a>, <a class="el" href="system_8h-source.html#l00163">RESET_SYSTEM</a>, <a class="el" href="tcp__ip_8h-source.html#l00628">tcb::send_next</a>, <a class="el" href="tcp__ip_8h-source.html#l00626">tcb::send_unacked</a>, <a class="el" href="tcp__ip_8h-source.html#l00568">tcp_frame::seqno</a>, <a class="el" href="ip_8h-source.html#l00123">ip_frame::sip</a>, <a class="el" href="tcp__ip_8h-source.html#l00566">tcp_frame::sport</a>, <a class="el" href="tcp__ip_8h-source.html#l00609">tcb::state</a>, <a class="el" href="tcp_8c-source.html#l02567">tcp_check_cs()</a>, <a class="el" href="tcp__ip_8h-source.html#l00418">TCP_EVENT_ABORT</a>, <a class="el" href="tcp__ip_8h-source.html#l00428">TCP_EVENT_ACK</a>, <a class="el" href="tcp__ip_8h-source.html#l00405">TCP_EVENT_CLOSE</a>, <a class="el" href="tcp__ip_8h-source.html#l00397">TCP_EVENT_CONNECTED</a>, <a class="el" href="tcp__ip_8h-source.html#l00387">TCP_EVENT_CONREQ</a>, <a class="el" href="tcp__ip_8h-source.html#l00445">TCP_EVENT_DATA</a>, <a class="el" href="tcp_8c-source.html#l02346">tcp_initseq()</a>, <a class="el" href="tcp_8c-source.html#l02369">tcp_mapsocket()</a>, <a class="el" href="tcp_8c-source.html#l02455">tcp_newstate()</a>, <a class="el" href="tcp_8c-source.html#l02253">tcp_sendcontrol()</a>, <a class="el" href="tcp_8c-source.html#l02294">tcp_sendreset()</a>, <a class="el" href="tcp__ip_8h-source.html#l00335">TCP_STATE_CLOSED</a>, <a class="el" href="tcp__ip_8h-source.html#l00353">TCP_STATE_CLOSING</a>, <a class="el" href="tcp__ip_8h-source.html#l00362">TCP_STATE_CONNECTED</a>, <a class="el" href="tcp__ip_8h-source.html#l00346">TCP_STATE_FINW1</a>, <a class="el" href="tcp__ip_8h-source.html#l00349">TCP_STATE_FINW2</a>, <a class="el" href="tcp__ip_8h-source.html#l00333">TCP_STATE_FREE</a>, <a class="el" href="tcp__ip_8h-source.html#l00356">TCP_STATE_LAST_ACK</a>, <a class="el" href="tcp__ip_8h-source.html#l00336">TCP_STATE_LISTENING</a>, <a class="el" href="tcp__ip_8h-source.html#l00339">TCP_STATE_SYN_RECEIVED</a>, <a class="el" href="tcp__ip_8h-source.html#l00343">TCP_STATE_SYN_SENT</a>, <a class="el" href="tcp__ip_8h-source.html#l00359">TCP_STATE_TIMED_WAIT</a>, <a class="el" href="tcp__ip_8h-source.html#l00310">TCP_TYPE_SERVER</a>, <a class="el" href="tcp__ip_8h-source.html#l00621">tcb::type</a>, <a class="el" href="tcp__ip_8h-source.html#l00573">tcp_frame::urgent</a>, and <a class="el" href="tcp__ip_8h-source.html#l00571">tcp_frame::window</a>. </td> </tr></table><a name="a15" doxytag="tcp.c::process_tcp_out"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> INT16 process_tcp_out </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">INT8 </td> <td class="mdname" nowrap> <em>sockethandle</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>UINT8 * </td> <td class="mdname" nowrap> <em>buf</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>UINT16 </td> <td class="mdname" nowrap> <em>blen</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>UINT16 </td> <td class="mdname" nowrap> <em>dlen</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><dl compact><dt><b>Author: </b></dt><dd> <ul><li> Jari Lahti (<a href="mailto:jari.lahti@violasystems.com">jari.lahti@violasystems.com</a>) </ul></dl><dl compact><dt><b>Date: </b></dt><dd>16.07.2002 </dl><dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>sockethandle</em> </td><td>handle to processed socket </td></tr><tr><td valign=top><em>buf</em> </td><td>pointer to data buffer (where TCP header will be stored) </td></tr><tr><td valign=top><em>blen</em> </td><td>buffer length in bytes </td></tr><tr><td valign=top><em>dlen</em> </td><td>length of data in bytes </td></tr></table></dl><dl compact><dt><b>Returns: </b></dt><dd> <ul><li> -1 - Error <li> >0 - Packet OK</ul></dl>Based on data supplied as function parameters and data stored in socket's tcb, TCP header is created in buffer, checksum is calculated and packet is forwarded to lower layers (IP). <p>Definition at line <a class="el" href="tcp_8c-source.html#l02119">2119</a> of file <a class="el" href="tcp_8c-source.html">tcp.c</a>.<p>References <a class="el" href="ip_8c-source.html#l00539">ip_checksum()</a>, <a class="el" href="ip_8c-source.html#l00582">ip_checksum_buf()</a>, <a class="el" href="ip_8h-source.html#l00074">IP_TCP</a>, <a class="el" href="tcp__ip_8h-source.html#l00625">tcb::locport</a>, <a class="el" href="tcp__ip_8h-source.html#l00627">tcb::myflags</a>, <a class="el" href="ip_8c-source.html#l00300">process_ip_out()</a>, <a class="el" href="tcp__ip_8h-source.html#l00632">tcb::receive_next</a>, <a class="el" href="tcp__ip_8h-source.html#l00623">tcb::rem_ip</a>, <a class="el" href="tcp__ip_8h-source.html#l00624">tcb::remport</a>, <a class="el" href="tcp__ip_8h-source.html#l00629">tcb::send_mtu</a>, <a class="el" href="tcp__ip_8h-source.html#l00626">tcb::send_unacked</a>, and <a class="el" href="tcp__ip_8h-source.html#l00631">tcb::tos</a>.<p>Referenced by <a class="el" href="tcp_8c-source.html#l00481">tcp_send()</a>, and <a class="el" href="tcp_8c-source.html#l02253">tcp_sendcontrol()</a>. </td> </tr></table><a name="a16" doxytag="tcp.c::tcp_sendcontrol"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void tcp_sendcontrol </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">INT8 </td> <td class="mdname1" valign="top" nowrap> <em>sockethandle</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><dl compact><dt><b>Author: </b></dt><dd> <ul><li> Jari Lahti (<a href="mailto:jari.lahti@violasystems.com">jari.lahti@violasystems.com</a>) </ul></dl><dl compact><dt><b>Date: </b></dt><dd>17.07.2002 </dl><dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>sockethandle</em> </td><td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -