6 * An implementation of the DCCP protocol
7 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
17 #include <linux/dccp.h>
18 #include <linux/list.h>
19 #include <linux/module.h>
24 unsigned char ccid_id
;
25 const char *ccid_name
;
26 struct module
*ccid_owner
;
27 int (*ccid_init
)(struct sock
*sk
);
28 void (*ccid_exit
)(struct sock
*sk
);
29 int (*ccid_hc_rx_init
)(struct sock
*sk
);
30 int (*ccid_hc_tx_init
)(struct sock
*sk
);
31 void (*ccid_hc_rx_exit
)(struct sock
*sk
);
32 void (*ccid_hc_tx_exit
)(struct sock
*sk
);
33 void (*ccid_hc_rx_packet_recv
)(struct sock
*sk
,
35 int (*ccid_hc_rx_parse_options
)(struct sock
*sk
,
37 unsigned char len
, u16 idx
,
38 unsigned char* value
);
39 void (*ccid_hc_rx_insert_options
)(struct sock
*sk
,
41 void (*ccid_hc_tx_insert_options
)(struct sock
*sk
,
43 void (*ccid_hc_tx_packet_recv
)(struct sock
*sk
,
45 int (*ccid_hc_tx_parse_options
)(struct sock
*sk
,
47 unsigned char len
, u16 idx
,
48 unsigned char* value
);
49 int (*ccid_hc_tx_send_packet
)(struct sock
*sk
,
50 struct sk_buff
*skb
, int len
);
51 void (*ccid_hc_tx_packet_sent
)(struct sock
*sk
, int more
,
53 void (*ccid_hc_rx_get_info
)(struct sock
*sk
,
54 struct tcp_info
*info
);
55 void (*ccid_hc_tx_get_info
)(struct sock
*sk
,
56 struct tcp_info
*info
);
59 extern int ccid_register(struct ccid
*ccid
);
60 extern int ccid_unregister(struct ccid
*ccid
);
62 extern struct ccid
*ccid_init(unsigned char id
, struct sock
*sk
);
63 extern void ccid_exit(struct ccid
*ccid
, struct sock
*sk
);
65 static inline void __ccid_get(struct ccid
*ccid
)
67 __module_get(ccid
->ccid_owner
);
70 static inline int ccid_hc_tx_send_packet(struct ccid
*ccid
, struct sock
*sk
,
71 struct sk_buff
*skb
, int len
)
74 if (ccid
->ccid_hc_tx_send_packet
!= NULL
)
75 rc
= ccid
->ccid_hc_tx_send_packet(sk
, skb
, len
);
79 static inline void ccid_hc_tx_packet_sent(struct ccid
*ccid
, struct sock
*sk
,
82 if (ccid
->ccid_hc_tx_packet_sent
!= NULL
)
83 ccid
->ccid_hc_tx_packet_sent(sk
, more
, len
);
86 static inline int ccid_hc_rx_init(struct ccid
*ccid
, struct sock
*sk
)
89 if (ccid
->ccid_hc_rx_init
!= NULL
)
90 rc
= ccid
->ccid_hc_rx_init(sk
);
94 static inline int ccid_hc_tx_init(struct ccid
*ccid
, struct sock
*sk
)
97 if (ccid
->ccid_hc_tx_init
!= NULL
)
98 rc
= ccid
->ccid_hc_tx_init(sk
);
102 static inline void ccid_hc_rx_exit(struct ccid
*ccid
, struct sock
*sk
)
104 if (ccid
->ccid_hc_rx_exit
!= NULL
&&
105 dccp_sk(sk
)->dccps_hc_rx_ccid_private
!= NULL
)
106 ccid
->ccid_hc_rx_exit(sk
);
109 static inline void ccid_hc_tx_exit(struct ccid
*ccid
, struct sock
*sk
)
111 if (ccid
->ccid_hc_tx_exit
!= NULL
&&
112 dccp_sk(sk
)->dccps_hc_tx_ccid_private
!= NULL
)
113 ccid
->ccid_hc_tx_exit(sk
);
116 static inline void ccid_hc_rx_packet_recv(struct ccid
*ccid
, struct sock
*sk
,
119 if (ccid
->ccid_hc_rx_packet_recv
!= NULL
)
120 ccid
->ccid_hc_rx_packet_recv(sk
, skb
);
123 static inline void ccid_hc_tx_packet_recv(struct ccid
*ccid
, struct sock
*sk
,
126 if (ccid
->ccid_hc_tx_packet_recv
!= NULL
)
127 ccid
->ccid_hc_tx_packet_recv(sk
, skb
);
130 static inline int ccid_hc_tx_parse_options(struct ccid
*ccid
, struct sock
*sk
,
131 unsigned char option
,
132 unsigned char len
, u16 idx
,
133 unsigned char* value
)
136 if (ccid
->ccid_hc_tx_parse_options
!= NULL
)
137 rc
= ccid
->ccid_hc_tx_parse_options(sk
, option
, len
, idx
,
142 static inline int ccid_hc_rx_parse_options(struct ccid
*ccid
, struct sock
*sk
,
143 unsigned char option
,
144 unsigned char len
, u16 idx
,
145 unsigned char* value
)
148 if (ccid
->ccid_hc_rx_parse_options
!= NULL
)
149 rc
= ccid
->ccid_hc_rx_parse_options(sk
, option
, len
, idx
, value
);
153 static inline void ccid_hc_tx_insert_options(struct ccid
*ccid
, struct sock
*sk
,
156 if (ccid
->ccid_hc_tx_insert_options
!= NULL
)
157 ccid
->ccid_hc_tx_insert_options(sk
, skb
);
160 static inline void ccid_hc_rx_insert_options(struct ccid
*ccid
, struct sock
*sk
,
163 if (ccid
->ccid_hc_rx_insert_options
!= NULL
)
164 ccid
->ccid_hc_rx_insert_options(sk
, skb
);
167 static inline void ccid_hc_rx_get_info(struct ccid
*ccid
, struct sock
*sk
,
168 struct tcp_info
*info
)
170 if (ccid
->ccid_hc_rx_get_info
!= NULL
)
171 ccid
->ccid_hc_rx_get_info(sk
, info
);
174 static inline void ccid_hc_tx_get_info(struct ccid
*ccid
, struct sock
*sk
,
175 struct tcp_info
*info
)
177 if (ccid
->ccid_hc_tx_get_info
!= NULL
)
178 ccid
->ccid_hc_tx_get_info(sk
, info
);