2 * Connection oriented routing
3 * Copyright (C) 2007-2010 Michael Blizek
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include <asm/atomic.h>
23 #include <linux/types.h>
24 #include <linux/netdevice.h>
25 #include <linux/skbuff.h>
26 #include <linux/spinlock.h>
27 #include <linux/workqueue.h>
28 #include <linux/kref.h>
34 #define PIDOUT_NEWCONN 16
35 #define PIDOUT_SENDDEF_THRES 8
36 #define PIDOUT_SENDDEF_COUNT 16
40 #define ETH_P_COR 0x1022
44 #define SOCKADDRTYPE_PORT 1
53 #define MAX_CONN_CMD_LEN 4096
56 #define PACKET_TYPE_ANNOUNCE 1
57 #define PACKET_TYPE_DATA 2
60 * Kernel packet data - these commands are sent by the neighbor
61 * The end nodes may cause these commands to be sent, but they see them beyond
69 * KP_PING[1] cookie[4]
70 * KP_PONG[1] cookie[4] respdelay[4]
72 * This is needed to find out whether the other node is reachable. After a new
73 * neighbor is seen, ping requests are sent and the neighbor is only reachable
74 * after a few pongs are received. These requests are also used to find out
75 * whether a neighber is gone.
78 * The receiver of a ping may delay the sending of the pong e.g. to create
79 * bigger kernel packets. The respdelay is the time in microseconds the packet
85 /* KP_ACK[1] seqno[4] */
89 * KP_ACK_CONN[1] conn_id[4] seqno[4] window[1]
90 * KP_ACK_CONN_OOO[1] conn_id[4] seqno[4] window[1] seqno_ooo[4] length[4]
92 * conn_id is the conn_id we use if we sent something through this conn and
93 * *not* the conn_id that the neighbor used to send us the data
95 * seqno = the seqno which is expected in the next non-out-of-order packet
96 * seqno_ooo, length = in case
98 * window = amount of data which can be sent without receiving the next ack
99 * packets with lower seqno do not overwrite the last window size
100 * note: the other side may also reduce the window size
103 * 1...255 = 64*2^((value-1)/11) end result is rounded down to an integer
105 * 32* 2 ^ ((value-1)/8)
108 #define KP_ACK_CONN 5
109 #define KP_ACK_CONN_OOO 6
112 * NOTE on connection ids:
113 * connection ids + init seqnos we send are used for the receive channel
114 * connection ids + init seqnos we receive are used for the send channel
118 * incoming connection
119 * KP_CONNECT[1] conn_id[4] init_seqno[4] window[1]
124 * incoming connection successful,
125 * the first conn_id is the same as previously sent/received in KP_CONNECT
126 * the second conn_id is generated by us and used for the other direction
127 * KP_CONNECT_SUCCESS[1] conn_id[4] conn_id[4] init_seqno[4] window[1]
129 #define KP_CONNECT_SUCCESS 8
131 /* KP_CONN_DATA[1] conn_id[4] seqno[4] length[2] data[length] */
132 #define KP_CONN_DATA 9
135 * KP_PING_CONN[1] conn_id[4]
137 * This is for querying the status of an open connection. The response is either
138 * KP_ACK_CONN or CONNID_UNKNOWN
140 #define KP_PING_CONN 10
143 * { KP_RESET_CONN[1] conn_id[4] }
144 * We send this, if there is an established connection we want to close.
146 #define KP_RESET_CONN 11
149 * KP_CONNID_UNKNOWN[1] sent_conn_id[4]
150 * We send this, if we receive an invalid conn_id
152 #define KP_CONNID_UNKNOWN 12
155 * KP_PING_ALL_CONNS[1]
156 * We send this, if we we lost a conn, but could not send reset_conn and
159 #define KP_PING_ALL_CONNS 13
162 * KP_SET_MAX_CMSG_DELAY[1] delay[4]
163 * Sent after connecting and at any change
164 * delay in specifies in microsecs
166 #define KP_SET_MAX_CMSG_DELAY 14
169 * KP_SET_CONN_CREDITS[1] conn_id[4] credit_rate[4]
171 #define KP_SET_CONN_CREDITS 15
175 * Connection data which in interpreted when connection has no target yet
176 * These commands are sent by the end node.
179 * cmd[2] length[1-4] parameter[length]
180 * unrecogniced commands are ignored
181 * parameters which are longer than expected are ignored as well
184 /* outgoing connection: CD_CONNECT_NB[2] length[1-4]
185 * addrtypelen[1-4] addrlen[1-4] addrtype[addrtypelen] addr[addrlen] */
186 #define CD_CONNECT_NB 1
188 /* connection to local open part: CD_CONNECT_PORT[2] length[1-4] port[8] */
189 #define CD_CONNECT_PORT 2
192 * CD_LIST_NEIGH sends CDR_BINDATA if the command was successful. The response
195 * totalneighs[1-4] response_rows[1-4]
196 * numfields[1-4] (field[2] fieldlen[1-4])[numfields]
197 * rows[responserows]:
198 * fieldlen[1-4], only if fieldlen in the header was "0"
199 * fielddata[fieldlen]
201 * Neighbors have to be sorted by uptime, new neighbors first. This is so that
202 * the routing daemon can easily find out whether there are new neighbors. It
203 * only needs to send a query with offset 0. If the totalneighs stays the same
204 * while new were added, a connection to another neighbor was lost.
206 * Future versions may append data to field definition. Therefore clients must
207 * silently discard data at the end they do not expect.
210 /* list connected neighbors: CD_LIST_NEIGH[2] length[1-4] limit[1-4]
212 #define CD_LIST_NEIGH 3
215 * numaddr[1-4] (addrtypelen[1-4] addrlen[1-4] addrtype[addrtypelen]
216 * addr[addrlen])[numaddr]
218 #define LIST_NEIGH_FIELD_ADDR 1
221 * latency_in_microsecs[4]
222 * Only raw network latency in measured. Delays caused by the credit system are
225 #define LIST_NEIGH_FIELD_LATENCY 2
229 * CD_SET_TOS[2] length[1-4] forward_tos[1] backward_tos[1]
230 * Only 2 bits of the tos flags are used, the highers 6 bits are ignored.
235 #define TOS_LATENCY 1
236 #define TOS_THROUGHPUT 2
237 #define TOS_PRIVACY 3
242 * Connection data response
243 * Format is the same as with connection data
252 * CDR_EXECFAILED[1] reasoncode[2]
253 * reasontextlength[1-4] reasontext[reasontextlength]
254 * reasontextlength may be 0
256 #define CDR_EXECFAILED 2
257 #define CDR_EXECFAILED_UNKNOWN_COMMAND 1
258 #define CDR_EXECFAILED_PERMISSION_DENIED 2
259 #define CDR_EXECFAILED_TEMPORARILY_OUT_OF_RESSOURCES 3
260 #define CDR_EXECFAILED_CMD_TOO_SHORT 4
261 #define CDR_EXECFAILED_CMD_TOO_LONG 5
262 #define CDR_EXECFAILED_TARGETADDRTYPE_UNKNOWN 6
263 #define CDR_EXECFAILED_TARGETADDR_DOESNTEXIST 7
264 #define CDR_EXECFAILED_TARGETADDR_PORTCLOSED 8
265 #define CDR_EXECFAILED_LISTENERQUEUE_FULL 9
266 #define CDR_EXECFAILED_ILLEGAL_COMMAND 10
269 * must be sent after CDR_EXEC{OK|FAILED}
270 * CDR_EXEOK_BINDATA[1] bindatalen[1-4] bindata[bindatalen] */
271 #define CDR_BINDATA 3
274 * sending 2^32 credits per millisec means that credits the neighbor owns
275 * should be halfed after 1 minute
277 * ((x - 4294967295)/x) ^ 60000 = 0.5
278 * (x-4294967295)/x = 0.5**(1/60000)
279 * x/x - 4294967295/x = 0.5**(1/60000)
280 * 1 - 0.5**(1/60000) = 4294967295/x
281 * x = 4294967295 / (1 - 0.5**(1/60000))
283 #define CREDITS_TOTAL 371781828609998LL
287 /* result codes for rcv.c/proc_packet */
289 #define RC_FINISHED 1
291 #define RC_RCV1_ANNOUNCE 2
292 #define RC_RCV1_KERNEL 3
293 #define RC_RCV1_CONN 4
296 /* start of next element, *not* next htab_entry */
301 struct htab_entry
**htable
;
306 int (*matches
)(void *htentry
, void *searcheditem
);
317 struct announce_data
{
321 struct net_device
*dev
;
322 struct delayed_work announce_work
;
323 struct announce
*ann
;
324 struct resume_block rb
;
326 __u32 curr_announce_msg_offset
;
327 __u64 scheduled_announce_timer
;
333 __u8 pongs
; /* count of pongs for pings sent after this one */
336 #define NEIGHBOR_STATE_INITIAL 0
337 #define NEIGHBOR_STATE_ACTIVE 1
338 #define NEIGHBOR_STATE_STALLED 2
339 #define NEIGHBOR_STATE_KILLED 3
342 struct list_head nb_list
;
346 struct net_device
*dev
;
347 char mac
[MAX_ADDR_LEN
];
352 struct delayed_work cmsg_timer
;
353 struct mutex cmsg_lock
;
354 struct list_head control_msgs_out
;
356 * urgent messages; These are sent even if the neighbor state is not
357 * active. If the queue gets full, the oldest ones are dropped. It thus
358 * may only contain messages which are allowed to be dropped.
360 struct list_head ucontrol_msgs_out
;
361 unsigned long timeout
;
365 atomic_t cmcnt
; /* size of queue + retransmits */
366 atomic_t ucmcnt
; /* size of queue only */
369 __u8 max_cmsg_delay_sent
;
371 /* see snd.c/qos_queue */
372 /* protected by cmsg_lock */
375 /* procected by queues_lock */
376 struct resume_block rb_kp
;
377 struct resume_block rb_cr
;
379 struct mutex pingcookie_lock
;
380 unsigned long last_ping_time
;
381 __u32 ping_intransit
;
382 struct ping_cookie cookies
[PING_COOKIES_PER_NEIGH
];
384 atomic_t latency
; /* microsecs */
385 atomic_t max_remote_cmsg_delay
; /* microsecs */
387 spinlock_t state_lock
;
389 __u64 last_state_change
;/* initial state */
392 * time of the last sent packet which has been acked or
393 * otherwise responded to (e.g. pong)
395 unsigned long last_roundtrip
;/* active/stalled state */
400 struct delayed_work stalltimeout_timer
;
401 __u8 str_timer_pending
;
404 atomic_t kpacket_seqno
;
405 atomic_t ooo_packets
;
407 spinlock_t credits_lock
;
408 unsigned long jiffies_credit_update
;
409 unsigned long jiffies_credit_decay
;
411 /* we only keep track on how much the other side may spend */
414 /* credit rates are in credits/ms */
415 __u32 creditrate_initial
;
416 __u64 creditrate_earning
;
417 __u64 creditrate_spending
;
420 * connecions which receive data from/send data to this node
421 * used when terminating all connections of a neighbor
423 struct mutex conn_list_lock
;
424 struct list_head rcv_conn_list
;
425 struct list_head snd_conn_list
;
426 __u32 num_send_conns
;
429 * used for ping_all conns, if not zero this is the next conn we need to
430 * ping, protected by conn_list_lock
432 struct conn
*next_ping_conn
;
433 __u32 ping_conns_remaining
;
434 __u32 ping_conns_retrans_remaining
;
435 __u32 pong_conns_expected
;
436 unsigned long ping_conn_completed
; /* jiffies */
439 * the timer has to be inited when adding the neighbor
440 * init_timer(struct timer_list * timer);
441 * add_timer(struct timer_list * timer);
443 spinlock_t retrans_lock
;
444 struct delayed_work retrans_timer_conn
;
445 struct delayed_work retrans_timer
;
446 __u8 retrans_timer_conn_running
;
447 __u8 retrans_timer_running
;
449 struct list_head retrans_list
;
450 struct list_head retrans_list_conn
;
452 struct conn
*firstboundconn
;
455 struct cor_sched_data
{
457 struct list_head conn_list
;
458 struct sk_buff_head requeue_queue
;
464 struct data_buf_item
{
465 struct list_head buf_list
;
485 struct connlistener
*owner
;
489 #define SOCKSTATE_LISTENER 1
490 #define SOCKSTATE_CONN 2
493 /* The first member of connlistener/conn (see sock.c) */
497 struct connlistener
{
498 /* The first member has to be the same as in conn (see sock.c) */
504 struct list_head conn_queue
;
505 wait_queue_head_t wait
;
510 __u64 speed
;/* bytes*65536/jiffie */
511 unsigned long jiffies_last_update
;
516 * There are 2 conn objects per bi-directional connection. They refer to each
517 * other with in the reversedir field. To distinguish them, the variables on
518 * the stack are usually called rconn and sconn. rconn refers to the conn object
519 * which has received a command. sconn is the other conn object.
522 /* The first member has to be the same as in connlistener (see sock.c)*/
525 #define SOURCE_NONE 0
527 #define SOURCE_SOCK 2
529 #define TARGET_UNCONNECTED 0
531 #define TARGET_SOCK 2
538 __u8 last_bufferstate
:1,
543 * 0... connection active
544 * 1... connection is about to be reset, target does not need to be
546 * 2... connection is reset
547 * 3... connection is reset + no pointers to "struct conn *reversedir"
548 * remaining except from this conn
552 struct list_head queue_list
;
558 * 1) If both sides are SOCK, the side with source.sock.is_client == 1
559 * has to be locked first. This is needed for credits.
560 * 2) If one side is NONE/UNCONNECTED and the direction with
561 * TARGET_UNCONNECTED has to be locked first This is needed for
562 * changing source/targettype, credit flow and TARGET_UNCONNECTED
563 * generating responses.
564 * 3) If one side is SOCK and the other is IN/OUT, TARGET_SOCK has to be
566 * 4) If data is forwarded, (both sides are IN/OUT), only one direction
569 struct mutex rcv_lock
;
571 unsigned long jiffies_credit_update
;
572 struct list_head credit_list
;
575 /* credit rates, locked by credit_lock (in credit.c) */
579 * This is how much we *want* to forward, but how much we actually do.
587 /* list of all connections from this neighbor */
588 struct list_head nb_list
;
590 struct sk_buff_head reorder_queue
;
592 struct htab_entry htab_entry
;
597 atomic_t pong_awaiting
;
602 __u32 window_seqnolimit_max
;
603 __u32 window_seqnolimit_last
;
605 struct list_head buffer_list
;
616 struct speedtracker st
;
618 unsigned long jiffies_last_window_set
;
622 struct list_head cl_list
;
623 wait_queue_head_t wait
;
629 struct sock_buffertracker
*sbt
;
630 struct list_head delflush_list
;
631 struct list_head alwait_list
;
646 char paramlen_buf
[4];
648 __u8 in_buffer_wait_list
;
649 struct list_head buffer_wait_list
;
653 /* has to be first (because it is first in target
657 /* list of all connections to this neighbor */
658 struct list_head nb_list
;
659 /* protected by nb->retrans_lock, sorted by seqno */
660 struct list_head retrans_list
;
662 /* reverse conn_id lookup */
663 struct htab_entry htab_entry
;
666 __u32 seqno_nextsend
;
668 __u32 seqno_windowlimit
;
669 __u32 kp_windowsetseqno
;
671 struct resume_block rb
;
674 __u64 crate_out_raw_remote
;
675 __s64 crate_out_remotediff
;
679 wait_queue_head_t wait
;
686 struct list_head items
;
687 struct data_buf_item
*lastread
;
692 __u32 read_remaining
;
694 __u16 last_read_offset
;
696 __u16 cpacket_buffer
;/* including overhead */
699 struct conn
*reversedir
;
703 struct skb_procstate
{
706 struct work_struct work
;
719 struct sock_buffertracker
{
725 struct list_head delflush_conns
;
726 struct list_head waiting_conns
;
733 extern atomic_t num_conns
;
735 extern __u8
enc_log_64_11(__u32 window_bytes
);
737 extern __u32
dec_log_64_11(__u8 window
);
739 extern __u64
multiply_div(__u64 a
, __u64 b
, __u64 c
);
741 extern char *htable_get(struct htable
*ht
, __u32 key
, void *searcheditem
);
743 extern int htable_delete(struct htable
*ht
, __u32 key
, void *searcheditem
,
744 void (*free
) (struct kref
*ref
));
746 extern void htable_insert(struct htable
*ht
, char *newelement
, __u32 key
);
748 extern void htable_init(struct htable
*ht
, int (*matches
)(void *htentry
,
749 void *searcheditem
), __u32 entry_offset
,
752 extern struct conn
*get_conn_reverse(struct neighbor
*nb
, __u32 conn_id
);
754 extern void insert_reverse_connid(struct conn
*rconn
);
756 extern struct conn
*get_conn(__u32 conn_id
);
758 extern void free_conn(struct kref
*ref
);
760 extern int conn_init_out(struct conn
*rconn
, struct neighbor
*nb
);
762 extern void conn_init_sock_source(struct conn
*conn
);
764 extern void conn_init_sock_target(struct conn
*conn
);
766 extern void close_port(struct connlistener
*listener
);
768 extern struct connlistener
*open_port(__be64 port
);
770 extern int connect_port(struct conn
*rconn
, __be64 port
);
772 extern int connect_neigh(struct conn
*rconn
,
773 __u16 addrtypelen
, __u8
*addrtype
,
774 __u16 addrlen
, __u8
*addr
);
776 extern struct conn
* alloc_conn(gfp_t allocflags
);
778 extern void reset_ping(struct conn
*rconn
);
780 extern void reset_conn(struct conn
*conn
);
783 extern __u32
creditrate_initial(void);
785 extern int refresh_conn_credits(struct conn
*conn
, int fromperiodic
,
788 extern void set_creditrate_initial(struct neighbor
*nb
, __u32 debitrate
);
790 extern void set_conn_in_crate(struct conn
*rconn
, __u64 crate_in
);
792 extern void connreset_credits(struct conn
*conn
);
794 extern void credits_init(void);
797 extern void neighbor_free(struct kref
*ref
);
799 extern struct neighbor
*get_neigh_by_mac(struct sk_buff
*skb
);
801 extern struct neighbor
*find_neigh(__u16 addrtypelen
, __u8
*addrtype
,
802 __u16 addrlen
, __u8
*addr
);
804 extern __u32
generate_neigh_list(char *buf
, __u32 buflen
, __u32 limit
,
807 extern int get_neigh_state(struct neighbor
*nb
);
809 extern void ping_resp(struct neighbor
*nb
, __u32 cookie
, __u32 respdelay
);
811 extern __u32
add_ping_req(struct neighbor
*nb
);
813 extern void unadd_ping_req(struct neighbor
*nb
, __u32 cookie
);
815 extern int time_to_send_ping(struct neighbor
*nb
);
817 extern int force_ping(struct neighbor
*nb
);
819 extern void rcv_announce(struct sk_buff
*skb
);
821 extern int send_announce_qos(struct announce_data
*ann
);
823 extern void announce_data_free(struct kref
*ref
);
825 extern int __init
cor_neighbor_init(void);
828 extern __u8
get_window(struct conn
*rconn
);
830 extern void reset_bufferusage(struct conn
*conn
);
832 extern void refresh_speedstat(struct conn
*rconn
, __u32 written
);
834 extern void drain_ooo_queue(struct conn
*rconn
);
836 extern void conn_rcv_buildskb(char *data
, __u32 datalen
, __u32 conn_id
,
839 extern int __init
cor_rcv_init(void);
841 /* kpacket_parse.c */
842 extern void kernel_packet(struct neighbor
*nb
, struct sk_buff
*skb
, __u32 seqno
);
845 extern void schedule_controlmsg_timerfunc(struct neighbor
*nb
);
847 struct control_msg_out
;
849 #define ACM_PRIORITY_LOW 1
850 #define ACM_PRIORITY_MED 2
851 #define ACM_PRIORITY_HIGH 3
853 extern int may_alloc_control_msg(struct neighbor
*nb
, int priority
);
855 extern struct control_msg_out
*alloc_control_msg(struct neighbor
*nb
,
858 extern void free_control_msg(struct control_msg_out
*cm
);
860 extern void retransmit_timerfunc(struct work_struct
*work
);
862 extern void kern_ack_rcvd(struct neighbor
*nb
, __u32 seqno
);
864 extern int send_messages(struct neighbor
*nb
, int allmsgs
, int resume
);
866 extern void send_pong(struct neighbor
*nb
,
869 extern void send_reset_conn(struct control_msg_out
*cm
, __u32 conn_id
);
871 extern void send_ack(struct neighbor
*nb
,
874 extern void send_ack_conn(struct control_msg_out
*cm
, struct conn
*rconn
,
875 __u32 conn_id
, __u32 seqno
);
877 extern void send_ack_conn_ooo(struct control_msg_out
*cm
, struct conn
*rconn
,
878 __u32 conn_id
, __u32 seqno
, __u32 seqno_ooo
, __u32 length
);
880 extern void send_connect_success(struct control_msg_out
*cm
, __u32 rcvd_conn_id
,
881 __u32 gen_conn_id
, __u32 init_seqno
, struct conn
*rconn
);
883 extern void send_connect_nb(struct control_msg_out
*cm
, __u32 conn_id
,
884 __u32 init_seqno
, struct conn
*sconn
);
886 extern void send_conndata(struct control_msg_out
*cm
, __u32 conn_id
,
887 __u32 seqno
, char *data_orig
, char *data
, __u32 datalen
);
889 extern void send_ping_conn(struct control_msg_out
*cm
, __u32 conn_id
);
891 extern void send_connid_unknown(struct control_msg_out
*cm
, __u32 conn_id
);
893 extern void send_ping_all_conns(struct neighbor
*nb
);
895 extern void set_creditrate_out(struct control_msg_out
*cm
, __u32 conn_id
,
898 extern void cor_kgen_init(void);
900 /* cpacket_parse.c */
901 extern void free_cpacket_buffer(__s32 amount
);
903 extern void connreset_cpacket_buffer(struct conn
*rconn
);
905 extern int encode_len(char *buf
, int buflen
, __u32 len
);
907 extern int decode_len(char *buf
, int buflen
, __u32
*len
);
909 extern void parse(struct conn
*rconn
, int fromresume
);
911 extern int __init
cor_cpacket_init(void);
914 extern int destroy_queue(struct net_device
*dev
);
916 extern int create_queue(struct net_device
*dev
);
918 #define QOS_CALLER_KPACKET 0
919 #define QOS_CALLER_CONN_RETRANS 1
920 #define QOS_CALLER_ANNOUNCE 2
921 #define QOS_CALLER_CONN 3
923 extern void qos_enqueue(struct net_device
*dev
, struct resume_block
*rb
,
926 extern void qos_remove_conn(struct conn
*rconn
);
928 extern struct sk_buff
*create_packet(struct neighbor
*nb
, int size
,
929 gfp_t alloc_flags
, __u32 conn_id
, __u32 seqno
);
931 extern void cancel_retrans(struct conn
*rconn
);
933 extern void retransmit_conn_timerfunc(struct work_struct
*work
);
935 extern void conn_ack_rcvd(__u32 kpacket_seqno
, struct conn
*rconn
, __u32 seqno
,
936 __u8 window
, __u32 seqno_ooo
, __u32 length
);
938 #define RC_FLUSH_CONN_OUT_OK 0
939 #define RC_FLUSH_CONN_OUT_OK_SENT 1
940 #define RC_FLUSH_CONN_OUT_CONG 2
941 #define RC_FLUSH_CONN_OUT_CREDITS 3
942 #define RC_FLUSH_CONN_OUT_OOM 4
943 extern int flush_out(struct conn
*rconn
, int fromqos
, __u32 creditsperbyte
);
945 extern int __init
cor_snd_init(void);
948 extern void databuf_pull(struct conn
*conn
, char *dst
, int len
);
950 extern size_t databuf_pulluser(struct conn
*sconn
, struct msghdr
*msg
);
952 extern void databuf_unpull(struct conn
*conn
, __u32 bytes
);
954 extern void databuf_pullold(struct conn
*conn
, __u32 startpos
, char *dst
,
957 extern void databuf_ack(struct conn
*rconn
, __u32 pos
);
959 extern void databuf_ackread(struct conn
*rconn
);
961 extern void flush_buf(struct conn
*rconn
);
963 extern void reset_seqno(struct conn
*conn
, __u32 initseqno
);
965 extern void databuf_free(struct conn
*conn
);
967 extern void databuf_init(struct conn
*conn
);
969 __s64
receive_userbuf(struct conn
*rconn
, struct msghdr
*msg
, __u32 maxcpy
,
972 extern void receive_cpacketresp(struct conn
*rconn
, char *buf
, int len
);
974 extern int receive_skb(struct conn
*rconn
, struct sk_buff
*skb
);
976 extern void wake_sender(struct conn
*rconn
);
978 extern void forward_init(void);
981 extern struct mutex sock_bufferlimits_lock
;
983 extern void free_sbt(struct kref
*ref
);
985 extern void unreserve_sock_buffer(struct conn
*conn
);
988 static inline struct skb_procstate
*skb_pstate(struct sk_buff
*skb
)
990 return (struct skb_procstate
*) &(skb
->cb
[0]);
993 static inline struct sk_buff
*skb_from_pstate(struct skb_procstate
*ps
)
995 return (struct sk_buff
*) (((char *)ps
) - offsetof(struct sk_buff
,cb
));
999 static inline __u32
mss(struct neighbor
*nb
)
1001 return nb
->dev
->mtu
- LL_RESERVED_SPACE(nb
->dev
) - 9;
1005 static inline void put_u64(char *dst
, __u64 value
, int convbo
)
1007 char *p_value
= (char *) &value
;
1010 value
= cpu_to_be64(value
);
1012 dst
[0] = p_value
[0];
1013 dst
[1] = p_value
[1];
1014 dst
[2] = p_value
[2];
1015 dst
[3] = p_value
[3];
1016 dst
[4] = p_value
[4];
1017 dst
[5] = p_value
[5];
1018 dst
[6] = p_value
[6];
1019 dst
[7] = p_value
[7];
1022 static inline void put_u32(char *dst
, __u32 value
, int convbo
)
1024 char *p_value
= (char *) &value
;
1027 value
= cpu_to_be32(value
);
1029 dst
[0] = p_value
[0];
1030 dst
[1] = p_value
[1];
1031 dst
[2] = p_value
[2];
1032 dst
[3] = p_value
[3];
1035 static inline void put_u16(char *dst
, __u16 value
, int convbo
)
1037 char *p_value
= (char *) &value
;
1040 value
= cpu_to_be16(value
);
1042 dst
[0] = p_value
[0];
1043 dst
[1] = p_value
[1];
1046 static inline char *cor_pull_skb(struct sk_buff
*skb
, unsigned int len
)
1048 char *ptr
= skb_pull(skb
, len
);
1050 if(unlikely(ptr
== 0))
1056 #define S64_MAX 9223372036854775807LL
1057 #define S64_MIN (1LL << 63)