网络内核阅读笔记_第1页
网络内核阅读笔记_第2页
网络内核阅读笔记_第3页
网络内核阅读笔记_第4页
网络内核阅读笔记_第5页
已阅读5页,还剩267页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Linux2.4网络内核源代码阅读笔记

应用层网络接口

#include<sys/types.h>

#include<sys/socket.h>

intsocket(intfamily,inttype,intprotocol)

/东服务器与客户端都调用socket。来建立socket*/

其中:(1)family指明套节字协议族,其值包括:

AF_UNIX(UNIX内部协议族)

AF_INET(Internet协议族)

AF_NS(XeroxNs协议,TCP/IP编程取该值)

AF_IMPLINK(IMP链接层)

(2)type指明套接字类型,取值有:

SOCK_STREAM(流套接字)

SOCK_DGRAM(数据报套接字)

SOCK_RAW(原始套接字)

SOCK_SEQPACKET(定序分组套接字)

股情况卜.,前两个参数的组合的可以决定所使用的协议,这时第三个参数被置为0,如果第一个参数为AFJNET

第:个参数选SOCK_STREAM,则使用的协议为TCP;第.个参数选SOCK_DGRAM,则使用的协议为UDP:

当第:个参数选SOCK_RAW时,使用的协议为IP。值得指出的是并不是所有的族和类型的组合都是合法的,

具体请查阅相关资料。该系统调用若成功则返一个类似文件描述符,称为套接口描述字,可以像文件描述符

那样用read和write对其进行I/O操作。当一个进程使用完该软插座时,需用close(<描述符〉)关闭。

intbind(intsocketfd,structsockaddrjn*localaddr,sizeof(structsockaddrjn))

/*服务器端Bind系统调用*/

其中:

(1)第一个参数socketfd是前步socket。系统调用返回的套节字描述符。

(2)笫二个参数被捆向本地地址的一种结构,该结构在sys/netinet/in.h中定义:

structsockaddr_in{

shortsin_family;/*socket。系统调用的协议族如AF_INET*/

u_shortsin_port;/*网络字节次序形式的端口号码*/

structin_addrsin_addr;/*网络字节次序形式的网络地址*/

charsin_zero[8];

):

/'一台机器上的每一个网络程序都使用一个各自独立的网络端口号。如telnet使用23端口

ftp使用21端口,我们在写程序的时候,可以通过调用getservbyname。函数从etc/services

辉文件中得到端口号,也可以使用htons(intportnum)函数k转换为网络字节次序

来得到,有些版本的unix规定1024以卜一端口只能被超级用户使用,普通用户只能使用

1025-32767之间的端I」号,网络地址可以由gethostbyname(char*hostname)函数得到

(该函数与getservbyname()一样都是以网络字节次序形式返回所有在他们结构中的数据),

参数hostname为etc/hosts文件中某个网络地址所对应的机器名,该函数返回一个类型为

hostent的结构体指针,该结构体hostent在netdb.h

*/

structhostent{

char*h_name;

char**h_aliases;

inth_addrtype;

inth」ength;/*地址长度*/

char**h_addr_list;

井defineh_addrh_addr_list[O];/*地址*/

}:

(3)笫:个参数为第.个结构参数的长度,如果调用成功,bind返回0,否则将返回一1并设置errno。

intlisten(intsockedfd,intbacklog)

/*面向连接的服务器端系统调用listen,表示服务器愿意接受连接*/

它通常是在socket。和bind。调用后,在accept。调用前执行。第二个参数指定accept

调用时系统可以等待多少个连接请求o

intnewsocket=accept(intsocketfd,structsockaddrjn*peer,int*addlen);

/*服务器调用accept,以等待客户机调用connect进行连接。*/

调用等待队列中的第一个连接请求,并建立一个与socketfd一样特征的套接字。

如果没有等待的连接请求,此调用阻塞调用者一直到连接请求到达。

连接成功后,该accept。调用将把对端的地址结构和地址长度放到到参数peer和addlen中,

如果服务器端对客户端的地址信息不感兴趣,这两个参数可以用0代替。

intconnect(intsocketfd,structsockaddrjn*servsaddr,intaddrlen)

/*客户端调用connect。与服务器建立连接*/

客户端取得套接字描述符后,用该connect。调用建立。服务器的连接,

参数socketfd为socket。调用返回的套接字描述符,第和第1个参数是指向想要连接的

目的地址的结构和地址长度。调用成功返回0,否则将返回一1并设置errno.

/*通过建立的socket发送和接收数据*/

一旦建立连接,就可以通过调用read()和write像普通文件一样向网络上发送和接收数据。

intread(intsockfd,char*buff,intnbytes)

Read。有三个参数:一个是套接字描述符,个为数据将被加入的数据缓冲区,还仃一个整数指明要要接受的数据的长度,

Read。返Ml实际接收到的了节数,出错返回-1,遇到文件尾则返回0。

intwrite(intsockfd,char*buff,intnbytes)

Write。有三个参数:•个是套接字描述符,个为指向需要发送的数据的缓冲区,还有一个整数为要写入到文件中的字节个数,

它返回实际写入的字」数,出错返回-10

intsend(intsockfd,char*buff,intnbytes,intflags);

intrecv(intsockfd,char*buff,intnbytes,intflags);

也可以调用send和recv来对套节字进行读写,其调用与基本的read和write系统调用相似,只是多了一个发送方式参数flags,

intsendto(intsockfd,char*buff,intnbytes,intflags,structsockaddr*to,intaddrlen);

intrecvfrom(intsockfd,char*buff,intnbytes,intflags,structsockaddr*from,intaddrlen);

对于使用无连接协议的服务器程序和客户端程序的流程,

客户端程序并不和服务器程序建迂连接,它是通过使用服务器地址作为参数的sendto()系统调用,

发送一个数据报给服务器的。同样,服务器并不接受客户端的连接,而是川recvfrom()调用等待从客户端来的数据。

这些调用与标准的系统调用read()^11write。相似。

这些调用需要附加的参数.Flag参数可以是。或者下列常数:

MSG_OOB接受或发送绑定外的数据

MSG_PEEK监视进入信息

MSG_DONTROUTE绕过路由

intclose(socketfd)

/*退出程序时,应按正常方式关闭套节字号

Socket及协议管理层

include\linux\fs.h

描述:ljsocket相关的文件系统部分结构体

Structinode

structinode{

structIist_headi_hash;

structlist_headUist;

structlist_headi_dentry;

structlist_headi_dirty_buffers;

structlist_headi_dirty_data_buffers;

unsignedlongLino;

atomic_ti_count;

kdev_ti_dev;

umode_ti_mode;

nlink_ti.nlink;

uid_tLuid;

gid_ti_gid;

kdev_ti_rdev;

lofOi_size;

time_ti_atime;

i_mtime;

time_ti_ctime;

unsignedinti_blkbits;

unsignedlongi_blksize;

unsignedlongi_blocks;

unsignedlongi_version;

structsemaphorei_sem;

structsemaphorei_zombie;

structinode_operations*i_op;

structfile_operations*i_fop;/*former->i_op->default_file_ops*/

structsuper_block*i_sb;

wait_queue_head_ti_wait;

structfile_lock*i_flock;

structaddress_space*i_mapping;

structaddress_spacei_data;

structdquot*i_dquot[MAXQUOTAS];

/*Thesethreeshouldprobablybeaunion*/

structlist_headi_devices;

structpipe_inode_info*i_pipe;

structblock_device*i_bdev;

structchar_device*i_cdev;

unsignedlongi_dnotify_mask;/*Directorynotifyevents*/

structdnotify_struct*i_dnotify;/*fordirectorynotifications*/

unsignedlongi_state;

unsignedintijlags;

unsignedchari_sock;

atomic_ti_writecount;

unsignedinti_attr_flags;

_u32Lgeneration;

union{

structminix_inode_infominix__i;

structext2_inode_infoext2_i;

structext3_inode_infoext3_i;

structhpfs_inode_infohpfs_i;

structntfs_inode_infontfs_i;

structmsdos_inode_infomsdos_i;

structumsdos_inode_infbumsdos_i;

structiso_inode_infoisofis_i;

structnfs_inode_infonfs_i;

structsysv_inode_infosysv_i;

structaffs_inode_infoaffs_i;

structufs_inode_infoufs_i;

structefs_inode_infoefs_i;

structromfs_inode_inforomfs_i;

structshmem_inode_infbshmem_i

structcoda_inode_infocoda_i;

structsmb_inode_infosmbfs_i;

structhfs_inode_infohfs_i;

structadfs_inode_infoadfs_i;

structqnx4_inode_infbqnx4_i;

structreiserfs_inode_inforeiserfs_i;

structbfs_inode_infobfs_i;

structudf_inode_infoudU;

structncp_inode_infoncpfs_i;

structproc_inode_infoproc_i;

structsocketsocket_i;

structusbdev_inode_infousbdev_i

structjffis2_inode_infojffs2_i;

void*generic_ip;

}u;

);

structfile

structfile{

structlist_headfjist;

structdentry*f_dentry;

structvfsmount*Cvfsmnt;

structfileoperations*f,op;

atomic_tf_count;

unsignedintLflags;

mode_tf_mode;

lofLtf_pos;

unsignedlongJreada,匚ramax,Jraend,匚ralen,Lrawin;

structfbwn__structf_owner;

unsignedintLuid,fLgid;

intCerror;

unsignedlongCversion;

/*neededforttydriver,andmaybeothers*/

void*private_data;

/*preallocatedhelperkiobuftospeedupO_DIRECT*/

structkiobuf*Mobuf;

longCiobuf_lock;

);

structfile_operations

/*

*NOTE:

*read,write,polkfsync,readv,writevcanbecalled

*withoutthebigkernellockheldinallfilesystems.

*/

structfile_operations{

structmodule"owner;

loff_t(*llseek)(structfile*,loff_t,int);

ssize_t(*read)(structfile*,char*,size_t,lofLt*);

ssize_t(*write)(structfile*,constchar*,size_t,lofO*);

int(*readdir)(structfile*,void*,filldir_t);

unsignedint(*poH)(structfile*,structpoll_table_struct*);

int(*ioctl)(structinode*,structfile*,unsignedint,unsignedlong);

int(*mmap)(structfile*,structvm_area_struct*);

int(*open)(structinode*,structfile*);

int(*flush)(structfile*);

int(*release)(structinode*,structfile*);

int(*fsync)(structfile*,structdentry*,intdatasync);

int(*fasync)(int,structfile*,int);

int(*lock)(structfile*,int,structfile_lock*);

ssize_t(*readv)(structfile*,conststructiovec*,unsignedlong,lofO*);

ssize_t(*writev)(structfile*,conststructiovec*,unsignedlong,lofLt*);

ssize_t(*sendpage)(structfile*,stmctpage*,int,size_t,loffLt*,int);

unsignedlong(*get_unmapped_area)(structfile*,unsignedlong,unsignedlong,unsigned

long,unsignedlong);

);

include\linux\skbuff.h

structsk_buff_head

structsk_buff_head{

/*Thesetwomembersmustbefirst.*/

structsk_buff*next;

structsk_buff*prev;

―u32qlen;

spinlock_tlock;

);

structsk_buff

structsk_buff{

/*Thesetwomembersmustbefirst.*/

structsk_buff*next;/*Nextbufferinlist*/

structsk_buff*prev;/*Previousbufferinlist*/

structsk_bufLhead*list;/*Listweareon*/

structsock*sk;/*Socketweareownedby*/

structtimevalstamp;/*Timewearrived*/

structnet_device*dev;/*Devicewearrivedon/areleavingby*1

/*Transportlayerheader传输层头部结构体*/

union

(

structtcphdr*th;

structudphdr*uh;

structicmphdr*icmph;

structigmphdr*igmph;

structiphdr*ipiph;

structspxhdr*spxh;

unsignedchar*raw;

}h;

/*Networklayerheader网络层头部结构体*/

union

(

structiphdr*iph;

structipv6hdr*ipv6h;

structarphdr*arph;

structipxhdr*ipxh;

unsignedchar*raw;

}nh;

/*Linklayerheader数据链路层头部结构体*/

union

(

structethhdr*ethemet;

unsignedchar*raw;

}mac;

/*该数据报的传输路由信息结构体*/

structdst_entry*dst;

*Thisisthecontrolbuffer.Itisfreetouseforevery

*layer.Pleaseputyourprivatevariablesthere.Ifyou

*wanttokeepthemacrosslayersyouhavetodoaskb_clone()

*first.ThisisownedbywhoeverhastheskbqueuedATM.

*1

/*这个字符数组是一个控制缓冲区,每一层都可以自由使用。

请把你的私有变量存放在这儿。如果你想要这个数组的数据

在每一层都可以使用,那么你必须调用skb_clone()函数。

*/

charcb(48];

unsignedintlen;/*Lengthofactualdata整个数据报的实际长度*/

unsignedintdata_len;

unsignedintcsum;/*Checksum*/

unsignedchar_unused,/*Deadfield,maybereused*/

cloned,/*headmaybecloned(checkrefcnttobesure).*/

pkt_type,/*Packetclass*/

ip_summed;/*DriverfedusanIPchecksum*/

_u32priority;/*Packetqueueingpriority*/

atomic_tusers;/*Usercount-seedatagram.c,tcp.c*/

unsignedshortprotocol;/*Packetprotocolfromdriver.*1

unsignedshortsecurity;/*Securitylevelofpacket列

unsignedinttruesize;/*Buffersize整个缓冲区的大小*/

unsignedchar*head;/*Headofbuffer缓冲区起始地址*/

unsignedchar*data;/*Dataheadpointer协议数据报的起始地址*/

unsignedchar*tail;/*Tailpointer协议数据报尾地址*/

unsignedchar*end;/*Endpointer整个缓冲区的尾地址*/

void(*destructor)(structsk_buff*);/*Destructfunction*/

#ifdefCONFIG_NETFILTER

/*Canbeusedforcommunicationbetweenhooks.*/

unsignedlongnfmark;

/*Cacheinfo*/

_u32nfcache;

/*Associatedconnection,ifany*/

structnfLct_info*nfct;

#ifdefCONFIG_NETFIETER_DEBUG

unsignedintnCdebug;

#endif

#endif/*CONFIGNETFILTER*/

#ifdefined(CONF!G_HIPPI)

union{

—u32ifield;

}private;

#endif

#ifdefCONFIG_NET_SCHED

―u32tc_index;/*trafficcontrolindex*/

#endif

);

include\net\sock.h

structinet_opt

structinet_opt{

intttl;/*TTLsetting*/

inttos;/*TOS*/

unsignedcmsg_flags;

structip_options*opt;

unsignedcharhdrincl;/*Includeheaders?*1

_u8/*MulticastingTTL*/

_u8mc_loop;/*Loopback*/

unsignedrecverr:1,

freebind:1;

_ul6id;1*IDcounterforDFpkts*/

_u8pmtudisc;

intmc_index;/*Multicastdeviceindex*/

_u32mc_addr;

structip_mc_socklist/*Grouparray*/

);

structtcp_opt

描述:Linux_2.4.1网络套接字内部包含了一个由tcp_opt结构

组成的共计420个字节的传输控制块

structtcp_opt{

inttcp_header_len;/*Bytesoftcpheadertosend*/

/*

*Headerpredictionflags

*0x5?10«16+snd_wndinnetbyteorder

*/

,u32pred_flags;

*RFC793variablesbytheirpropernames.Thismeansyoucan

*readthecodeandthespecsidebyside(andlaugh...)

*SeeRFC793andRFC1122.TheRFCwritestheseincapitals.

*/

_u32rcv_nxt;/*Whatwewanttoreceivenext*/

_u32snd_nxt;/*Nextsequencewesend*/

_u32snd_una;/*Firstbytewewantanackfor*/

_u32snd_sml;/*Lastbyteofthemostrecentlytransmittedsmallpacket*/

_u32rcv_tstamp;/*timestampoflastreceivedACK(forkeepalives)*/

_u32Isndtime;/*timestampoflastsentdatapacket(forrestartwindow)*/

/*DelayedACKcontroldata*/

struct{

一u8pending;/*ACKispending*/

一u8quick;/*Schedulednumberofquickacks*/

_u8pingpong;/*Thesessionisinteractive*/

_u8blocked;/*DelayedACKwasblockedbysocketlock*/

_u32ato;/*Predictedtickofsoftclock*/

unsignedlongtimeout;/*Currentlyscheduledtimeout*/

_u32Ircvtime;/*timestampoflastreceiveddatapacket*/

—u16last_seg_size;/*Sizeoflastincomingsegment*/

—ul6rcv_mss;/*MSSusedfordelayedACKdecisions*1

}ack;

/*Datafordirectcopytouser*/

struct{

structskbuffheadprequeue;

structtask__struct*task;

structiovec*iov;

intmemory;

intlen;

}ucopy;

—u32snd_wl1;/*Sequenceforwindowupdate*/

—u32snd_wnd;/*Thewindowweexpecttoreceive*/

―u32max_window;/*Maximalwindoweverseenfrompeer*/

_u32pmtu_cookie;/*Lastpmtuseenbysocket*/

_ul6mss_cache;/*Cachedeffectivemss,notincludingSACKS*/

_u!6mss_clamp;/*Maximalmss,negotiatedatconnectionsetup*/

—ul6ext_header_len;/*Networkprotocoloverhead(IP/IPv6options)*/

_u8ca_state;/*Stateoffast-retransmitmachine*/

一u8retransmits;/*NumberofunrecoveredRTOtimeouts.*/

_u8reordering;/*Packetreorderingmetric.*/

一u8queue_shrunk;/*Writequeuehasbeenshrunkrecently.*/

一u8defer_accept;/*Userwaitsforsomedataafteraccept()*/

/*RTTmeasurement*/

_u8backoff;/*backoff*/

_u32srtt;/*smothedroundtriptime«3*/

_u32mdev;/*mediumdeviation*/

_u32mdev_max;/*maximalmdevforthelastrttperiod*/

_u32rttvar;/*smoothedmdev_max*/

_u32rtt_seq;/*sequencenumbertoupdaterttvar*/

_u32rto;/*retransmittimeout*/

_u32packets_out:/*Packetswhichare"inflight"*/

_u32left_out;/*Packetswhichleavednetwork*/

_u32retrans_out;/*Retransmittedpacketsout*/

*Slowstartandcongestioncontrol(seealsoNagle,andKam&Partridge)

*/

—u32snd_ssthresh;/*Slowstartsizethreshold*/

―u32snd_cwnd;/*Sendingcongestionwindow*/

_ul6snd_cwnd_cnt;/*Linearincreasecounter*/

_ul6snd_cwnd_clamp;/*Donotallowsnd_cwndtogrowabovethis*/

_u32snd_cwnd_used;

―u32snd_cwnd_stamp;

/*Twocommonlyusedtimersinbothsenderandreceiverpaths.*/

unsignedlongtimeout;

structtimer_listretransmit_timer;/*Resend(noack)*/

structtimerjistdelack_timer;/*Ackdelay*/

/*out_of_order_queue用于接收无序得tcp包*/

structsk_bufLheadout_oLorder_queue;/*Outofordersegmentsgohere*/

/*OperationswhichareAF_INET{4,6}specific*/

structtcp_func^af_specific;

structsk_buff*send_head;/*Frontofstufftotransmit*/

structpage*sndmsg_page;/*Cachedpageforsendmsg*/

u32sndmsg_off;/*Cachedoffsetforsendmsg*/

—u32rcv_wnd;/*Currentreceiverwindow*/

—u32rcv_wup;/*rcv_nxtonlastwindowupdatesent*/

—u32write_seq;/*Tail(+1)ofdataheldintcpsendbuffer

_u32pushed_seq;/*Lastpushedseq,requiredtotalktowindows*/

―u32copied_seq;/*Headofyetunreaddata*/

Optionsreceived(usuallyonlastpacket,someonlyonSYNpackets).

*/

chartstamp_ok,/*TIMESTAMPseenonSYNpacket*/

wscale_ok,/*WscaleseenonSYNpacket*/

sack_ok;/*SACKseenonSYNpacket*/

charsaw_tstamp;/*SawTIMESTAMPonlastpacket*/

_u8snd_wscale;/*Windowscalingreceivedfromsender*/

一u8rcv_wscale;/*Windowscalingtosendtoreceiver*/

一u8nonagle;/*DisableNaglealgorithm?*/

_u8keepalive_probes;/*numofallowedkeepaliveprobes*/

PAWS/RTTMdata*/

_u32rcv_tsval;/*Timestampvalue*/

―u32rcv_tsecr;/*Timestampechoreply*/

_u32ts_recent;/*Timestamptoechonext*/

longts_recent_stamp;/*Timewestoredts_recent(foraging)*1

SACKsdata*/

_u16user_mss;/*mssrequestedbyuserinioctl*/

_u8dsack;/*D-SACKisscheduled*/

_u8eff_sacks;/*SizeofSACKarraytosendwithnextpacket*/

structtcp_sack_blockduplicate_sack[1];/*D-SACKblock*/

structtcp_sack_blockselective_acks[4];/*TheSACKSthemselves*/

―u32window_clamp;/*Maximalwindowtoadvertise*/

―u32rcv_ssthresh;/*Currentwindowclamp*/

一u8probes_out;/*unanswered0windowprobes*/

一u8num_sacks;/*NumberofSACKblocks*/

—ul6advmss;/*AdvertisedMSS*/

_u8syn_retries;/*numofallowedsynretries*/

_u8ecn_flags;/*ECNstatusbits.*/

_ul6prior_ssthresh;/*ssthreshsavedatrecoverystart*/

―u32lost_out;/*Lostpackets*/

―u32sacked_out;/*SACK'dpackets*/

―u32fackets_out;/*FACK'dpackets*/

―u32high_seq;/*snd_nxtatonsetofcongestion*/

―u32retrans_stamp;/*Timestampofthelastretransmit,

*alsousedinSYN-SENTtorememberstampof

*thefirstSYN.*/

―u32undo_marker;/*trackingretransstartedhere.*/

intundo_retrans;/*numberofundoableretransmissions.*/

_u32urg_seq;/*Seqofreceivedurgentpointer*/

一u!6urg_data;/*SavedoctetofOOBdataandcontrolflags*/

_u8pending;/*Scheduledtimerevent*/

_u8urg_mode;/*Inurgentmode*/

_u32snd_up;/*Urgentpointer*/

/*Thesyn_wait_lockisnecessaryonlytoavoidtcp_get_infohaving

*tograbthemainlocksockwhilebrowsingthelisteninghash

*(otherwiseit'sdeadlockprone).

*Thislockisacquiredinreadmodeonlyfromtcp_get_info()and

*it'sacquiredinwritemode_only_fromcodethatisactively

*changingthesyn_wait_queue.Allreadersthatareholding

*themastersocklockdon'tneedtograbthislockinreadmode

*tooasthesyn_wait_queuewritesarealwaysprotectedfrom

*themainsocklock.

*/

rwlock_tsyn_wait_lock;

structtcplistenopt*listen_opt;

/*FIFOofestablishedchildren*/

structopen_request^acceptjqueue;

structopenjrequest^acceptjqueueJail;

intwrite_pending;/*Awritetosocketwaitstostart.*1

unsignedintkeepalive_time;/*timebeforekeepalivetakesplace*/

unsignedintkeepalive_intvl;/*timeintervalbetweenkeepaliveprobes*/

intlinger2;

unsignedlonglast_synq_overflow;

);

structsock

structsock{

/*Socketdemultiplexcomparisonsonincomingpackets.*/

_u32daddr;/*ForeignIPv4addr*/

_u32rcv_saddr;/*BoundlocalIPv4addr*/

—u!6dport;/*Destinationport*/

unsignedshortnum;/*Localport*/

intbound_dev_if;/*Bounddeviceindexif!=0*/

/*Mainhashlinkageforvariousprotocollookuptables.*/

structsock*next;

structsock**pprev;

structsock*bind_next;

structsock**bind_pprev;

volatileunsignedcharstate,/*Connectionstate*/

zapped;/*Inax25&ipxmeansnotlinked*/

_ul6sport;/*Sourceport*/

unsignedshortfamily;/*Addressfamily*/

unsignedcharreuse;/*SO_REUSEADDRsetting*/

unsignedcharshutdown;

atomic_trefcnt;/*Referencecount*/

socket_lock_tlock;/*Synchronizer...*/

/*接收缓冲区字节长度*/

intrcvbuf;/*Sizeofreceivebufferinbytes*/

wait_queue_head_t*sleep;/*Sockwaitqueue*/

structdst_entry*dst_cache;/*Destinationcache*/

rwlock_tdst_lock;

/*接收队列已经提交的字节数*/

atomic_trmem_alloc;/*Receivequeuebytescommitted*/

/*接收的数据报的队列号

structsk_buff_headreceive_queue;/*Incomingpackets*/

/*发送队列已提交的字节数*/

atomic_twniem_alloc;/*Transmitqueuebytescommitted*/

/*发送数据报的队列*/

structsk_bufL_headwrile_queue;/*Packetsendingqueue*/

atomic_tomem_alloc;/*nonis"option"or"other"*/

intwmem_queued;/*Persistentqueuesize*/

intfbrward_alloc;/*Spaceallocatedforward.*/

—u32saddr;/*Sendingsource*/

unsignedintallocation;/*Allocationmode*/

/*发送缓冲区的字节长度刃

intsndbuf;/*Sizeofsendbufferinbytes*/

structsock*prev;

/*Notallarevolatile,butsomeare,sowemightaswellsaytheyallare.

*XXXMakethisaflagword-DaveM

*/

volatilechardead,

done,

urginline,

keepopen,

linger,

destroy,

no_check,

broadcast,

bsdism;

unsignedchardebug;

unsignedcharrcvtstamp;

unsignedcharuse_write_queue;

unsignedcharuserlocks;

/*Holeof3bytes.Trytopack.*/

introute_caps;

intproc;

unsignedlonglingertime;

inthashent;

structsock*pair;

/*Thebacklogqueueisspecial,itisalwaysusedwith

*theper-socketspinlockheldandrequireslowlatency

*access.Thereforewespecialcaseit'simplementation.

*/

/*backlog是一个队列,用于将该sock接收到的skb但是不能被及时处理的skb连接成

一个链表。

*/

struct{

structsk_buff*head;

structsk_buff

}backlog;

rwlock_tcallback_lock;

/*Errorqueue,rarelyused.*/

structsk_bufLheaderror_queue;

/*

sk结构的操作指针prot注册为与具体协议相关的

操作函数集structproto,实现了在协议上的抽象。

UDP协议为udp_prot»TCP为tcp_proto

*/

/*指定协议簇的内部的协议处理函数,它是套接口层与传输层之间的一个接口,

提供如bind,accept,close等操作*/

structproto*prot:

#ifdefined(CONFIG_IPV6)IIdefined(CONFIG_IPV6_MODULE)

union{

structipv6_pinfoaf_inet6;

}net_pinfo;

#endif

union{

structtcpoptaf_tcp;/*TCP传输控制结构*/

#ifdefined(CONFIGJNET)IIdefined(CONFIG_INET_MODULE)

structraw_opttp_raw4;

#endif

#ifdefined(CONFIG」PV6)IIdefined(CONFIG_IPV6_MODULE)

structraw6_opttp_raw;

#endif/*CONFIG_IPV6*/

#ifdefined(CONHG_SPX)IIdefined(CONFIG_SPX_MODULE)

structspx_optaCspx;

#endif/*CONFIG_SPX*/

}tp_pinfo;r-传输协议控制块联合结构*1

interr,err_soft;/*Softholdserrorsthatdon't

causefailurebutarethecause

ofapersistentfailurenotjust

,timedout'*/

/*表示当前的监听队列*/

unsignedshortack_backlog;

/*表示最大的监听队列*/

unsignedshortmax_ack_backlog;

u32priority;

unsignedshorttype;

unsignedcharlocalroute;/*Routelocallyonly*/

unsignedcharprotocol;

structucredpeercred;

rcvlowat;

rcvtimeo;

sndtimeo;

#ifdefCONFIG.FILTER

/*SocketFilteringInstructions*/

structsk_filter*filter;

#endif/*CONFIG_FILTER*/

/*Thisiswherealltheprivate(optional)areasthatdon't

*overlapwilleventuallylive.

*/

union{

void*destruct_hook;

structunix_optafLunix;

#ifdefined(CONFIG」NET)IIdefined(CONFIG」NET_MODULE)

structinetoptaMnet;

#endif

#ifdefined(CONFIG_ATALK)IIdefined(CONFIG_ATALK_MODULE)

structatalk_sockaflat;

#endif

#ifdefined(CONFIG_IPX)IIdefined(CONFIG_IPX_MODULE)

structipx_opta匚ipx;

#endif

#ifdefined(CONFIG_DECNET)IIdefined(CONFIG_DECNET_MODULE)

structdn_scpdn;

#endif

#ifdefined(CONFIG_PACKET)IIdefined(CONFIG_PACKET_MODULE)

structpacket_opt*af_packet;

#endif

#ifdefined(CONFIG_X25)IIdefi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论