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

📄 linuxpatch

📁 DCCP协议在linux下的C编程实现 linux C
💻
字号:
Index: sock.h===================================================================--- sock.h	(revision 2)+++ sock.h	(revision 10)@@ -207,6 +207,156 @@ }; #endif +#if defined (CONFIG_NET_DCP) || defined (CONFIG_NET_DCP_MODULE)++#define DCP_RCVQ_SZ 32+#define DCP_OPTASZ  128 //Was 32 maybe 32 is max??++#if 0+/*added by BJORN. */+struct ipcm_cookie+{+   u32         addr;+   int         oif;+   struct ip_options *opt;+};+/*from dcp.c by BJORN. */+struct build_t+{+    unsigned char *h,*kdb;+	u16 hl,kdbl;+	struct iovec *iov;+	u32 check;+};+/*end from dcp.c.*/+#endif++struct dcp_opt+{+#if 0+    /* added by BJORN to make + * dcp.c:dccp_connect+ * dcp.c:dccp_accept nonblocking. */+	 unsigned char *pbuf;+	 struct ipcm_cookie ipc;+	 //u32 isn[DCP_MAX_TRIES];+    u32 *isn;+	 //u32 stamp[DCP_MAX_TRIES] ;+    u32 *stamp;+	 +    struct build_t b;++    struct sock *sk2; //accept return this when done.+    +/* end of added by BJORN. */+#endif++    +	void *send_ccb; 	/* the congestion control block covering outgoing packets - TFRC only */+	void *recv_ccb;		/* the congestion control block for incoming packets - TFRC only */+	u32 avgpsize;		/* average packet size - TFRC only */+	u16 ndp, retries;	/* ndp = non data packets i.e. everything that isn't a DATA or DATAACK packet+				   retries = the number of times a packet has been resent */+	u32 seq,svc;		/* seq = the current sequence number for outgoing packets+				   svc = the service code for the connection */+	u8  wndcount;         /* wndcount is increased every quarter of an RTT */ +	u8  highestwndcountseen;	/* the greatest value for wndcount seen thus far */++	u32 lastsend;         +	u32 losseventrate; 	/* the rate at which loss event options are received */+++	u16 ackratio,			/* ackratio is the local ackratio - set by peer */+	unacked,			/* unacked is the number of received but unackd packets */+	rtt,			/* rtt est */+	rto,			/* timeout */+	rtt_d,			/* rtt deviation est */+	cwnd,			/* the size of the congestion window */+	ssthresh,		/* slow start threshold - CCID 2 specific */+	outstanding,		/* the number of sent packets charged against cwnd */+	rcvr_ratio,			/* ackratio on other end of connection */+	valid4;			/* number of packets left in window until we need to get a new rtt sample */++	u32 checkingrtt,		/* when gathering a rtt sample, start time. 0 when idle */+	checkingsn;			/* when gathering a rtt sample, sn of the packet that's the sample's front end */++	unsigned char *ackvector,	/* for acks we send, 2 bits to the pkt */+	*cwndvector;		/* for data charged against cwd we're waiting for acks on, 1 bit to the packet */++	u32 av_ts, av_hs,		/* seq no's of head and tail ptrs  - av = ack vector, cv = congestion window*/+	cv_ts, cv_hs;++	struct +		ack_collapse_t  *av_clist;	/* for acks of acks */++	unsigned char  *av_tp,	/* ack/cwnd vector head and tail ptrs */+	*cv_hp, *cv_tp;++	u16 av_sz, cv_sz;		/* size (in pkts) of ackvector and cwndvector - keep as multiple of 8 */++	wait_queue_head_t newdata;+	spinlock_t rsem;+	struct tq_struct rtask;	/* send reset */+	struct tq_struct ctask;	/* send close */+	struct tq_struct atask;	/* send ack */++	struct timer_list retransmit_timer, /* used for retransmission of packets, i.e REQUEST, RESPONSE, CLOSEREQ etc */+	timewait_t; /* used for the timewait state */++	struct sk_buff *rcvq[DCP_RCVQ_SZ]; /* Where incoming packets are stored prior to processing */+	unsigned char rcvq_h, rcvq_t; /* head and tail pointers of the receive queue */++	unsigned char ccid,		/* at 0 we have no cc, so can't send */+	whoami,			/* can be WHOAMI_CLIENT WHOAMI_SERVER WHOAMI_BINDER */+	timer_expired,		/* flag describing if a timer has expired */+	flags,			/* contains information regarding whether an ACK is scheduled and if handshake data is allowed - can be expanded in future */+	opt_a_sz;		/* length of the options to be appended to the packet header */+++	u32 ackn,			/* highest seq n (subject to wrapping) we've seen */+	rto_num,			/* seqno of outstanding pcket with timer set - 2^24 if not set */+	timeout_barrier,		/* for karn */ // Huh? - SHANE+	ts_r_stamp,			/* if we have an unacknowledged timestamp echo, this is when it was rcvd */+	ts_r,			/* if we have an unacknowledged timestamp echo, this was its value */+	ackc_wsn;		/* the smallest acknowledgment number that has not been acknowledged by the server  */++	u16 avoidp,		/* the number of packets in the congestion window that have been acked */+	ackc,ackp,		/* ackc = the number of congestion windows that have not seen any ack loss +				   ackp = the number of packets that have been credited for the current congestion window */+	hsdlen;			/* handshake data len */++	struct sk_buff *shake_defer; /* stores any handshake data that will be dealt with once the connection process is complete */++	unsigned char +		opt_append[DCP_OPTASZ],	/* options to go out in next packet */+	uav,			/* use ack vector */+	uav_state,		/* status of the ack vector option negotiation */+	rcvr_ratio_state,	/* used to describe whether we know the receiver's ack ratio or not */+	ccid_state,		/* same as above, except for CCID */+	negibuf,			/* used to keep track of what's already in opt_append */+	*hsd;			/* handshake data */++	u_int8_t        type_rcv;       /* Type of packet received */+	u_int32_t       len_rcv;        /* Length of data received */+    u_int8_t        ndp_rcv;        /* ndp value of received packet */+	u_int32_t	seq_rcv;        /* Seq num of received packet */+	u_int32_t	seq_snd;        /* Seq num of received packet */+	u_int32_t	ack_rcv;        /* Seq num of received packet */+	u_int32_t	ack_snd;        /* Seq num of received packet */+	uint8_t *tfrcmem;		/* Used for mmapping virtual memory to physical */++++++};+ struct dcp_rateinfo     + { +	   double rate;+ };++#endif+ #if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE) struct inet_opt {@@ -648,7 +798,9 @@ #if defined(CONFIG_SPX) || defined (CONFIG_SPX_MODULE) 		struct spx_opt		af_spx; #endif /* CONFIG_SPX */-+#if defined (CONFIG_NET_DCP) || defined (CONFIG_NET_DCP_MODULE)+		struct dcp_opt         tp_dcp;+#endif 	} tp_pinfo;  	int			err, err_soft;	/* Soft holds errors that don'tIndex: af_inet.c===================================================================--- af_inet.c	(revision 2)+++ af_inet.c	(revision 10)@@ -292,18 +292,25 @@ 	if (sock->state != SS_UNCONNECTED || sock->type != SOCK_STREAM) 		goto out; -	old_state = sk->state;-	if (!((1<<old_state)&(TCPF_CLOSE|TCPF_LISTEN)))+	if (sock->type != SOCK_DCCP)+	  {+	    if (sock->type != SOCK_STREAM)+	      goto out;+	    +	    old_state = sk->state;+	    if (!((1<<old_state)&(TCPF_CLOSE|TCPF_LISTEN)))+	      goto out;+	    +	    /* Really, if the socket is already in listen state+	     * we can only allow the backlog to be adjusted.+	     */+	    if (old_state != TCP_LISTEN) {+	      err = tcp_listen_start(sk);+	      if (err) 		goto out;+	    }+	  } -	/* Really, if the socket is already in listen state-	 * we can only allow the backlog to be adjusted.-	 */-	if (old_state != TCP_LISTEN) {-		err = tcp_listen_start(sk);-		if (err)-			goto out;-	} 	sk->max_ack_backlog = backlog; 	err = 0; @@ -1198,6 +1205,10 @@ 	proc_net_create ("udp", 0, udp_get_info); #endif		/* CONFIG_PROC_FS */ +#ifdef CONFIG_NET_DCP+	dcp_init();+#endif+ 	ipfrag_init();  	return 0;Index: socket.h===================================================================--- socket.h	(revision 2)+++ socket.h	(revision 10)@@ -259,7 +259,7 @@ #define SOL_IRDA        266 #define SOL_NETBEUI	267 #define SOL_LLC		268-+#define SOL_DCCP	269 /* IPX options */ #define IPX_TYPE	1 Index: asmumarchsocket.h===================================================================--- asmumarchsocket.h	(revision 2)+++ asmumarchsocket.h	(revision 10)@@ -53,6 +53,7 @@ #define SOCK_RAW	3		/* raw socket			*/ #define SOCK_RDM	4		/* reliably-delivered message	*/ #define SOCK_SEQPACKET	5		/* sequential packet socket	*/+#define SOCK_DCCP	6  #define SOCK_PACKET	10		/* linux specific way of	*/ 					/* getting packets at the dev	*/ 					/* level.  For writing rarp and	*/Index: netsyms.c===================================================================--- netsyms.c	(revision 2)+++ netsyms.c	(revision 10)@@ -299,7 +299,7 @@ #endif  -#if defined (CONFIG_IPV6_MODULE) || defined (CONFIG_KHTTPD) || defined (CONFIG_KHTTPD_MODULE) || defined (CONFIG_IP_SCTP_MODULE)+#if defined (CONFIG_IPV6_MODULE) || defined (CONFIG_KHTTPD) || defined (CONFIG_KHTTPD_MODULE) || defined (CONFIG_IP_SCTP_MODULE) || defined (CONFIG_NET_DCP_MODULE) /* inet functions common to v4 and v6 */ EXPORT_SYMBOL(inet_release); EXPORT_SYMBOL(inet_stream_connect);@@ -316,7 +316,7 @@ #endif EXPORT_SYMBOL(inet_sock_destruct); EXPORT_SYMBOL(inet_sock_release);-+EXPORT_SYMBOL(ip_build_xmit); /* Socket demultiplexing. */ EXPORT_SYMBOL(tcp_hashinfo); EXPORT_SYMBOL(tcp_listen_wlock);@@ -372,7 +372,9 @@ EXPORT_SYMBOL(udp_prot); EXPORT_SYMBOL(tcp_prot); EXPORT_SYMBOL(tcp_openreq_cachep);+#ifndef CONFIG_NET_DCP_MODULE EXPORT_SYMBOL(ipv4_specific);+#endif EXPORT_SYMBOL(tcp_simple_retransmit); EXPORT_SYMBOL(tcp_transmit_skb); EXPORT_SYMBOL(tcp_connect);@@ -415,7 +417,7 @@  EXPORT_SYMBOL(tcp_read_sock); -#ifdef CONFIG_IP_SCTP_MODULE+#if defined (CONFIG_IP_SCTP_MODULE) || defined (CONFIG_NET_DCP_MODULE) EXPORT_SYMBOL(ip_setsockopt); EXPORT_SYMBOL(ip_getsockopt); EXPORT_SYMBOL(inet_ioctl);Index: Makefile===================================================================--- Makefile	(revision 2)+++ Makefile	(revision 10)@@ -22,6 +22,7 @@ obj-$(CONFIG_IP_ROUTE_NAT) += ip_nat_dumb.o obj-$(CONFIG_IP_MROUTE) += ipmr.o obj-$(CONFIG_NET_IPIP) += ipip.o+obj-$(CONFIG_NET_DCP) += dcp.o obj-$(CONFIG_NET_IPGRE) += ip_gre.o obj-$(CONFIG_SYN_COOKIES) += syncookies.o obj-$(CONFIG_IP_PNP) += ipconfig.oIndex: Config.in===================================================================--- Config.in	(revision 2)+++ Config.in	(revision 10)@@ -24,6 +24,7 @@ #   bool '    IP: ARP support' CONFIG_IP_PNP_ARP		 fi tristate '  IP: tunneling' CONFIG_NET_IPIP+tristate '  IP: DCCP Datagram Congestion Control Protocol' CONFIG_NET_DCP tristate '  IP: GRE tunnels over IP' CONFIG_NET_IPGRE if [ "$CONFIG_IP_MULTICAST" = "y" ]; then    if [ "$CONFIG_NET_IPGRE" != "n" ]; then

⌨️ 快捷键说明

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