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

📄 ip.4

📁 操作系统设计与实现源码
💻 4
📖 第 1 页 / 共 3 页
字号:
the Internet Address is changed..PPThe structure \fBnwio_ipconf\fP is defined in <net/gen/ip_io.h>:.PP.RS.nf.if t .ft Ctypedef struct nwio_ipconf{	u32_t   nwic_flags;	ipaddr_t nwic_ipaddr;	ipaddr_t nwic_netmask;} nwio_ipconf_t;.SP#define NWIC_NOFLAGS            0x0#define NWIC_FLAGS              0x3#       define NWIC_IPADDR_SET          0x1#       define NWIC_NETMASK_SET         0x2.if t .ft R.fi.RE.PPThe function of \fBnwio_ipconf\fP depends on the value of \fBnwic_flags\fP.If.B NWIC_IPADDR_SETis set then the Internet Address will be set to\fBnwic_ipaddr\fP.If.B NWIC_NETMASK_SETis set then the Internet Address will be set to\fBnwic_netmask\fP..PP.ft Bioctl(\fIfd\fP, NWIOSIPOPT, &struct nwio_ipopt).ft R.PPBefore an IP channel can be used, it has to be configured using the.B NWIOSIPOPTioctl.The structure \fBnwio_ipopt\fP is defined in <net/gen/ip_io.h>:.PP.RS.nf.if t .ft Ctypedef struct nwio_ipopt{        u32_t nwio_flags;        ipaddr_t nwio_rem;        ip_hdropt_t nwio_hdropt;        u8_t nwio_tos;        u8_t nwio_ttl;        u8_t nwio_df;        ipproto_t nwio_proto;} nwio_ipopt_t;.SP#define NWIO_NOFLAGS    0x0000L#define NWIO_ACC_MASK   0x0003L#       define NWIO_EXCL        0x00000001L#       define NWIO_SHARED      0x00000002L#       define NWIO_COPY        0x00000003L#define NWIO_LOC_MASK   0x0010L#       define NWIO_EN_LOC      0x00000010L#       define NWIO_DI_LOC      0x00100000L#define NWIO_BROAD_MASK 0x0020L#       define NWIO_EN_BROAD    0x00000020L#       define NWIO_DI_BROAD    0x00200000L#define NWIO_REM_MASK   0x0100L#       define NWIO_REMSPEC     0x00000100L#       define NWIO_REMANY      0x01000000L#define NWIO_PROTO_MASK 0x0200L#       define NWIO_PROTOSPEC   0x00000200L#       define NWIO_PROTOANY    0x02000000L#define NWIO_HDR_O_MASK 0x0400L#       define NWIO_HDR_O_SPEC  0x00000400L#       define NWIO_HDR_O_ANY   0x04000000L#define NWIO_RW_MASK    0x1000L#       define NWIO_RWDATONLY   0x00001000L#       define NWIO_RWDATALL    0x10000000L.if t .ft R.fi.RE.PPThe options are divided in several categories:.BR NWIO_ACC_MASK ,.BR NWIO_LOC_MASK ,.BR NWIO_BROAD_MASK ,.BR NWIO_REM_MASK ,.BR NWIO_PROTO_MASK ,.B NWIO_HDR_O_MASKand.BR NWIO_RW_MASK .A channel is configured when one option of each category is set..PPThe options covered by.B NWIO_ACC_MASKcontrol the number of channels thatcan use one IP protocol.If.B NWIO_EXCLis specified then only that channel can use a certain IP protocol.If.B NWIO_SHAREDthen multiple channels that all have to specify.B NWIO_SHAREDcan use the same IP protocol, but incoming packets willbe delivered to a most one channel..B NWIO_SHAREDdoes not impose any restrictions.Every channel gets a copy of an incoming packet..PP.B NWIO_LOC_MASKand.B NWIO_BROAD_MASKcontrol the delivery of packets.If.B NWIO_EN_LOCis specified then packets that are explicitly send tothe IP server are delivered.If.B NWIO_EN_BROADis specified then broadcast packets are delivered.Either one or both of them can be disabled with.B NWIO_DI_LOCand.BR NWIO_DI_BROAD ..PP.B NWIO_REMSPECcan be used to restrict communication to one remote host.This host is taken from the \fBnwio_rem\fP field.If any remote host is to be allowed then.B NWIO_REMANYcan be used..PP.B NWIO_PROTOSPECrestricts communication to one IP protocol, specifiedin \fBnwio_proto\fP..B NWIO_PROTOANYallows any protocol to be sent or received..PP.B NWIO_HDR_O_SPECspecifies all IP header options in advance.The values are taken from.BR nwio_hdropt ,.BR nwio_tos ,.BR nwio_ttl ,and.BR nwio_df .\fBNwio_hdropt\fP specifies the IP options that should be present in anoutgoing packet.\fBIp_hdropt_t\fP is defined in <net/gen/in.h>:.PP.RS.nf.if t .ft Ctypedef struct ip_hdropt{        u8_t iho_opt_siz;        u8_t iho_data[IP_MAX_HDR_SIZE-IP_MIN_HDR_SIZE];} ip_hdropt_t;.if t .ft R.fi.RE.PPThe bytes of size \fBiho_opt_siz\fP in \fBiho_data\fP are appended to the IPheader.\fBNwio_tos\fP specifies the value of the ``type of service'' bits,\fBnwio_ttl\fP gives the value of the ``time to live'' field and \fBnwio_df\fPspecifies whether fragmentation is disallowed or not..B NWIO_HDR_O_ANYspecifies that the header options should be specified ateach write request..PP.B NWIO_RWDATONLYspecifies that the header should be omitted from awrite request.This option can only be used when all header fields are specified in previousoptions:.BR NWIO_EN_LOC ,.BR NWIO_DI_BROAD ,.BR NWIO_REMSPEC ,.B NWIO_PROTOSPECand.BR NWIO_HDR_O_SPEC .A read operation will also only return the data part, so the IP options willbe lost..PP.ft Bioctl(\fIfd\fP, NWIOSIPOROUTE, &struct nwio_route).ft R.PPThe.B NWIOSIPOROUTEioctl adds a route to the routing table.See \fBNWIOGIPOROUTE\fP above for a description of the \fBnwio_route\fPstructure.The fields \fBnwr_ent_no\fP and \fBnwr_ent_count\fP are ignored..SS "TCP Functions".PP.ft Bioctl(\fIfd\fP, NWIOTCPCONN, &struct nwio_tcpcl).ft R.PPThe.B NWIOTCPCONNioctl tries to setup a connection with a remote TCP/IP server.The channel must be fully configured (see.BR NWIOSTCPCONF )and values for the local port, the remote port and the remote address have bespecified using.B NWTC_LP_SETor.BR NWTC_LP_SEL ,.B NWTC_SET_RAand.BR NWTC_SET_RP .The struct nwio_tcpcl is defined in <net/gen/tcp_io.h> as:.PP.RS.nf.if t .ft Ctypedef struct nwio_tcpcl{	long nwtcl_flags;	long nwtcl_ttl;} nwio_tcpcl_t;.if t .ft R.fi.RE.PPSet the.B nwtcl_flagsfield to zero before the connect or listen call.  [[[Further explanation ofnwio_tcpcl?]]].PP.ft Bioctl(\fIfd\fP, NWIOGTCPCONF, &struct nwio_tcpconf).ft R.PPThis call reports the current configuration of a TCP channel.The.B nwtc_flagsfield shows the status of the.BR access ,.BR locport ,.B remaddrand.B remportfields..B Nwtc_locaddrcontains the Internet address of the TCP/IP server..B Remaddrcontains the Internet address of the remote TCP/IP server when set with.B NWTC_SET_RAor after a successful connect or listen (see.B NWIOTCPCONNor.BR NWIOTCPLISTEN )..B Nwio_locportcontains the local TCP/IP port set with.B NWTC_LP_SETor the selected port set with.BR NWTC_LP_SEL ..B Nwtc_remportcontains the TCP port of the remote TCP/IP server as set with.B NWIO_SET_RPor after a successful connect or listen..PPA value of 0 (zero) is reported for.BR nwtc_remaddr ,.B nwtc_locportor.B nwtc_remportwhen no value is set either explicitly or implicitly..PP.ft Bioctl(\fIfd\fP, NWIOTCPLISTEN, &struct nwio_tcpcl).ft R.PPThe.B NWIOTCPLISTENioctl waits until a remote TCP/IP server tries to connect to this channel.The channel has to be configured (see.BR NWIOSTCPCONF ).An additional restriction is that the local portmust be set (with.BR NWTC_LP_SET )or selected (with.BR NWTC_LP_SEL ).When a remote address is set only connections for that host are accepted, andwhen a remote port is set only connections from that port are accepted.After a successful listen.B NWIOGTCPCONFcan be used to find out what the address and port of the other side are..PP.ft Bioctl(\fIfd\fP, NWIOSTCPCONF, &struct nwio_tcpconf).ft R.PPBefore a TCP channel can be used it must configured using the.B NWIOSTCPCONFioctl.The parameters to.B NWIOSTCPCONFare the channel file descriptor and a.B struct nwio_tcpconfas defined in <net/gen/tcp_io.h>:.PP.RS.nf.if t .ft Ctypedef struct nwio_tcpconf{	u32_t nwtc_flags;	ipaddr_t nwtc_locaddr;	ipaddr_t nwtc_remaddr;	tcpport_t nwtc_locport;	tcpport_t nwtc_remport;} nwio_tcpconf_t;.SP#define NWTC_NOFLAGS    0x0000L#define NWTC_ACC_MASK   0x0003L#       define NWTC_EXCL        0x00000001L#       define NWTC_SHARED      0x00000002L#       define NWTC_COPY        0x00000003L#define NWTC_LOCPORT_MASK       0x0030L#       define NWTC_LP_UNSET    0x00000010L#       define NWTC_LP_SET      0x00000020L#       define NWTC_LP_SEL      0x00000030L#define NWTC_REMADDR_MASK       0x0100L#       define NWTC_SET_RA      0x00000100L#       define NWTC_UNSET_RA    0x01000000L#define NWTC_REMPORT_MASK       0x0200L#       define NWTC_SET_RP      0x00000200L#       define NWTC_UNSET_RP    0x02000000L.if t .ft R.fi.RE.PPA tcp channel is considered configured when one flag in each category hasbeen selected.Thus one of.BR NWTC_EXCL ,.B NWTC_SHAREDor.BR NWTC_COPY ,one of.BR NWTC_LP_UNSET ,.B NWTC_LP_SETor.BR NWTC_LP_SEL ,one of.B NWTC_SET_RAor.BR NWTC_UNSET_RA ,and one of.B NWTC_SET_RPor.BR NWTC_UNSET_RP ..PPThe acc flags control the access to a certain TCP port..B NWTC_EXCLmeans exclusive access.An attempt to configure a channel will be denied if the same port is specifiedas that of a channel that requested exclusive access..B NWTC_SHAREDindicates that several channels use the same port but cooperate.If the shared mode is specified for one channel than all other channel thatuse the same port should also be configured with the.B NWTC_SHAREDflag..B NWTC_COPYis specified when the programmer does not care about other channels.This is the default..PPThe locport flags control which TCP port is used for communication..B NWTC_LP_UNSETindicates the absence of a local port.This is the default..B NWTC_LP_SETmeans that the.B nwtc_locportfield contains the local port to be used by TCP.This value must be in network byte order (see.BR hton (3).).B NWTC_LP_SELrequests the TCP server to pick a port.This port will be in the range from 32768 to 65535 and will be unique..LPThe.B remaddrflags specify which hosts are acceptable for connections..B NWTC_SET_RAindicates that only connection to the host specified in.B nwtc_remaddrare acceptable..B Nwtc_remaddrshould be in network byte order (see.BR hton (3).).B NWTC_UNSET_RAallows every host on the other side of a connection.This is the default..PPThe.B remportflags specify which remote ports are acceptable for connections..B NWTC_SET_RPindicates that only the port specified in.B nwtc_remportis acceptable..B NWTC_UNSET_RPallows every port on the other side of a connection.This is the default..PP.ft Bioctl(\fIfd\fP, NWIOTCPSHUTDOWN).ft R.PPThe.B NWIOTCPSHUTDOWNtells the TCP/IP server that no more data will be sent over the channelspecified by.IR fd .This command can be issued when the channel is connected to a remote TCP/IPserver.The TCP/IP server will tell the remote TCP/IP server and the client of theremote TCP/IP server will receive an end-of-file indication..PP.ft Bioctl(\fIfd\fP, NWIOGTCPOPT, &struct nwio_tcpopt).brioctl(\fIfd\fP, NWIOSTCPOPT, &struct nwio_tcpopt).ft R.PPThe behaviour of a TCP channel may be changed by setting a number ofoptions.  The TCP options can be obtained with the.B NWIOGTCPOPTioctl and set with the.B NWIOSTCPOPTioctl.  The options are passed in a.B struct nwio_tcpoptas defined in <net/gen/tcp_io.h>:.PP.RS.nf.if t .ft Ctypedef struct nwio_tcpopt{	u32_t nwto_flags;} nwio_tcpconf_t;.SP#define NWTO_NOFLAG     0x0000L#define NWTO_SND_URG_MASK       0x0001L#       define NWTO_SND_URG     0x00000001L#       define NWTO_SND_NOTURG  0x00010000L#define NWTO_RCV_URG_MASK       0x0002L#       define NWTO_RCV_URG     0x00000002L#       define NWTO_RCV_NOTURG  0x00020000L#define NWTO_BSD_URG_MASK       0x0004L#       define NWTO_BSD_URG     0x00000004L#define NWTO_DEL_RST_MASK       0x0008L#       define NWTO_DEL_RST     0x00000008L.if t .ft R.fi.RE.PPThe

⌨️ 快捷键说明

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