Module: xenomai-head
Branch: master
Commit: 604d65538c57be52ff7e6fe6ce47f0cbdad2089e
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=604d65538c57be52ff7e6fe6ce47f0cbdad2089e

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun May 30 14:50:28 2010 +0200

rtipc: define per-protocol socket option levels

---

 examples/rtdm/profiles/ipc/bufp-label.c     |    6 ++--
 examples/rtdm/profiles/ipc/bufp-readwrite.c |    2 +-
 examples/rtdm/profiles/ipc/iddp-label.c     |    6 ++--
 examples/rtdm/profiles/ipc/iddp-sendrecv.c  |    2 +-
 examples/rtdm/profiles/ipc/xddp-echo.c      |    4 ++-
 examples/rtdm/profiles/ipc/xddp-label.c     |    6 +++-
 examples/rtdm/profiles/ipc/xddp-stream.c    |    4 ++-
 include/rtdm/rtipc.h                        |   31 ++++++++++++--------------
 ksrc/drivers/ipc/bufp.c                     |   12 +++++-----
 ksrc/drivers/ipc/iddp.c                     |   26 +++++-----------------
 ksrc/drivers/ipc/xddp.c                     |   20 ++++++++--------
 11 files changed, 54 insertions(+), 65 deletions(-)

diff --git a/examples/rtdm/profiles/ipc/bufp-label.c 
b/examples/rtdm/profiles/ipc/bufp-label.c
index 9a1dde3..5df0999 100644
--- a/examples/rtdm/profiles/ipc/bufp-label.c
+++ b/examples/rtdm/profiles/ipc/bufp-label.c
@@ -66,7 +66,7 @@ void *server(void *arg)
         * port.
         */
        bufsz = 16384; /* bytes */
-       ret = setsockopt(s, SOL_RTIPC, BUFP_SETBUFFER,
+       ret = setsockopt(s, SOL_BUFP, BUFP_BUFSZ,
                         &bufsz, sizeof(bufsz));
        if (ret)
                fail("setsockopt");
@@ -76,7 +76,7 @@ void *server(void *arg)
         * binding, in addition to the port number (if given).
         */
        strcpy(label, BUFP_PORT_LABEL);
-       ret = setsockopt(s, SOL_RTIPC, BUFP_SETLABEL,
+       ret = setsockopt(s, SOL_BUFP, BUFP_LABEL,
                         label, sizeof(label));
        if (ret)
                fail("setsockopt");
@@ -130,7 +130,7 @@ void *client(void *arg)
         * port as well (like the server thread did).
         */
        strcpy(label, BUFP_PORT_LABEL);
-       ret = setsockopt(s, SOL_RTIPC, BUFP_SETLABEL,
+       ret = setsockopt(s, SOL_BUFP, BUFP_LABEL,
                         label, sizeof(label));
        if (ret)
                fail("setsockopt");
diff --git a/examples/rtdm/profiles/ipc/bufp-readwrite.c 
b/examples/rtdm/profiles/ipc/bufp-readwrite.c
index 7ea1a07..b1b0988 100644
--- a/examples/rtdm/profiles/ipc/bufp-readwrite.c
+++ b/examples/rtdm/profiles/ipc/bufp-readwrite.c
@@ -65,7 +65,7 @@ void *server(void *arg)
         * port.
         */
        bufsz = 16384; /* bytes */
-       ret = setsockopt(s, SOL_RTIPC, BUFP_SETBUFFER,
+       ret = setsockopt(s, SOL_BUFP, BUFP_BUFSZ,
                         &bufsz, sizeof(bufsz));
        if (ret)
                fail("setsockopt");
diff --git a/examples/rtdm/profiles/ipc/iddp-label.c 
b/examples/rtdm/profiles/ipc/iddp-label.c
index c477605..1ad324f 100644
--- a/examples/rtdm/profiles/ipc/iddp-label.c
+++ b/examples/rtdm/profiles/ipc/iddp-label.c
@@ -71,7 +71,7 @@ void *server(void *arg)
 
        /*
         * We will use Xenomai's system heap for datagram, so no
-        * IDDP_SETLOCALPOOL required here.
+        * IDDP_POOLSZ required here.
         */
 
        /*
@@ -79,7 +79,7 @@ void *server(void *arg)
         * binding, in addition to the port number (if given).
         */
        strcpy(label, IDDP_PORT_LABEL);
-       ret = setsockopt(s, SOL_RTIPC, IDDP_SETLABEL,
+       ret = setsockopt(s, SOL_IDDP, IDDP_LABEL,
                         label, sizeof(label));
        if (ret)
                fail("setsockopt");
@@ -146,7 +146,7 @@ void *client(void *arg)
         * port as well (like the server thread did).
         */
        strcpy(label, IDDP_PORT_LABEL);
-       ret = setsockopt(s, SOL_RTIPC, IDDP_SETLABEL,
+       ret = setsockopt(s, SOL_IDDP, IDDP_LABEL,
                         label, sizeof(label));
        if (ret)
                fail("setsockopt");
diff --git a/examples/rtdm/profiles/ipc/iddp-sendrecv.c 
b/examples/rtdm/profiles/ipc/iddp-sendrecv.c
index 601b46a..959ba50 100644
--- a/examples/rtdm/profiles/ipc/iddp-sendrecv.c
+++ b/examples/rtdm/profiles/ipc/iddp-sendrecv.c
@@ -69,7 +69,7 @@ void *server(void *arg)
         * of Xenomai's system pool.
         */
        poolsz = 32768; /* bytes */
-       ret = setsockopt(s, SOL_RTIPC, IDDP_SETLOCALPOOL,
+       ret = setsockopt(s, SOL_IDDP, IDDP_POOLSZ,
                         &poolsz, sizeof(poolsz));
        if (ret)
                fail("setsockopt");
diff --git a/examples/rtdm/profiles/ipc/xddp-echo.c 
b/examples/rtdm/profiles/ipc/xddp-echo.c
index b96f572..3ec33e3 100644
--- a/examples/rtdm/profiles/ipc/xddp-echo.c
+++ b/examples/rtdm/profiles/ipc/xddp-echo.c
@@ -51,6 +51,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <string.h>
+#include <malloc.h>
 #include <pthread.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -111,7 +112,7 @@ void *realtime_thread(void *arg)
         * Xenomai's system pool.
         */
        poolsz = 16384; /* bytes */
-       ret = setsockopt(s, SOL_RTIPC, XDDP_SETLOCALPOOL,
+       ret = setsockopt(s, SOL_XDDP, XDDP_POOLSZ,
                         &poolsz, sizeof(poolsz));
        if (ret)
                fail("setsockopt");
@@ -176,6 +177,7 @@ void *regular_thread(void *arg)
                fail("asprintf");
 
        fd = open(devname, O_RDWR);
+       free(devname);
        if (fd < 0)
                fail("open");
 
diff --git a/examples/rtdm/profiles/ipc/xddp-label.c 
b/examples/rtdm/profiles/ipc/xddp-label.c
index 859baa0..afd6ad9 100644
--- a/examples/rtdm/profiles/ipc/xddp-label.c
+++ b/examples/rtdm/profiles/ipc/xddp-label.c
@@ -57,6 +57,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <string.h>
+#include <malloc.h>
 #include <pthread.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -115,7 +116,7 @@ void *realtime_thread1(void *arg)
         * binding, in addition to the port number (if given).
         */
        strcpy(label, XDDP_PORT_LABEL);
-       ret = setsockopt(s, SOL_RTIPC, XDDP_SETLABEL,
+       ret = setsockopt(s, SOL_XDDP, XDDP_LABEL,
                         label, sizeof(label));
        if (ret)
                fail("setsockopt");
@@ -185,7 +186,7 @@ void *realtime_thread2(void *arg)
         * when connecting, instead of the port number.
         */
        strcpy(label, XDDP_PORT_LABEL);
-       ret = setsockopt(s, SOL_RTIPC, XDDP_SETLABEL,
+       ret = setsockopt(s, SOL_XDDP, XDDP_LABEL,
                         label, sizeof(label));
        if (ret)
                fail("setsockopt");
@@ -250,6 +251,7 @@ void *regular_thread(void *arg)
                fail("asprintf");
 
        fd = open(devname, O_RDWR);
+       free(devname);
        if (fd < 0)
                fail("open");
 
diff --git a/examples/rtdm/profiles/ipc/xddp-stream.c 
b/examples/rtdm/profiles/ipc/xddp-stream.c
index a970748..1cc5892 100644
--- a/examples/rtdm/profiles/ipc/xddp-stream.c
+++ b/examples/rtdm/profiles/ipc/xddp-stream.c
@@ -53,6 +53,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <string.h>
+#include <malloc.h>
 #include <pthread.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -118,7 +119,7 @@ void *realtime_thread(void *arg)
         * would disable streaming.
         */
        streamsz = 1024; /* bytes */
-       ret = setsockopt(s, SOL_RTIPC, XDDP_SETSTREAMBUF,
+       ret = setsockopt(s, SOL_XDDP, XDDP_BUFSZ,
                         &streamsz, sizeof(streamsz));
        if (ret)
                fail("setsockopt");
@@ -182,6 +183,7 @@ void *regular_thread(void *arg)
                fail("asprintf");
 
        fd = open(devname, O_RDWR);
+       free(devname);
        if (fd < 0)
                fail("open");
 
diff --git a/include/rtdm/rtipc.h b/include/rtdm/rtipc.h
index 0574671..0e7f2cd 100644
--- a/include/rtdm/rtipc.h
+++ b/include/rtdm/rtipc.h
@@ -85,25 +85,22 @@ struct sockaddr_ipc {
        rtipc_port_t sipc_port;
 };
 
-/* RTIPC socket level */
-#define SOL_RTIPC  311
-
-/* SOL_RTIPC level option names (via setsockopt) */
-#define XDDP_SETSTREAMBUF      1
-#define XDDP_SETMONITOR                2
-#define XDDP_SETLOCALPOOL      3
-#define XDDP_SETLABEL          4
-#define XDDP_GETLABEL          5
-#define IDDP_SETLOCALPOOL      6
-#define IDDP_GETSTALLCOUNT     7
-#define IDDP_SETLABEL          8
-#define IDDP_GETLABEL          9
-#define BUFP_SETBUFFER         10
-#define BUFP_SETLABEL          11
-#define BUFP_GETLABEL          12
-
+/* Socket level options (via set/getsockopt) */
+#define SOL_XDDP               311
+#define XDDP_LABEL             1
+#define XDDP_POOLSZ            2
+#define XDDP_BUFSZ             3
+#define XDDP_MONITOR           4
 #define XDDP_LABEL_LEN         XNOBJECT_NAME_LEN
+
+#define SOL_IDDP               312
+#define IDDP_LABEL             1
+#define IDDP_POOLSZ            2
 #define IDDP_LABEL_LEN         XNOBJECT_NAME_LEN
+
+#define SOL_BUFP               313
+#define BUFP_LABEL             1
+#define BUFP_BUFSZ             2
 #define BUFP_LABEL_LEN         XNOBJECT_NAME_LEN
 
 /* XDDP in-kernel monitored events */
diff --git a/ksrc/drivers/ipc/bufp.c b/ksrc/drivers/ipc/bufp.c
index 7f9b1fc..d3e91b8 100644
--- a/ksrc/drivers/ipc/bufp.c
+++ b/ksrc/drivers/ipc/bufp.c
@@ -773,7 +773,7 @@ static int __bufp_connect_socket(struct bufp_socket *sk,
         * immediately, regardless of whether the destination is
         * bound at the time of the call.
         *
-        * - If sipc_port is -1 and a label was set via BUFP_SETLABEL,
+        * - If sipc_port is -1 and a label was set via BUFP_LABEL,
         * connect() blocks for the requested amount of time until a
         * socket is bound to the same label, unless the internal
         * timeout (see SO_RCVTIMEO) specifies a non-blocking
@@ -857,12 +857,12 @@ static int __bufp_setsockopt(struct bufp_socket *sk,
                return ret;
        }
 
-       if (sopt.level != SOL_RTIPC)
+       if (sopt.level != SOL_BUFP)
                return -ENOPROTOOPT;
 
        switch (sopt.optname) {
 
-       case BUFP_SETBUFFER:
+       case BUFP_BUFSZ:
                if (sopt.optlen != sizeof(len))
                        return -EINVAL;
                if (rtipc_get_arg(user_info, &len,
@@ -883,7 +883,7 @@ static int __bufp_setsockopt(struct bufp_socket *sk,
                );
                break;
 
-       case BUFP_SETLABEL:
+       case BUFP_LABEL:
                if (sopt.optlen < sizeof(label))
                        return -EINVAL;
                if (rtipc_get_arg(user_info, label,
@@ -954,12 +954,12 @@ static int __bufp_getsockopt(struct bufp_socket *sk,
                return ret;
        }
 
-       if (sopt.level != SOL_RTIPC)
+       if (sopt.level != SOL_BUFP)
                return -ENOPROTOOPT;
 
        switch (sopt.optname) {
 
-       case BUFP_GETLABEL:
+       case BUFP_LABEL:
                if (len < sizeof(label))
                        return -EINVAL;
                RTDM_EXECUTE_ATOMICALLY(
diff --git a/ksrc/drivers/ipc/iddp.c b/ksrc/drivers/ipc/iddp.c
index 9131b0d..8525788 100644
--- a/ksrc/drivers/ipc/iddp.c
+++ b/ksrc/drivers/ipc/iddp.c
@@ -636,7 +636,7 @@ static int __iddp_connect_socket(struct iddp_socket *sk,
         * immediately, regardless of whether the destination is
         * bound at the time of the call.
         *
-        * - If sipc_port is -1 and a label was set via IDDP_SETLABEL,
+        * - If sipc_port is -1 and a label was set via IDDP_LABEL,
         * connect() blocks for the requested amount of time until a
         * socket is bound to the same label, unless the internal
         * timeout (see SO_RCVTIMEO) specifies a non-blocking
@@ -720,12 +720,12 @@ static int __iddp_setsockopt(struct iddp_socket *sk,
                return ret;
        }
 
-       if (sopt.level != SOL_RTIPC)
+       if (sopt.level != SOL_IDDP)
                return -ENOPROTOOPT;
 
        switch (sopt.optname) {
 
-       case IDDP_SETLOCALPOOL:
+       case IDDP_POOLSZ:
                if (sopt.optlen != sizeof(len))
                        return -EINVAL;
                if (rtipc_get_arg(user_info, &len,
@@ -746,13 +746,7 @@ static int __iddp_setsockopt(struct iddp_socket *sk,
                );
                break;
 
-       case IDDP_GETSTALLCOUNT:
-               if (rtipc_put_arg(user_info, arg,
-                                 &sk->stalls, sizeof(sk->stalls)))
-                       return -EFAULT;
-               break;
-
-       case IDDP_SETLABEL:
+       case IDDP_LABEL:
                if (sopt.optlen < sizeof(label))
                        return -EINVAL;
                if (rtipc_get_arg(user_info, label,
@@ -823,20 +817,12 @@ static int __iddp_getsockopt(struct iddp_socket *sk,
                return ret;
        }
 
-       if (sopt.level != SOL_RTIPC)
+       if (sopt.level != SOL_IDDP)
                return -ENOPROTOOPT;
 
        switch (sopt.optname) {
 
-       case IDDP_GETSTALLCOUNT:
-               if (len < sizeof(sk->stalls))
-                       return -EINVAL;
-               if (rtipc_put_arg(user_info, sopt.optval,
-                                 &sk->stalls, sizeof(sk->stalls)))
-                       return -EFAULT;
-               break;
-
-       case IDDP_GETLABEL:
+       case IDDP_LABEL:
                if (len < sizeof(label))
                        return -EINVAL;
                RTDM_EXECUTE_ATOMICALLY(
diff --git a/ksrc/drivers/ipc/xddp.c b/ksrc/drivers/ipc/xddp.c
index f32c192..b779d68 100644
--- a/ksrc/drivers/ipc/xddp.c
+++ b/ksrc/drivers/ipc/xddp.c
@@ -184,8 +184,8 @@ static void __xddp_free_handler(void *buf, void *xstate) /* 
nklock free */
        __clear_bit(_XDDP_ATOMIC, &sk->status);
 
        /*
-        * If a XDDP_SETSTREAMBUF request is pending, resize the
-        * streaming buffer on-the-fly.
+        * If a XDDP_BUFSZ request is pending, resize the streaming
+        * buffer on-the-fly.
         */
        if (unlikely(sk->curbufsz != sk->reqbufsz))
                __xddp_resize_streambuf(sk);
@@ -808,7 +808,7 @@ static int __xddp_connect_socket(struct xddp_socket *sk,
         * immediately, regardless of whether the destination is
         * bound at the time of the call.
         *
-        * - If sipc_port is -1 and a label was set via XDDP_SETLABEL,
+        * - If sipc_port is -1 and a label was set via XDDP_LABEL,
         * connect() blocks for the requested amount of time until a
         * socket is bound to the same label, unless the internal
         * timeout (see SO_RCVTIMEO) specifies a non-blocking
@@ -885,12 +885,12 @@ static int __xddp_setsockopt(struct xddp_socket *sk,
                return ret;
        }
 
-       if (sopt.level != SOL_RTIPC)
+       if (sopt.level != SOL_XDDP)
                return -ENOPROTOOPT;
 
        switch (sopt.optname) {
 
-       case XDDP_SETSTREAMBUF:
+       case XDDP_BUFSZ:
                if (sopt.optlen != sizeof(len))
                        return -EINVAL;
                if (rtipc_get_arg(user_info, &len,
@@ -912,7 +912,7 @@ static int __xddp_setsockopt(struct xddp_socket *sk,
                rtdm_lock_put_irqrestore(&sk->lock, lockctx);
                break;
 
-       case XDDP_SETLOCALPOOL:
+       case XDDP_POOLSZ:
                if (sopt.optlen != sizeof(len))
                        return -EINVAL;
                if (rtipc_get_arg(user_info, &len,
@@ -929,7 +929,7 @@ static int __xddp_setsockopt(struct xddp_socket *sk,
                );
                break;
 
-       case XDDP_SETMONITOR:
+       case XDDP_MONITOR:
                /* Monitoring is available from kernel-space only. */
                if (user_info)
                        return -EPERM;
@@ -941,7 +941,7 @@ static int __xddp_setsockopt(struct xddp_socket *sk,
                sk->monitor = monitor;
                break;
 
-       case XDDP_SETLABEL:
+       case XDDP_LABEL:
                if (sopt.optlen < sizeof(label))
                        return -EINVAL;
                if (rtipc_get_arg(user_info, label,
@@ -1000,12 +1000,12 @@ static int __xddp_getsockopt(struct xddp_socket *sk,
                return ret;
        }
 
-       if (sopt.level != SOL_RTIPC)
+       if (sopt.level != SOL_XDDP)
                return -ENOPROTOOPT;
 
        switch (sopt.optname) {
 
-       case XDDP_GETLABEL:
+       case XDDP_LABEL:
                if (len < sizeof(label))
                        return -EINVAL;
                RTDM_EXECUTE_ATOMICALLY(


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to