aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2005-09-16 19:58:40 -0400
committerDavid S. Miller <davem@davemloft.net>2005-09-16 19:58:40 -0400
commit67e6b629212fa9ffb7420e8a88a41806af637e28 (patch)
tree64f07616a23b657f3eb06e1daedf2450f6fbfc60 /include
parent0c10c5d96865ce611d6a780888eff0ef4fab358b (diff)
[DCCP]: Introduce DCCP_SOCKOPT_SERVICE
As discussed in the dccp@vger mailing list: Now applications have to use setsockopt(DCCP_SOCKOPT_SERVICE, service[s]), prior to calling listen() and connect(). An array of unsigned ints can be passed meaning that the listening sock accepts connection requests for several services. With this we can ditch struct sockaddr_dccp and use only sockaddr_in (and sockaddr_in6 in the future). Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/dccp.h40
1 files changed, 29 insertions, 11 deletions
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index 8bf4bacb5051..0e72708677e4 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -4,16 +4,6 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <asm/byteorder.h> 5#include <asm/byteorder.h>
6 6
7/* Structure describing an Internet (DCCP) socket address. */
8struct sockaddr_dccp {
9 __u16 sdccp_family; /* Address family */
10 __u16 sdccp_port; /* Port number */
11 __u32 sdccp_addr; /* Internet address */
12 __u32 sdccp_service; /* Service */
13 /* Pad to size of `struct sockaddr': 16 bytes . */
14 __u32 sdccp_pad;
15};
16
17/** 7/**
18 * struct dccp_hdr - generic part of DCCP packet header 8 * struct dccp_hdr - generic part of DCCP packet header
19 * 9 *
@@ -188,6 +178,9 @@ enum {
188 178
189/* DCCP socket options */ 179/* DCCP socket options */
190#define DCCP_SOCKOPT_PACKET_SIZE 1 180#define DCCP_SOCKOPT_PACKET_SIZE 1
181#define DCCP_SOCKOPT_SERVICE 2
182
183#define DCCP_SERVICE_LIST_MAX_LEN 32
191 184
192#ifdef __KERNEL__ 185#ifdef __KERNEL__
193 186
@@ -382,6 +375,25 @@ enum dccp_role {
382 DCCP_ROLE_SERVER, 375 DCCP_ROLE_SERVER,
383}; 376};
384 377
378struct dccp_service_list {
379 __u32 dccpsl_nr;
380 __u32 dccpsl_list[0];
381};
382
383#define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1)
384
385static inline int dccp_list_has_service(const struct dccp_service_list *sl,
386 const u32 service)
387{
388 if (likely(sl != NULL)) {
389 u32 i = sl->dccpsl_nr;
390 while (i--)
391 if (sl->dccpsl_list[i] == service)
392 return 1;
393 }
394 return 0;
395}
396
385/** 397/**
386 * struct dccp_sock - DCCP socket state 398 * struct dccp_sock - DCCP socket state
387 * 399 *
@@ -417,7 +429,8 @@ struct dccp_sock {
417 __u64 dccps_gss; 429 __u64 dccps_gss;
418 __u64 dccps_gsr; 430 __u64 dccps_gsr;
419 __u64 dccps_gar; 431 __u64 dccps_gar;
420 unsigned long dccps_service; 432 __u32 dccps_service;
433 struct dccp_service_list *dccps_service_list;
421 struct timeval dccps_timestamp_time; 434 struct timeval dccps_timestamp_time;
422 __u32 dccps_timestamp_echo; 435 __u32 dccps_timestamp_echo;
423 __u32 dccps_packet_size; 436 __u32 dccps_packet_size;
@@ -443,6 +456,11 @@ static inline struct dccp_sock *dccp_sk(const struct sock *sk)
443 return (struct dccp_sock *)sk; 456 return (struct dccp_sock *)sk;
444} 457}
445 458
459static inline int dccp_service_not_initialized(const struct sock *sk)
460{
461 return dccp_sk(sk)->dccps_service == DCCP_SERVICE_INVALID_VALUE;
462}
463
446static inline const char *dccp_role(const struct sock *sk) 464static inline const char *dccp_role(const struct sock *sk)
447{ 465{
448 switch (dccp_sk(sk)->dccps_role) { 466 switch (dccp_sk(sk)->dccps_role) {