The network layer
href="Network layer - The kernel structures_file/style.css" rel=stylesheet>
Network layer - The kernel structures
References:The
socket structure
The structure socket is defined in the header file
include/linux/net.h and is rather short,
state, the socket_state;
flags,
ops, pointer to the protocol functions;
inode, pointer to the associated inode;
fasync_list, asynchronous wake-up list;
file,
sk, pointer to a struct sock;
wait, wait queue head;
type, socket type;
passcred, The proto_ops and proto
structures
The protocol operations, struct proto_ops, are the user
interface API. At the user level there is only one system call
sys_socket(); the specific function is selected with an index.
Indeed the user systemcalls do not map 1-1 on the propotol functions.
bind(socket, umyaddr, addr_len),
release(socket),
connect(socket, uservaddr, addr_len, flags),
listen(socket, len),
accept(socket, new_socekt, flags),
getname(socket, uaddr, addr_len, peer),
sockedpair(socket_1, socket_2),
setsockopt(socket, level, optname, optval, optlen),
getsockopt(socket, level, optname, optval, optlen),
sendmsg(socket, msghdr, len, cookie),
recvmsg(socket, msghdr, len, flags, cookie),
mmap(file, socket, vma),
poll(file, socket, poll_table),
ioctl(socket, cmd, arg),
shutdown(socket, flags),
sendpage(socket, page, offset, size, flags), The
proto structure is a function table with pointers to routines for
the IP protocol, that operate on the sock structure. The functions are, mainly,
close(sock, timeout)
connect(sock, uaddr, addr_len)
disconnect(sock, flags)
accept(sock, flags, error_pointer)
ioctl(sock, cmd, arg)
init(sock)
destroy(sock)
shutdown(sock, how)
setsockopt(sock, level, optname, optval, optlen)
getsockopt(sock, level, optname, optval, option)
sendmsg(sock, msghdr, len)
recvmsg(sock, msghdr, len)
bind(sock, uaddr, addr_len)
backlog_rcv(sock, sk_buff)
get_port(sock, snum) The inet protocols are kept on
the list inetsw. At start three static protocols are added,
SOCK_STREAM, SOCK_DGRAM, and SOCK_RAW. These are permanent and cannot be
modified. Other protocols can be registered and unregistered with the functions
inet_register_protosw and inet_unregister_protosw
respectively. These take as parameter a pointer to a struct
inet_protosw which contains, among other things,
type and protocol, are the lookup key;
prot points to a struct proto;
ops points to a struct proto_ops; clear=all> src="Network layer - The kernel structures_file/socket.gif" width=480> clear=all>The sock structure
The structure sock is defined in the header
include/net/sock.h, and is rather large. There is a note in the source saying
that it really should be better organized. Among other things it contains
daddr, and dport: the destination address and
port;
rcv_saddr, local reveiving (bound) address;
num, local port;
next, pprev, bind_next,
bind_pprev hash linkage pointers;
state, connection state;
saddr and sport, source address and port;
family, address family;
refcnt, reference count;
sndbuf and rcvbuf, size of sending and receiving
buffer in bytes;
sleep, a wait_queue_head for the sock;
receive_queue, sk_buff_head of incoming packets;
write_queue, sk_buff_head of outgoing packets;
filter, pointer to a sk_filter;
socket, pointer to the socket; The sk_buff
structure
The socket buffer structure sk_buff is defined in
include/linux/skbuff.h, and contains (besides other things)
next and prev, because the socket buffer are
tied together in a doubly linked list;
list is the socket buffer list to which this sk_buff belongs;
sk, the socket the owns this sk_buff;
stamp, time of arrival;
dev, network device on which this sk_buff arrived;
h, a pointer to the transport layer header;
nh, a pointer to the network layer header;
mac, a pointer to the link layer header;
cb[48], control buffer (for private data);
len, length of actual data;
protocol, packet protocol number from the driver;
head, pointer to the head of buffer;
data, pointer to the beginning of data;
tail, pointer to the tail of data;
end, pointer to the end of buffer; clear=all>Marco Corvi - 2003
language=JavaScript>var PUpage="76001084"; var PUprop="geocities";
src="Network layer - The kernel structures_file/pu5geo.js">
src="Network layer - The kernel structures_file/ygIELib9.js">
var yviContents='http://us.toto.geo.yahoo.com/toto?s=76001084&l=NE&b=1&t=1057747006';yviR='us';yfiEA(0);
src="Network layer - The kernel structures_file/mc.js">
src="Network layer - The kernel structures_file/geov2.js">
geovisit();
src="Network layer - The kernel structures_file/visit.gif" width=1
border=0> src="Network layer - The kernel structures_file/serv.gif" width=1>