Linux Networks TCPIP Networking Layers BSD Socket Interface
Linux Networks TCP/IP Networking Layers BSD Socket Interface INET Socket Layer u. Create u. Bind u. Listen u. Accept u. Connect 回到第一頁
Network Applications User Kernel BSD Sockets Socket Interface INET Sockets TCP UDP Protocol Layers IP Network Devices PPP SLIP ARP Ethernet Linux Networking Layers 回到第一頁
files_struct count close_on_exec open_fs fd[0] fd[1] fd[255] file f_mode f_pos f_flags f_count f_owner f_op f_inode f_version inode BSD Socket File Operations lseek read write select ioctl close fasync socket SOCK_STREAM type protocol data SOCK_STREAM Address Family socket operations sock type protocol socket Linux BSD Socket Data Structure 回到第一頁
System Call n <net/socket. c> u int sys_socketcall(int call, unsigned long *args); u call F <linux/net. h> SYS_SOCKET --> socket() F SYS_BIND --> bind() F. . . F u args F args[] 回到第一頁
family n <include/linux/socket. h> u AF_UNIX F u AF_INET F u Appletalk DDP AF_X 25 F u Novell IPX AF_APPLETALK F u Internet IP Protocol AF_IPX F u Unix domain sockets Reserved for X. 25 project . . . 回到第一頁
type n <include/linux/socket. h> u SOCK_STREAM F u SOCK_DGRAM F u reliably-delivered message SOCK_SEQPACKET F u raw socket SOCK_RDM F u datagram (conn. less) socket SOCK_RAW F u stream (connection) socket sequential packet socket . . . 回到第一頁
protocol n <include/linux/in. h> u IPPROTO_IP F u IPPROTO_ICMP F u Transmission Control Protocol IPPROTO_EGP F u Internet Group Management Protocol IPPROTO_TCP F u Internet Control Message Protocol IPPROTO_IGMP F u Dummy protocol for TCP Exterior Gateway Protocol . . . 回到第一頁
socket(family, type, protocol) n <net/socket. c> u sys_socket(. . . ) u get an empty inode for socket structure u allocate a sock structure u return the file descriptor of the socket if success 回到第一頁
bind(fd, uaddr, addrlen) n <net/socket. c> u sys_bind(. . . ) u bind a name to a socket u move the socket address to kernel space u address & port checking 回到第一頁
listen(fd, backlog) n <net/socket. c> u sys_listen(. . . ) u allow the protocol to do anything necessary u move a socket into listening state 回到第一頁
accept(fd, sockaddr, skaddrlen) n <net/socket. c> u sys_accept(. . . ) u attempt to create a new socket u set up the link with the client u wake up the client u return the new fd 回到第一頁
connect(fd, uaddr, addrlen) n <net/socket. c> u sys_connect(. . . ) u attempt to connect to a socket with the server address u move the address to kernel space 回到第一頁
- Slides: 12