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

📄 [转载] linux的tcp-ip协议栈阅读笔记(3) - china linux forum.htm

📁 linux下的tcp/ip协议实现的确部分阅读笔记
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0110)http://www.linuxforum.net/forum/showflat.php?Cat=&Board=linuxK&Number=67724&page=192&view=collapsed&sb=5&o=all -->
<HTML><HEAD><TITLE>[转载] Linux的TCP/IP协议栈阅读笔记(3) - China Linux Forum</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
<BODY>
<CENTER><FONT color=red>著名软件中国镜像:</FONT> <A 
href="http://apache.linuxforum.net/"><FONT color=red>Apache|</FONT></A> <A 
href="http://php.linuxforum.net/"><FONT color=red>Php|</FONT></A> <A 
href="http://debian.linuxforum.net/"><FONT color=red>Debian|</FONT></A> <A 
href="http://mysql.linuxforum.net/"><FONT color=red>Mysql|</FONT></A> <A 
href="http://proftpd.linuxforum.net/"><FONT color=red>Proftp|</FONT></A> <A 
href="http://qmail.linuxforum.net/top.html"><FONT color=red>Qmail|</FONT></A> <A 
href="http://samba.linuxforum.net/samba.html"><FONT color=red>Samba|</FONT></A> 
<A href="http://www1.cn.squid-cache.org/"><FONT color=red>Squid|</FONT></A> <A 
href="http://xfree86.linuxforum.net/"><FONT color=red>Xfree86|</FONT></A> <A 
href="http://cpan.linuxforum.net/"><FONT color=red>CPAN|</FONT></A> <A 
href="http://ldp.linuxforum.net/"><FONT color=red>LDP|</FONT></A> <A 
href="http://gnu.linuxforum.net/"><FONT 
color=red>GNU|</FONT></A></CENTER><BR><LINK 
href="[转载] Linux的TCP-IP协议栈阅读笔记(3) - China Linux Forum.files/stylesheet2.css" 
rel=stylesheet type=text/css><SPAN class=onbody>
<TABLE align=center border=0 cellPadding=3 cellSpacing=0 class=p9 width="95%">
  <TBODY>
  <TR align=right bgColor=#0099cc vAlign=center>
    <TD align=left width="20%"><A 
      href="http://www.linuxforum.net/index.php"><FONT 
      color=#ffffff>中国Linux论坛首页</FONT></A></TD>
    <TD width="80%"><A 
      href="http://www.linuxforum.net/forum/ubbthreads.php"><FONT 
      color=#ffffff>技术论坛|</FONT></A><FON color="#FFFFFF" t> <A 
      href="http://www.linuxforum.net/docnew/index.php"><FONT 
      color=#ffffff>文章荟萃</FONT></A><FONT color=#ffffff>| <A 
      href="http://www.linuxforum.net/books/index.php"><FONT 
      color=#ffffff>藏经阁</FONT></A>| <A href="http://mail.linuxforum.net/"><FONT 
      color=#ffffff>会员信箱</FONT></A>| <A href="http://sf.linuxforum.net/"><FONT 
      color=#ffffff>项目计划</FONT></A>| <A 
      href="http://www.linuxforum.net/poll2/index.php"><FONT 
      color=#ffffff>在线调查</FONT></A>| <A href="ftp://ftp.linuxforum.net/"><FONT 
      color=#ffffff>软件仓库</FONT></A>| <A 
      href="http://www.linuxforum.net/about.php"><FONT 
      color=#ffffff>关于本站</FONT></A>| </FONT></TD></TR></TBODY></TABLE><BR></SPAN>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="95%">
  <TBODY>
  <TR>
    <TD class=tableborders>
      <TABLE border=0 cellPadding=3 cellSpacing=1 width="100%">
        <TBODY>
        <TR>
          <TD align=right class=menubar><A 
            href="http://www.linuxforum.net/forum/ubbthreads.php?Cat=">讨论区列表</A> 
            | <A href="http://www.linuxforum.net/forum/search.php?Cat=">搜寻文章</A> 
            | <A 
            href="http://www.linuxforum.net/forum/newuser.php?Cat=">新用户注册</A> | 
            <A href="http://www.linuxforum.net/forum/login.php?Cat=">登入论坛</A> | 
            <A href="http://www.linuxforum.net/forum/online.php?Cat=">在线用户</A> | 
            <A 
            href="http://www.linuxforum.net/forum/faq_chinese.php?Cat=">常见问题</A> 
          </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<P>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="95%">
  <TBODY>
  <TR>
    <TD class=tableborders>
      <TABLE border=0 cellPadding=3 cellSpacing=1 width="100%">
        <TBODY>
        <TR class=darktable>
          <TD>
            <TABLE cellPadding=0 cellSpacing=0 width="100%">
              <TBODY>
              <TR class=darktable>
                <TD align=left width="33%"><SPAN class=catandforum><A 
                  href="http://www.linuxforum.net/forum/ubbthreads.php?Cat=&amp;C=4">Linux 
                  高级应用</A> <BR>&nbsp;&nbsp;&nbsp;&gt;&gt; <A 
                  href="http://www.linuxforum.net/forum/postlist.php?Cat=&amp;Board=linuxK&amp;page=192&amp;view=collapsed&amp;sb=5&amp;o=all">Linux内核技术</A> 
                  </SPAN></TD>
                <TD align=middle width="33%">此话题阅读次数: 830 </TD>
                <TD align=right width="33%">
                  <TABLE border=0>
                    <TBODY>
                    <TR>
                      <TD class=navigation noWrap><IMG align=absMiddle alt=* 
                        src="[转载] Linux的TCP-IP协议栈阅读笔记(3) - China Linux Forum.files/greyflat.gif">平坦模式&nbsp; 
                      </TD>
                      <TD class=navigation noWrap><A 
                        href="http://www.linuxforum.net/forum/showthreaded.php?Cat=&amp;Board=linuxK&amp;Number=67724&amp;page=192&amp;view=collapsed&amp;sb=5&amp;o=all&amp;vc=1"><IMG 
                        align=absMiddle alt=树状模式,一封一封读 border=0 
                        src="[转载] Linux的TCP-IP协议栈阅读笔记(3) - China Linux Forum.files/threaded.gif">树状模式</A>&nbsp; 
                      </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=4 cellSpacing=0 width="95%">
  <TBODY>
  <TR>
    <TD align=left class=small>&nbsp; </TD>
    <TD align=right class=small><A 
      href="http://www.linuxforum.net/forum/printthread.php?Cat=&amp;Board=linuxK&amp;main=67724&amp;type=thread" 
      target=_blank><IMG align=top border=0 
      src="[转载] Linux的TCP-IP协议栈阅读笔记(3) - China Linux Forum.files/printthread.gif"> 
      打印</A> </TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="95%">
  <TBODY>
  <TR>
    <TD class=tableborders>
      <TABLE border=0 cellPadding=3 cellSpacing=1 width="100%">
        <TBODY>
        <TR>
          <TD class=darktable rowSpan=2 vAlign=top width="17%"><A 
            name=Post67724></A><A 
            href="http://www.linuxforum.net/forum/showprofile.php?Cat=&amp;User=tommytang&amp;Number=67724&amp;Board=linuxK&amp;what=showflat&amp;page=192&amp;view=collapsed&amp;sb=5&amp;o=all&amp;fpart=1&amp;vc=1">tommytang</A><BR><SPAN 
            class=small>(stranger)<BR>01/03/01 21:57<BR></SPAN></TD>
          <TD class=subjecttable width="83%">
            <TABLE border=0 class=subjecttable width="100%">
              <TBODY>
              <TR>
                <TD align=left width="70%"><IMG height=15 
                  src="[转载] Linux的TCP-IP协议栈阅读笔记(3) - China Linux Forum.files/book.gif" 
                  width=15> <B>[转载] Linux的TCP/IP协议栈阅读笔记(3)</B> </TD>
                <TD align=right width="30%">&nbsp; </TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD class=lighttable width="83%"><BR>
            <P class=post>发信人: AngelFalls (TRY IT), 信区: SysInternals<BR>标 题: 
            [转载] Linux的TCP/IP协议栈阅读笔记(3)<BR>发信站: 武汉白云黄鹤站 (Wed Oct 4 01:36:27 
            2000), 转信<BR><BR>【 以下文字转载自 Security 讨论区 】<BR>【 原文由 AngelFalls 所发表 
            】<BR>其中的sock_register函数的作用已经在前面说了,现在来看看<BR>struct 
            inet_protocol和inet_add_protocol函数。前面的结构体<BR>是在include/net/protocol.h里面:<BR>struct 
            inet_protocol <BR>{<BR>int (*handler)(struct sk_buff *skb, unsigned 
            short len);<BR>void (*err_handler)(struct sk_buff *skb, unsigned 
            char *dp, int len);<BR>struct inet_protocol *next;<BR>unsigned char 
            protocol;<BR>unsigned char copy:1;<BR>void *data;<BR>const char 
            *name;<BR>};<BR>第一个函数是用来接收数据的callback函数,第二个是错误处理函数,<BR>其它的copy是用来协议共享的,这个以后再说,data当然就是这个结<BR>构体的私有数据了。<BR><BR>inet_add_protocol函数是在net/ipv4/protocol.c里面的:<BR>void 
            inet_add_protocol(struct inet_protocol *prot)<BR>{<BR>unsigned char 
            hash;<BR>struct inet_protocol *p2;<BR><BR>hash = prot-&gt;protocol 
            &amp; (MAX_INET_PROTOS - 1);<BR>prot -&gt;next = 
            inet_protos[hash];<BR>inet_protos[hash] = prot;<BR>prot-&gt;copy = 
            0;<BR><BR>p2 = (struct inet_protocol *) prot-&gt;next;<BR>while(p2 
            != NULL) <BR>{<BR>if (p2-&gt;protocol == prot-&gt;protocol) 
            <BR>{<BR>prot-&gt;copy = 1;<BR>break;<BR>}<BR>p2 = (struct 
            inet_protocol *) 
            p2-&gt;next;<BR>}<BR>}<BR>显然这个函数就是作乐一个hash表,然后每个hash表项都是一个链表头,<BR>然后通过这个hash表加链表的方式访问每个协议结构体。在这里你也见<BR>到了copy成员的用法了把。<BR><BR>arp_init函数是在net/ipv4/arp.c里面的(假定没有定义CONFIG_SYSCTL):<BR><BR>neigh_table_init(&amp;arp_tbl);<BR>dev_add_pack(&amp;arp_packet_type);<BR>proc_net_register(&amp;proc_net_arp);<BR><BR>不知道是不是有人眼睛一亮啊,呵呵,看到了dev_add_pack函数。<BR>还是一步步来把。<BR>neigh_table_init函数在net/core/neighbour.c中间:<BR>void 
            neigh_table_init(struct neigh_table *tbl)<BR>{<BR>unsigned long now 
            = jiffies;<BR><BR>tbl-&gt;parms.reachable_time = 
            neigh_rand_reach_time(<BR>tbl-&gt;parms.base_reachable_time);<BR><BR>init_timer(&amp;tbl-&gt;gc_timer);<BR>tbl-&gt;gc_timer.data 

⌨️ 快捷键说明

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