: API to query the current TX/RX CCID
PATCH 9/9 : API to query the current TX/RX CCID
[DCCP]: API to query the current TX/RX CCID
This provides function to query the current TX/RX CCID dynamically, without reliance on the minisock value, using dynamic information available in the currently loaded CCID module.
This query function is then used
(a) to provide the getsockopt part for getting/setting CCIDs via sockopts;
(b) replaces the current use in dccp_probe.
--- net/dccp/ccid.h | 9 +++++++++ net/dccp/probe.c | 7 ++----- net/dccp/proto.c | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-)
net/dccp/ccid.h +9 -0
@@ -93,6 +93,15 @@ extern struct ccid *ccid_hc_rx_new(unsigextern struct ccid *ccid_hc_tx_new (unsigned char id,struct sock *sk,gfp_t gfp); +static inline int ccid_get_current_id (struct dccp_sock *dp,bool rx) +{ +struct ccid *ccid = rx? dp->dccps_hc_rx_ccid : dp->dccps_hc_tx_ccid; + +if (ccid =NULL || ccid->ccid_ops =NULL ) +return -1 ; +return ccid->ccid_ops->ccid_id; +} +extern void ccid_hc_rx_delete (struct ccid *ccid,struct sock *sk);extern void ccid_hc_tx_delete (struct ccid *ccid,struct sock *sk);
net/dccp/proto.c +6 -0
@@ -668,6 +668,12 @@ static int do_dccp_getsockopt(struct socbreak ;case DCCP_SOCKOPT_AVAILABLE_CCIDS :return ccid_getsockopt_available_ccids (sk, len, optval, optlen); +case DCCP_SOCKOPT_TX_CCID : +case DCCP_SOCKOPT_RX_CCID : + val =ccid_get_current_id (dp, optname =DCCP_SOCKOPT_RX_CCID ); +if (val <0 ) +return -ENOPROTOOPT ; +break ;case DCCP_SOCKOPT_SERVER_TIMEWAIT : val = dp->dccps_server_timewait;break ;
net/dccp/probe.c +2 -5
@@ -78,14 +78,11 @@ static void printl(const char *fmt, ...)static int jdccp_sendmsg (struct kiocb *iocb,struct sock *sk,struct msghdr *msg,size_t size) { -const struct dccp_minisock *dmsk =dccp_msk (sk);const struct inet_sock *inet =inet_sk (sk); -const struct ccid3_hc_tx_sock *hctx; +struct ccid3_hc_tx_sock *hctx =NULL ; -if (dmsk->dccpms_tx_ccid =DCCPC_CCID3 ) +if (ccid_get_current_id (dccp_sk (sk), false) =DCCPC_CCID3 ) hctx =ccid3_hc_tx_sk (sk); -else - hctx =NULL ;if (port =0 ||ntohs (inet->dport) = port ||ntohs (inet->sport) = port) {
Quoted 10 lines · Gerrit Renker
[DCCP]: API to query the current TX/RX CCID
This provides function to query the current TX/RX CCID dynamically, without reliance on the minisock value, using dynamic information available in the currently loaded CCID module.
This query function is then used
(a) to provide the getsockopt part for getting/setting CCIDs via sockopts;
(b) replaces the current use indccp_probe.Signed-off-by Gerrit Renker <[email protected]>
I presume this is to support more CCIDs in future as currently makes the code more complicated...
Signature · 3 lines
Web1: http://wand.net.nz/~iam4/ Web2: http://www.jandi.co.nz Blog: http://iansblog.jandi.co.nz
| > [DCCP]: API to query the current TX/RX CCID | > | > This provides function to query the current TX/RX CCID dynamically, without | > reliance on the minisock value, using dynamic information available in the | > currently loaded CCID module. <snip> | | I presume this is to support more CCIDs in future as currently makes | the code more complicated...
The benefits are not visible in this patch - the tx_ccid/rx_ccid members of the minisock are removed in a future patch, and from then on CCIDs are fully dynamic.