aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:30:19 -0400
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:45:28 -0400
commitc8041e264b3db6944d37b87969fbe6458cb30cfd (patch)
tree0dd21c001bea090756710216717a73d8e409a65d
parentfade756f18d42694e3acb00e3471ab43002cba16 (diff)
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 to (a) provide the getsockopt part for getting/setting CCIDs via sockopts; (b) replace the current test for "which CCID is in use" in probe.c. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
-rw-r--r--net/dccp/ccid.h18
-rw-r--r--net/dccp/probe.c7
-rw-r--r--net/dccp/proto.c10
3 files changed, 30 insertions, 5 deletions
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index 259f5469d7d0..803343aed004 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -116,6 +116,24 @@ extern struct ccid *ccid_hc_rx_new(unsigned char id, struct sock *sk,
116extern struct ccid *ccid_hc_tx_new(unsigned char id, struct sock *sk, 116extern struct ccid *ccid_hc_tx_new(unsigned char id, struct sock *sk,
117 gfp_t gfp); 117 gfp_t gfp);
118 118
119static inline int ccid_get_current_rx_ccid(struct dccp_sock *dp)
120{
121 struct ccid *ccid = dp->dccps_hc_rx_ccid;
122
123 if (ccid == NULL || ccid->ccid_ops == NULL)
124 return -1;
125 return ccid->ccid_ops->ccid_id;
126}
127
128static inline int ccid_get_current_tx_ccid(struct dccp_sock *dp)
129{
130 struct ccid *ccid = dp->dccps_hc_tx_ccid;
131
132 if (ccid == NULL || ccid->ccid_ops == NULL)
133 return -1;
134 return ccid->ccid_ops->ccid_id;
135}
136
119extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk); 137extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk);
120extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk); 138extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk);
121 139
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index 81368a7f5379..9ca783d74678 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -74,14 +74,11 @@ static void printl(const char *fmt, ...)
74static int jdccp_sendmsg(struct kiocb *iocb, struct sock *sk, 74static int jdccp_sendmsg(struct kiocb *iocb, struct sock *sk,
75 struct msghdr *msg, size_t size) 75 struct msghdr *msg, size_t size)
76{ 76{
77 const struct dccp_minisock *dmsk = dccp_msk(sk);
78 const struct inet_sock *inet = inet_sk(sk); 77 const struct inet_sock *inet = inet_sk(sk);
79 const struct ccid3_hc_tx_sock *hctx; 78 struct ccid3_hc_tx_sock *hctx = NULL;
80 79
81 if (dmsk->dccpms_tx_ccid == DCCPC_CCID3) 80 if (ccid_get_current_tx_ccid(dccp_sk(sk)) == DCCPC_CCID3)
82 hctx = ccid3_hc_tx_sk(sk); 81 hctx = ccid3_hc_tx_sk(sk);
83 else
84 hctx = NULL;
85 82
86 if (port == 0 || ntohs(inet->dport) == port || 83 if (port == 0 || ntohs(inet->dport) == port ||
87 ntohs(inet->sport) == port) { 84 ntohs(inet->sport) == port) {
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 2cd56df44d8e..6550452d59e2 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -667,6 +667,16 @@ static int do_dccp_getsockopt(struct sock *sk, int level, int optname,
667 break; 667 break;
668 case DCCP_SOCKOPT_AVAILABLE_CCIDS: 668 case DCCP_SOCKOPT_AVAILABLE_CCIDS:
669 return ccid_getsockopt_builtin_ccids(sk, len, optval, optlen); 669 return ccid_getsockopt_builtin_ccids(sk, len, optval, optlen);
670 case DCCP_SOCKOPT_TX_CCID:
671 val = ccid_get_current_tx_ccid(dp);
672 if (val < 0)
673 return -ENOPROTOOPT;
674 break;
675 case DCCP_SOCKOPT_RX_CCID:
676 val = ccid_get_current_rx_ccid(dp);
677 if (val < 0)
678 return -ENOPROTOOPT;
679 break;
670 case DCCP_SOCKOPT_SERVER_TIMEWAIT: 680 case DCCP_SOCKOPT_SERVER_TIMEWAIT:
671 val = dp->dccps_server_timewait; 681 val = dp->dccps_server_timewait;
672 break; 682 break;