Linux Networking Subsystem

时间:2012-03-14 05:47:12
【文件属性】:
文件名称:Linux Networking Subsystem
文件大小:351KB
文件格式:PDF
更新时间:2012-03-14 05:47:12
Linux Network 1 Introduction 1 1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Document Conventions . . . . . . . . . . . . . . . . . . . . . . 1 1.3 Sample Network Example . . . . . . . . . . . . . . . . . . . . 1 2 Initialization 3 2.1 Function do basic setup() . . . . . . . . . . . . . . . . . . . . 3 2.2 Function sock init() . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2.1 Function sk init() . . . . . . . . . . . . . . . . . . . . . 8 2.2.2 Function skb init() . . . . . . . . . . . . . . . . . . . . 10 2.2.2.1 union skb head pool . . . . . . . . . . . . . . 11 2.2.2.2 Function skb queue head init() . . . . . . . . 11 2.2.2.3 struct sk bu? head . . . . . . . . . . . . . . . 11 2.2.3 Function wanrouter init() . . . . . . . . . . . . . . . . 12 2.2.3.1 Function wanrouter proc init() . . . . . . . . 12 2.2.3.2 Function sdladrv init() . . . . . . . . . . . . . 12 2.2.3.3 wanpipe init() . . . . . . . . . . . . . . . . . 12 2.2.4 Netlink sockets . . . . . . . . . . . . . . . . . . . . . . 12 2.2.5 Function rtnetlink init() . . . . . . . . . . . . . . . . . 12 2.2.5.1 Function netlink kernel create() . . . . . . . . 13 2.2.5.2 Function register netdevice notifier() . . . . . 13 2.2.6 Function init netlink() . . . . . . . . . . . . . . . . . . 13 2.2.7 Function netfilter init() . . . . . . . . . . . . . . . . . . 15 2.2.8 Function bluez init() . . . . . . . . . . . . . . . . . . . 15 2.3 Function do initcalls() . . . . . . . . . . . . . . . . . . . . . . 16 2.4 Function netlink proto init() . . . . . . . . . . . . . . . . . . . 16 2.5 Function inet init() . . . . . . . . . . . . . . . . . . . . . . . . 17 2.5.1 Function sock register() . . . . . . . . . . . . . . . . . 22 2.5.1.1 struct net proto family . . . . . . . . . . . . . 23 iii iv CONTENTS 2.5.2 Adding INET Protocols . . . . . . . . . . . . . . . . . 24 2.5.2.1 struct inet protocol . . . . . . . . . . . . . . . 24 2.5.2.2 Function inet add protocol() . . . . . . . . . . 26 2.5.3 Register Socket Interfaces . . . . . . . . . . . . . . . . 28 2.5.3.1 struct inet protosw . . . . . . . . . . . . . . . 28 2.5.3.2 struct proto . . . . . . . . . . . . . . . . . . . 29 2.5.3.3 struct proto ops . . . . . . . . . . . . . . . . 31 2.5.3.4 Array inetsw array . . . . . . . . . . . . . . . 33 2.5.3.5 Function inet register protosw(..) . . . . . . . 36 2.5.4 Initializing Protocols . . . . . . . . . . . . . . . . . . . 36 2.5.4.1 struct packet type . . . . . . . . . . . . . . . 36 2.5.4.2 Function dev add pack() . . . . . . . . . . . . 37 2.5.5 Function arp init() . . . . . . . . . . . . . . . . . . . . 39 2.5.5.1 arp packet type . . . . . . . . . . . . . . . . . 39 2.5.5.2 Function neigh table init(..) . . . . . . . . . . 40 2.5.5.3 Function neigh sysctl register(..) . . . . . . . 40 2.5.6 Function ip init() . . . . . . . . . . . . . . . . . . . . . 40 2.5.6.1 ip packet type . . . . . . . . . . . . . . . . . 41 2.5.6.2 Function ip rt init() . . . . . . . . . . . . . . 41 2.5.6.3 Function inet initpeers() . . . . . . . . . . . . 43 2.5.7 Function tcp v4 init(..) . . . . . . . . . . . . . . . . . . 44 2.5.8 Function tcp init() . . . . . . . . . . . . . . . . . . . . 46 2.5.8.1 Function tcpdiag init() . . . . . . . . . . . . . 50 2.5.9 Function icmp init(..) . . . . . . . . . . . . . . . . . . . 51 2.5.10 Function ipip init() . . . . . . . . . . . . . . . . . . . . 53 2.5.11 Function ipgre init() . . . . . . . . . . . . . . . . . . . 53 2.5.12 Function ip mr init() . . . . . . . . . . . . . . . . . . . 54 2.6 Function af unix init() . . . . . . . . . . . . . . . . . . . . . . 54 2.7 Function packet init() . . . . . . . . . . . . . . . . . . . . . . 56 2.7.0.1 Function register netdevice notifier(..) . . . . 57 2.7.0.2 struct notifier block . . . . . . . . . . . . . . 57 3 BSD Sockets 59 3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 4 INET Sockets 61 4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 5 Transport Layer 63 5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 CONTENTS v 6 Network Layer 65 6.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 7 Syscall Trace 67 7.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 7.2 Socket structres . . . . . . . . . . . . . . . . . . . . . . . . . . 67 7.3 Syscalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 7.3.1 Establishing Connection . . . . . . . . . . . . . . . . . 67 7.3.2 socket creation . . . . . . . . . . . . . . . . . . . . . . 67 7.3.3 bind walkthrough . . . . . . . . . . . . . . . . . . . . . 67 7.3.4 listen walkthrough . . . . . . . . . . . . . . . . . . . . 67 7.3.5 accept walkthrough . . . . . . . . . . . . . . . . . . . . 67 7.3.6 connect walkthrough . . . . . . . . . . . . . . . . . . . 67 7.3.7 close walkthrough . . . . . . . . . . . . . . . . . . . . . 67 7.4 Linux Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 67 8 Receiving Messages 69 8.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 8.2 Receiving Walkthrough . . . . . . . . . . . . . . . . . . . . . . 69 8.2.1 Reading from a socket - I . . . . . . . . . . . . . . . . . 69 8.2.2 Receiving a Packet . . . . . . . . . . . . . . . . . . . . 69 8.2.3 SoftIRQ - net rx action . . . . . . . . . . . . . . . . . . 69 8.2.4 Unwrapping Packet in IP . . . . . . . . . . . . . . . . . 69 8.2.5 Accepting a Packet in UDP . . . . . . . . . . . . . . . 69 8.2.6 Accepting a Packet in TCP . . . . . . . . . . . . . . . 69 8.2.7 Reading from a Socket - II . . . . . . . . . . . . . . . . 69 8.3 Linux Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 69 9 Sending Messages 71 9.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 9.2 Sending Walkthrough . . . . . . . . . . . . . . . . . . . . . . . 71 9.2.1 Writing to a socket . . . . . . . . . . . . . . . . . . . . 71 9.2.2 Creating a Packet with UDP . . . . . . . . . . . . . . . 71 9.2.3 Creating a Packet with TCP . . . . . . . . . . . . . . . 71 9.2.4 Wrapping a Packet in IP . . . . . . . . . . . . . . . . . 71 9.2.5 Transmitting a Packet . . . . . . . . . . . . . . . . . . 71 9.3 Linux Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 71 10 IP Routing 73 10.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 vi CONTENTS 11 IP Forwarding 75 11.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 12 Netfilter 77 12.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 GNU Free Document License 79 Bibliography 81

网友评论

  • 还不错,不过重点不是原理,而是代码,不易看懂。