aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r--include/net/tcp.h260
1 files changed, 103 insertions, 157 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index a1449144848a..df6a2eb20193 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -296,45 +296,30 @@ extern struct proto tcp_prot;
296#define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val) 296#define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val)
297#define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val) 297#define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val)
298 298
299extern void tcp_v4_err(struct sk_buff *skb, u32); 299extern void tcp_v4_err(struct sk_buff *skb, u32);
300 300
301extern void tcp_shutdown (struct sock *sk, int how); 301extern void tcp_shutdown (struct sock *sk, int how);
302 302
303extern int tcp_v4_rcv(struct sk_buff *skb); 303extern int tcp_v4_rcv(struct sk_buff *skb);
304 304
305extern int tcp_v4_remember_stamp(struct sock *sk); 305extern int tcp_v4_remember_stamp(struct sock *sk);
306 306extern int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw);
307extern int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw); 307extern int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
308 308 size_t size);
309extern int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, 309extern int tcp_sendpage(struct sock *sk, struct page *page, int offset,
310 struct msghdr *msg, size_t size); 310 size_t size, int flags);
311extern ssize_t tcp_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags); 311extern int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg);
312 312extern int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
313extern int tcp_ioctl(struct sock *sk, 313 struct tcphdr *th, unsigned len);
314 int cmd, 314extern int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
315 unsigned long arg); 315 struct tcphdr *th, unsigned len);
316 316extern void tcp_rcv_space_adjust(struct sock *sk);
317extern int tcp_rcv_state_process(struct sock *sk, 317extern void tcp_cleanup_rbuf(struct sock *sk, int copied);
318 struct sk_buff *skb, 318extern int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp);
319 struct tcphdr *th, 319extern void tcp_twsk_destructor(struct sock *sk);
320 unsigned len); 320extern ssize_t tcp_splice_read(struct socket *sk, loff_t *ppos,
321 321 struct pipe_inode_info *pipe, size_t len,
322extern int tcp_rcv_established(struct sock *sk, 322 unsigned int flags);
323 struct sk_buff *skb,
324 struct tcphdr *th,
325 unsigned len);
326
327extern void tcp_rcv_space_adjust(struct sock *sk);
328
329extern void tcp_cleanup_rbuf(struct sock *sk, int copied);
330
331extern int tcp_twsk_unique(struct sock *sk,
332 struct sock *sktw, void *twp);
333
334extern void tcp_twsk_destructor(struct sock *sk);
335
336extern ssize_t tcp_splice_read(struct socket *sk, loff_t *ppos,
337 struct pipe_inode_info *pipe, size_t len, unsigned int flags);
338 323
339static inline void tcp_dec_quickack_mode(struct sock *sk, 324static inline void tcp_dec_quickack_mode(struct sock *sk,
340 const unsigned int pkts) 325 const unsigned int pkts)
@@ -372,88 +357,59 @@ enum tcp_tw_status {
372}; 357};
373 358
374 359
375extern enum tcp_tw_status tcp_timewait_state_process(struct inet_timewait_sock *tw, 360extern enum tcp_tw_status tcp_timewait_state_process(struct inet_timewait_sock *tw,
376 struct sk_buff *skb, 361 struct sk_buff *skb,
377 const struct tcphdr *th); 362 const struct tcphdr *th);
378 363extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb,
379extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb, 364 struct request_sock *req,
380 struct request_sock *req, 365 struct request_sock **prev);
381 struct request_sock **prev); 366extern int tcp_child_process(struct sock *parent, struct sock *child,
382extern int tcp_child_process(struct sock *parent, 367 struct sk_buff *skb);
383 struct sock *child, 368extern int tcp_use_frto(struct sock *sk);
384 struct sk_buff *skb); 369extern void tcp_enter_frto(struct sock *sk);
385extern int tcp_use_frto(struct sock *sk); 370extern void tcp_enter_loss(struct sock *sk, int how);
386extern void tcp_enter_frto(struct sock *sk); 371extern void tcp_clear_retrans(struct tcp_sock *tp);
387extern void tcp_enter_loss(struct sock *sk, int how); 372extern void tcp_update_metrics(struct sock *sk);
388extern void tcp_clear_retrans(struct tcp_sock *tp); 373extern void tcp_close(struct sock *sk, long timeout);
389extern void tcp_update_metrics(struct sock *sk); 374extern unsigned int tcp_poll(struct file * file, struct socket *sock,
390 375 struct poll_table_struct *wait);
391extern void tcp_close(struct sock *sk, 376extern int tcp_getsockopt(struct sock *sk, int level, int optname,
392 long timeout); 377 char __user *optval, int __user *optlen);
393extern unsigned int tcp_poll(struct file * file, struct socket *sock, struct poll_table_struct *wait); 378extern int tcp_setsockopt(struct sock *sk, int level, int optname,
394 379 char __user *optval, unsigned int optlen);
395extern int tcp_getsockopt(struct sock *sk, int level, 380extern int compat_tcp_getsockopt(struct sock *sk, int level, int optname,
396 int optname, 381 char __user *optval, int __user *optlen);
397 char __user *optval, 382extern int compat_tcp_setsockopt(struct sock *sk, int level, int optname,
398 int __user *optlen); 383 char __user *optval, unsigned int optlen);
399extern int tcp_setsockopt(struct sock *sk, int level, 384extern void tcp_set_keepalive(struct sock *sk, int val);
400 int optname, char __user *optval, 385extern void tcp_syn_ack_timeout(struct sock *sk, struct request_sock *req);
401 unsigned int optlen); 386extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
402extern int compat_tcp_getsockopt(struct sock *sk, 387 size_t len, int nonblock, int flags, int *addr_len);
403 int level, int optname, 388extern void tcp_parse_options(struct sk_buff *skb,
404 char __user *optval, int __user *optlen); 389 struct tcp_options_received *opt_rx, u8 **hvpp,
405extern int compat_tcp_setsockopt(struct sock *sk, 390 int estab);
406 int level, int optname, 391extern u8 *tcp_parse_md5sig_option(struct tcphdr *th);
407 char __user *optval, unsigned int optlen);
408extern void tcp_set_keepalive(struct sock *sk, int val);
409extern void tcp_syn_ack_timeout(struct sock *sk,
410 struct request_sock *req);
411extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk,
412 struct msghdr *msg,
413 size_t len, int nonblock,
414 int flags, int *addr_len);
415
416extern void tcp_parse_options(struct sk_buff *skb,
417 struct tcp_options_received *opt_rx,
418 u8 **hvpp,
419 int estab);
420
421extern u8 *tcp_parse_md5sig_option(struct tcphdr *th);
422 392
423/* 393/*
424 * TCP v4 functions exported for the inet6 API 394 * TCP v4 functions exported for the inet6 API
425 */ 395 */
426 396
427extern void tcp_v4_send_check(struct sock *sk, 397extern void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb);
428 struct sk_buff *skb); 398extern int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
429 399extern struct sock * tcp_create_openreq_child(struct sock *sk,
430extern int tcp_v4_conn_request(struct sock *sk, 400 struct request_sock *req,
431 struct sk_buff *skb);
432
433extern struct sock * tcp_create_openreq_child(struct sock *sk,
434 struct request_sock *req,
435 struct sk_buff *skb);
436
437extern struct sock * tcp_v4_syn_recv_sock(struct sock *sk,
438 struct sk_buff *skb,
439 struct request_sock *req,
440 struct dst_entry *dst);
441
442extern int tcp_v4_do_rcv(struct sock *sk,
443 struct sk_buff *skb); 401 struct sk_buff *skb);
444 402extern struct sock * tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
445extern int tcp_v4_connect(struct sock *sk, 403 struct request_sock *req,
446 struct sockaddr *uaddr, 404 struct dst_entry *dst);
447 int addr_len); 405extern int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb);
448 406extern int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
449extern int tcp_connect(struct sock *sk); 407 int addr_len);
450 408extern int tcp_connect(struct sock *sk);
451extern struct sk_buff * tcp_make_synack(struct sock *sk, 409extern struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
452 struct dst_entry *dst, 410 struct request_sock *req,
453 struct request_sock *req, 411 struct request_values *rvp);
454 struct request_values *rvp); 412extern int tcp_disconnect(struct sock *sk, int flags);
455
456extern int tcp_disconnect(struct sock *sk, int flags);
457 413
458 414
459/* From syncookies.c */ 415/* From syncookies.c */
@@ -464,7 +420,7 @@ extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb,
464 __u16 *mss); 420 __u16 *mss);
465 421
466extern __u32 cookie_init_timestamp(struct request_sock *req); 422extern __u32 cookie_init_timestamp(struct request_sock *req);
467extern void cookie_check_timestamp(struct tcp_options_received *tcp_opt); 423extern bool cookie_check_timestamp(struct tcp_options_received *opt, bool *);
468 424
469/* From net/ipv6/syncookies.c */ 425/* From net/ipv6/syncookies.c */
470extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb); 426extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb);
@@ -485,10 +441,10 @@ extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
485 441
486extern void tcp_send_probe0(struct sock *); 442extern void tcp_send_probe0(struct sock *);
487extern void tcp_send_partial(struct sock *); 443extern void tcp_send_partial(struct sock *);
488extern int tcp_write_wakeup(struct sock *); 444extern int tcp_write_wakeup(struct sock *);
489extern void tcp_send_fin(struct sock *sk); 445extern void tcp_send_fin(struct sock *sk);
490extern void tcp_send_active_reset(struct sock *sk, gfp_t priority); 446extern void tcp_send_active_reset(struct sock *sk, gfp_t priority);
491extern int tcp_send_synack(struct sock *); 447extern int tcp_send_synack(struct sock *);
492extern void tcp_push_one(struct sock *, unsigned int mss_now); 448extern void tcp_push_one(struct sock *, unsigned int mss_now);
493extern void tcp_send_ack(struct sock *sk); 449extern void tcp_send_ack(struct sock *sk);
494extern void tcp_send_delayed_ack(struct sock *sk); 450extern void tcp_send_delayed_ack(struct sock *sk);
@@ -592,7 +548,7 @@ static inline u32 tcp_receive_window(const struct tcp_sock *tp)
592 * scaling applied to the result. The caller does these things 548 * scaling applied to the result. The caller does these things
593 * if necessary. This is a "raw" window selection. 549 * if necessary. This is a "raw" window selection.
594 */ 550 */
595extern u32 __tcp_select_window(struct sock *sk); 551extern u32 __tcp_select_window(struct sock *sk);
596 552
597/* TCP timestamps are only 32-bits, this causes a slight 553/* TCP timestamps are only 32-bits, this causes a slight
598 * complication on 64-bit systems since we store a snapshot 554 * complication on 64-bit systems since we store a snapshot
@@ -602,12 +558,22 @@ extern u32 __tcp_select_window(struct sock *sk);
602 */ 558 */
603#define tcp_time_stamp ((__u32)(jiffies)) 559#define tcp_time_stamp ((__u32)(jiffies))
604 560
561#define tcp_flag_byte(th) (((u_int8_t *)th)[13])
562
563#define TCPHDR_FIN 0x01
564#define TCPHDR_SYN 0x02
565#define TCPHDR_RST 0x04
566#define TCPHDR_PSH 0x08
567#define TCPHDR_ACK 0x10
568#define TCPHDR_URG 0x20
569#define TCPHDR_ECE 0x40
570#define TCPHDR_CWR 0x80
571
605/* This is what the send packet queuing engine uses to pass 572/* This is what the send packet queuing engine uses to pass
606 * TCP per-packet control information to the transmission 573 * TCP per-packet control information to the transmission code.
607 * code. We also store the host-order sequence numbers in 574 * We also store the host-order sequence numbers in here too.
608 * here too. This is 36 bytes on 32-bit architectures, 575 * This is 44 bytes if IPV6 is enabled.
609 * 40 bytes on 64-bit machines, if this grows please adjust 576 * If this grows please adjust skbuff.h:skbuff->cb[xxx] size appropriately.
610 * skbuff.h:skbuff->cb[xxx] size appropriately.
611 */ 577 */
612struct tcp_skb_cb { 578struct tcp_skb_cb {
613 union { 579 union {
@@ -620,19 +586,6 @@ struct tcp_skb_cb {
620 __u32 end_seq; /* SEQ + FIN + SYN + datalen */ 586 __u32 end_seq; /* SEQ + FIN + SYN + datalen */
621 __u32 when; /* used to compute rtt's */ 587 __u32 when; /* used to compute rtt's */
622 __u8 flags; /* TCP header flags. */ 588 __u8 flags; /* TCP header flags. */
623
624 /* NOTE: These must match up to the flags byte in a
625 * real TCP header.
626 */
627#define TCPCB_FLAG_FIN 0x01
628#define TCPCB_FLAG_SYN 0x02
629#define TCPCB_FLAG_RST 0x04
630#define TCPCB_FLAG_PSH 0x08
631#define TCPCB_FLAG_ACK 0x10
632#define TCPCB_FLAG_URG 0x20
633#define TCPCB_FLAG_ECE 0x40
634#define TCPCB_FLAG_CWR 0x80
635
636 __u8 sacked; /* State flags for SACK/FACK. */ 589 __u8 sacked; /* State flags for SACK/FACK. */
637#define TCPCB_SACKED_ACKED 0x01 /* SKB ACK'd by a SACK block */ 590#define TCPCB_SACKED_ACKED 0x01 /* SKB ACK'd by a SACK block */
638#define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */ 591#define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */
@@ -1176,22 +1129,14 @@ struct tcp_md5sig_pool {
1176#define TCP_MD5SIG_MAXKEYS (~(u32)0) /* really?! */ 1129#define TCP_MD5SIG_MAXKEYS (~(u32)0) /* really?! */
1177 1130
1178/* - functions */ 1131/* - functions */
1179extern int tcp_v4_md5_hash_skb(char *md5_hash, 1132extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
1180 struct tcp_md5sig_key *key, 1133 struct sock *sk, struct request_sock *req,
1181 struct sock *sk, 1134 struct sk_buff *skb);
1182 struct request_sock *req, 1135extern struct tcp_md5sig_key * tcp_v4_md5_lookup(struct sock *sk,
1183 struct sk_buff *skb); 1136 struct sock *addr_sk);
1184 1137extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey,
1185extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, 1138 u8 newkeylen);
1186 struct sock *addr_sk); 1139extern int tcp_v4_md5_do_del(struct sock *sk, __be32 addr);
1187
1188extern int tcp_v4_md5_do_add(struct sock *sk,
1189 __be32 addr,
1190 u8 *newkey,
1191 u8 newkeylen);
1192
1193extern int tcp_v4_md5_do_del(struct sock *sk,
1194 __be32 addr);
1195 1140
1196#ifdef CONFIG_TCP_MD5SIG 1141#ifdef CONFIG_TCP_MD5SIG
1197#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_keylen ? \ 1142#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_keylen ? \
@@ -1204,10 +1149,10 @@ extern int tcp_v4_md5_do_del(struct sock *sk,
1204#endif 1149#endif
1205 1150
1206extern struct tcp_md5sig_pool * __percpu *tcp_alloc_md5sig_pool(struct sock *); 1151extern struct tcp_md5sig_pool * __percpu *tcp_alloc_md5sig_pool(struct sock *);
1207extern void tcp_free_md5sig_pool(void); 1152extern void tcp_free_md5sig_pool(void);
1208 1153
1209extern struct tcp_md5sig_pool *tcp_get_md5sig_pool(void); 1154extern struct tcp_md5sig_pool *tcp_get_md5sig_pool(void);
1210extern void tcp_put_md5sig_pool(void); 1155extern void tcp_put_md5sig_pool(void);
1211 1156
1212extern int tcp_md5_hash_header(struct tcp_md5sig_pool *, struct tcphdr *); 1157extern int tcp_md5_hash_header(struct tcp_md5sig_pool *, struct tcphdr *);
1213extern int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *, struct sk_buff *, 1158extern int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *, struct sk_buff *,
@@ -1413,7 +1358,8 @@ struct tcp_iter_state {
1413 sa_family_t family; 1358 sa_family_t family;
1414 enum tcp_seq_states state; 1359 enum tcp_seq_states state;
1415 struct sock *syn_wait_sk; 1360 struct sock *syn_wait_sk;
1416 int bucket, sbucket, num, uid; 1361 int bucket, offset, sbucket, num, uid;
1362 loff_t last_pos;
1417}; 1363};
1418 1364
1419extern int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo); 1365extern int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo);
@@ -1434,7 +1380,7 @@ extern int tcp_gro_complete(struct sk_buff *skb);
1434extern int tcp4_gro_complete(struct sk_buff *skb); 1380extern int tcp4_gro_complete(struct sk_buff *skb);
1435 1381
1436#ifdef CONFIG_PROC_FS 1382#ifdef CONFIG_PROC_FS
1437extern int tcp4_proc_init(void); 1383extern int tcp4_proc_init(void);
1438extern void tcp4_proc_exit(void); 1384extern void tcp4_proc_exit(void);
1439#endif 1385#endif
1440 1386