Socket option levels implemented
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 63b995b..3e9c139 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -149,4 +149,13 @@
# Installation.
install (FILES src/sp.h DESTINATION include/sp)
+install (FILES src/inproc.h DESTINATION include/sp)
+install (FILES src/ipc.h DESTINATION include/sp)
+install (FILES src/tcp.h DESTINATION include/sp)
+install (FILES src/pair.h DESTINATION include/sp)
+install (FILES src/pubsub.h DESTINATION include/sp)
+install (FILES src/reqrep.h DESTINATION include/sp)
+install (FILES src/fanin.h DESTINATION include/sp)
+install (FILES src/fanout.h DESTINATION include/sp)
+install (FILES src/survey.h DESTINATION include/sp)
diff --git a/doc/sp_fanin.7.txt b/doc/sp_fanin.7.txt
index 79dfda1..91e6012 100644
--- a/doc/sp_fanin.7.txt
+++ b/doc/sp_fanin.7.txt
@@ -8,9 +8,25 @@
SYNOPSIS
--------
-#include <sp/fanin.h>
+*#include <sp/sp.h>*
+
+*#include <sp/fanin.h>*
DESCRIPTION
-----------
-Blah-blah.
+FANIN pattern.
+
+
+SEE ALSO
+--------
+linknanomsg:sp_socket[3]
+linknanomsg:sp_getsockopt[3]
+linknanomsg:sp_setsockopt[3]
+linknanomsg:nanomsg[7]
+
+
+AUTHORS
+-------
+Martin Sustrik <sustrik@250bpm.com>
+
diff --git a/doc/sp_fanout.7.txt b/doc/sp_fanout.7.txt
index 1fc1d3f..448fe2a 100644
--- a/doc/sp_fanout.7.txt
+++ b/doc/sp_fanout.7.txt
@@ -8,9 +8,25 @@
SYNOPSIS
--------
-#include <sp/fanout.h>
+*#include <sp/sp.h>*
+
+*#include <sp/fanout.h>*
DESCRIPTION
-----------
-Blah-blah.
+FANOUT pattern.
+
+
+SEE ALSO
+--------
+linknanomsg:sp_socket[3]
+linknanomsg:sp_getsockopt[3]
+linknanomsg:sp_setsockopt[3]
+linknanomsg:nanomsg[7]
+
+
+AUTHORS
+-------
+Martin Sustrik <sustrik@250bpm.com>
+
diff --git a/doc/sp_inproc.7.txt b/doc/sp_inproc.7.txt
index 7a60c55..4167f0f 100644
--- a/doc/sp_inproc.7.txt
+++ b/doc/sp_inproc.7.txt
@@ -8,9 +8,25 @@
SYNOPSIS
--------
-#include <sp/inproc.h>
+*#include <sp/sp.h>*
+
+*#include <sp/inproc.h>*
DESCRIPTION
-----------
-Blah-blah.
+In-process transport.
+
+
+SEE ALSO
+--------
+linknanomsg:sp_ipc[7]
+linknanomsg:sp_tcp[7]
+linknanomsg:sp_bind[3]
+linknanomsg:sp_connect[3]
+linknanomsg:nanomsg[7]
+
+
+AUTHORS
+-------
+Martin Sustrik <sustrik@250bpm.com>
diff --git a/doc/sp_ipc.7.txt b/doc/sp_ipc.7.txt
index 3e92b9f..420ccb8 100644
--- a/doc/sp_ipc.7.txt
+++ b/doc/sp_ipc.7.txt
@@ -8,9 +8,25 @@
SYNOPSIS
--------
-#include <sp/ipc.h>
+*#include <sp/sp.h>*
+
+*#include <sp/ipc.h>*
DESCRIPTION
-----------
-Blah-blah.
+Inter-process transport.
+
+
+SEE ALSO
+--------
+linknanomsg:sp_inproc[7]
+linknanomsg:sp_tcp[7]
+linknanomsg:sp_bind[3]
+linknanomsg:sp_connect[3]
+linknanomsg:nanomsg[7]
+
+
+AUTHORS
+-------
+Martin Sustrik <sustrik@250bpm.com>
diff --git a/doc/sp_pair.7.txt b/doc/sp_pair.7.txt
index 69d4e99..f35b78e 100644
--- a/doc/sp_pair.7.txt
+++ b/doc/sp_pair.7.txt
@@ -8,9 +8,25 @@
SYNOPSIS
--------
-#include <sp/pair.h>
+*#include <sp/sp.h>*
+
+*#include <sp/pair.h>*
DESCRIPTION
-----------
-Blah-blah.
+PAIR pattern.
+
+
+SEE ALSO
+--------
+linknanomsg:sp_socket[3]
+linknanomsg:sp_getsockopt[3]
+linknanomsg:sp_setsockopt[3]
+linknanomsg:nanomsg[7]
+
+
+AUTHORS
+-------
+Martin Sustrik <sustrik@250bpm.com>
+
diff --git a/doc/sp_pubsub.7.txt b/doc/sp_pubsub.7.txt
index c9c6360..86eb642 100644
--- a/doc/sp_pubsub.7.txt
+++ b/doc/sp_pubsub.7.txt
@@ -8,9 +8,25 @@
SYNOPSIS
--------
-#include <sp/pubsub.h>
+*#include <sp/sp.h>*
+
+*#include <sp/pubsub.h>*
DESCRIPTION
-----------
-Blah-blah.
+PUBSUB pattern.
+
+
+SEE ALSO
+--------
+linknanomsg:sp_socket[3]
+linknanomsg:sp_getsockopt[3]
+linknanomsg:sp_setsockopt[3]
+linknanomsg:nanomsg[7]
+
+
+AUTHORS
+-------
+Martin Sustrik <sustrik@250bpm.com>
+
diff --git a/doc/sp_reqrep.7.txt b/doc/sp_reqrep.7.txt
index 66a6cc8..8d1fe07 100644
--- a/doc/sp_reqrep.7.txt
+++ b/doc/sp_reqrep.7.txt
@@ -8,9 +8,25 @@
SYNOPSIS
--------
-#include <sp/reprep.h>
+*#include <sp/sp.h>*
+
+*#include <sp/reprep.h>*
DESCRIPTION
-----------
-Blah-blah.
+REQREP pattern.
+
+
+SEE ALSO
+--------
+linknanomsg:sp_socket[3]
+linknanomsg:sp_getsockopt[3]
+linknanomsg:sp_setsockopt[3]
+linknanomsg:nanomsg[7]
+
+
+AUTHORS
+-------
+Martin Sustrik <sustrik@250bpm.com>
+
diff --git a/doc/sp_socket.3.txt b/doc/sp_socket.3.txt
index aad1e77..0c482be 100644
--- a/doc/sp_socket.3.txt
+++ b/doc/sp_socket.3.txt
@@ -10,7 +10,7 @@
--------
*#include <sp/sp.h>*
-*int sp_socket (int 'domain', int 'protocol');
+*int sp_socket (int 'domain', int 'protocol');*
DESCRIPTION
@@ -33,7 +33,8 @@
The newly created socket is initially not associated with any endpoints.
In order to establish a message flow at least one endpoint has to be added
-to the socket using _sp_bind()_ or _sp_connect()_ function.
+to the socket using linknanomsg:sp_bind[3] or linknanomsg:sp_connect[3]
+function.
Note that 'type' argument as found in standard _socket(2)_ function is omitted
from _sp_socket_. All the SP sockets are message-based and thus of
diff --git a/doc/sp_survey.7.txt b/doc/sp_survey.7.txt
index 2c0e71e..a61aeaa 100644
--- a/doc/sp_survey.7.txt
+++ b/doc/sp_survey.7.txt
@@ -8,9 +8,25 @@
SYNOPSIS
--------
-#include <sp/survey.h>
+*#include <sp/sp.h>*
+
+*#include <sp/survey.h>*
DESCRIPTION
-----------
-Blah-blah.
+SURVEY pattern.
+
+
+SEE ALSO
+--------
+linknanomsg:sp_socket[3]
+linknanomsg:sp_getsockopt[3]
+linknanomsg:sp_setsockopt[3]
+linknanomsg:nanomsg[7]
+
+
+AUTHORS
+-------
+Martin Sustrik <sustrik@250bpm.com>
+
diff --git a/doc/sp_tcp.7.txt b/doc/sp_tcp.7.txt
index dad8feb..d4b73b5 100644
--- a/doc/sp_tcp.7.txt
+++ b/doc/sp_tcp.7.txt
@@ -8,9 +8,26 @@
SYNOPSIS
--------
-#include <sp/tcp.h>
+*#include <sp/sp.h>*
+
+*#include <sp/tcp.h>*
DESCRIPTION
-----------
-Blah-blah.
+TCP transport.
+
+
+SEE ALSO
+--------
+linknanomsg:sp_inproc[7]
+linknanomsg:sp_ipc[7]
+linknanomsg:sp_bind[3]
+linknanomsg:sp_connect[3]
+linknanomsg:nanomsg[7]
+
+
+AUTHORS
+-------
+Martin Sustrik <sustrik@250bpm.com>
+
diff --git a/perf/inproc_lat.c b/perf/inproc_lat.c
index 098e91a..3196379 100644
--- a/perf/inproc_lat.c
+++ b/perf/inproc_lat.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
#include "../src/utils/err.c"
#include "../src/utils/thread.c"
diff --git a/perf/inproc_thr.c b/perf/inproc_thr.c
index e8ad4fd..c0d47b8 100644
--- a/perf/inproc_thr.c
+++ b/perf/inproc_thr.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
#include "../src/utils/err.c"
#include "../src/utils/thread.c"
diff --git a/perf/local_lat.c b/perf/local_lat.c
index 1e7fa3c..386a468 100644
--- a/perf/local_lat.c
+++ b/perf/local_lat.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/perf/local_thr.c b/perf/local_thr.c
index 3f6b998..541c90a 100644
--- a/perf/local_thr.c
+++ b/perf/local_thr.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/perf/remote_lat.c b/perf/remote_lat.c
index ed89d29..cbf4a4c 100644
--- a/perf/remote_lat.c
+++ b/perf/remote_lat.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/perf/remote_thr.c b/perf/remote_thr.c
index 41eb690..40a214b 100644
--- a/perf/remote_thr.c
+++ b/perf/remote_thr.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 894a2fd..96fa823 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -25,9 +25,18 @@
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_library (nanomsg SHARED
- pattern.h
sp.h
transport.h
+ pattern.h
+ inproc.h
+ ipc.h
+ tcp.h
+ pair.h
+ pubsub.h
+ reqrep.h
+ fanin.h
+ fanout.h
+ survey.h
core/ctx.h
core/ctx.c
diff --git a/src/core/sock.c b/src/core/sock.c
index 4e502ea..7e4e0c2 100644
--- a/src/core/sock.c
+++ b/src/core/sock.c
@@ -102,22 +102,27 @@
return -ETERM;
}
- /* TODO: Handle socket-level options here. */
-
- /* Unknown options may be pattern-specific. */
+ /* Generic socket-level options. */
if (level == SP_SOL_SOCKET) {
- rc = sockbase->vfptr->setopt (sockbase, option, optval, optvallen);
- if (rc != -ENOPROTOOPT) {
- sp_cp_unlock (&sockbase->cp);
- return rc;
- }
+ sp_cp_unlock (&sockbase->cp);
+ return -ENOPROTOOPT;
}
- /* TODO: Check transport-specific options here. */
+ /* Pattern-specific socket options. */
+ if (level > SP_SOL_SOCKET) {
+ rc = sockbase->vfptr->setopt (sockbase, level, option,
+ optval, optvallen);
+ sp_cp_unlock (&sockbase->cp);
+ return rc;
+ }
- /* Socket option not found. */
- sp_cp_unlock (&sockbase->cp);
- return -ENOPROTOOPT;
+ /* Transport-specific options. */
+ if (level < SP_SOL_SOCKET) {
+ sp_cp_unlock (&sockbase->cp);
+ return -ENOPROTOOPT;
+ }
+
+ sp_assert (0);
}
int sp_sock_getopt (struct sp_sock *self, int level, int option,
@@ -136,22 +141,27 @@
return -ETERM;
}
- /* TODO: Handle socket-level options here. */
-
- /* Unknown options may be pattern-specific. */
+ /* Generic socket-level options. */
if (level == SP_SOL_SOCKET) {
- rc = sockbase->vfptr->getopt (sockbase, option, optval, optvallen);
- if (rc != -ENOPROTOOPT) {
- sp_cp_unlock (&sockbase->cp);
- return rc;
- }
+ sp_cp_unlock (&sockbase->cp);
+ return -ENOPROTOOPT;
}
- /* TODO: Check transport-specific options here. */
+ /* Pattern-specific socket options. */
+ if (level > SP_SOL_SOCKET) {
+ rc = sockbase->vfptr->getopt (sockbase, level, option,
+ optval, optvallen);
+ sp_cp_unlock (&sockbase->cp);
+ return rc;
+ }
- /* Socket option not found. */
- sp_cp_unlock (&sockbase->cp);
- return -ENOPROTOOPT;
+ /* Transport-specific options. */
+ if (level < SP_SOL_SOCKET) {
+ sp_cp_unlock (&sockbase->cp);
+ return -ENOPROTOOPT;
+ }
+
+ sp_assert (0);
}
int sp_sock_send (struct sp_sock *self, const void *buf, size_t len, int flags)
diff --git a/src/fanin.h b/src/fanin.h
new file mode 100644
index 0000000..ef9c41a
--- /dev/null
+++ b/src/fanin.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (c) 2012 250bpm s.r.o.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+#ifndef FANIN_H_INCLUDED
+#define FANIN_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SP_FANIN_ID 4
+
+#define SP_SOURCE (SP_FANIN_ID * 16 + 0)
+#define SP_SINK (SP_FANIN_ID * 16 + 1)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/fanout.h b/src/fanout.h
new file mode 100644
index 0000000..18a8056
--- /dev/null
+++ b/src/fanout.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (c) 2012 250bpm s.r.o.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+#ifndef FANOUT_H_INCLUDED
+#define FANOUT_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SP_FANOUT_ID 5
+
+#define SP_PUSH (SP_FANOUT_ID * 16 + 0)
+#define SP_PULL (SP_FANOUT_ID * 16 + 1)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/inproc.h b/src/inproc.h
new file mode 100644
index 0000000..d9fc939
--- /dev/null
+++ b/src/inproc.h
@@ -0,0 +1,37 @@
+/*
+ Copyright (c) 2012 250bpm s.r.o.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+#ifndef INPROC_H_INCLUDED
+#define INPROC_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SP_INPROC -1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/ipc.h b/src/ipc.h
new file mode 100644
index 0000000..c5f556d
--- /dev/null
+++ b/src/ipc.h
@@ -0,0 +1,37 @@
+/*
+ Copyright (c) 2012 250bpm s.r.o.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+#ifndef IPC_H_INCLUDED
+#define IPC_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SP_IPC -2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/pair.h b/src/pair.h
new file mode 100644
index 0000000..9a014b2
--- /dev/null
+++ b/src/pair.h
@@ -0,0 +1,39 @@
+/*
+ Copyright (c) 2012 250bpm s.r.o.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+#ifndef PAIR_H_INCLUDED
+#define PAIR_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SP_PAIR_ID 1
+
+#define SP_PAIR (SP_PAIR_ID * 16 + 0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/pattern.h b/src/pattern.h
index 111beb4..1e654c4 100644
--- a/src/pattern.h
+++ b/src/pattern.h
@@ -58,9 +58,9 @@
int (*out) (struct sp_sockbase *self, struct sp_pipe *pipe);
int (*send) (struct sp_sockbase *self, const void *buf, size_t len);
int (*recv) (struct sp_sockbase *self, void *buf, size_t *len);
- int (*setopt) (struct sp_sockbase *self, int option,
+ int (*setopt) (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
- int (*getopt) (struct sp_sockbase *self, int option,
+ int (*getopt) (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
};
diff --git a/src/patterns/fanin/sink.c b/src/patterns/fanin/sink.c
index 4a5cddc..be2a154 100644
--- a/src/patterns/fanin/sink.c
+++ b/src/patterns/fanin/sink.c
@@ -24,6 +24,7 @@
#include "xsink.h"
#include "../../sp.h"
+#include "../../fanin.h"
static struct sp_socktype sp_sink_socktype_struct = {
AF_SP,
diff --git a/src/patterns/fanin/source.c b/src/patterns/fanin/source.c
index d0ca52f..138fc5e 100644
--- a/src/patterns/fanin/source.c
+++ b/src/patterns/fanin/source.c
@@ -24,6 +24,7 @@
#include "xsource.h"
#include "../../sp.h"
+#include "../../fanin.h"
static struct sp_socktype sp_source_socktype_struct = {
AF_SP,
diff --git a/src/patterns/fanin/xsink.c b/src/patterns/fanin/xsink.c
index 9ab41a7..1469e46 100644
--- a/src/patterns/fanin/xsink.c
+++ b/src/patterns/fanin/xsink.c
@@ -21,6 +21,10 @@
*/
#include "xsink.h"
+
+#include "../../sp.h"
+#include "../../fanin.h"
+
#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/fast.h"
@@ -53,9 +57,9 @@
static int sp_xsink_send (struct sp_sockbase *self, const void *buf,
size_t len);
static int sp_xsink_recv (struct sp_sockbase *self, void *buf, size_t *len);
-static int sp_xsink_setopt (struct sp_sockbase *self, int option,
+static int sp_xsink_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-static int sp_xsink_getopt (struct sp_sockbase *self, int option,
+static int sp_xsink_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
static const struct sp_sockbase_vfptr sp_xsink_sockbase_vfptr = {
sp_xsink_term,
@@ -165,13 +169,13 @@
return 0;
}
-static int sp_xsink_setopt (struct sp_sockbase *self, int option,
+static int sp_xsink_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
return -ENOPROTOOPT;
}
-static int sp_xsink_getopt (struct sp_sockbase *self, int option,
+static int sp_xsink_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/fanin/xsource.c b/src/patterns/fanin/xsource.c
index f06e417..a51dc60 100644
--- a/src/patterns/fanin/xsource.c
+++ b/src/patterns/fanin/xsource.c
@@ -23,6 +23,7 @@
#include "xsource.h"
#include "../../sp.h"
+#include "../../fanin.h"
#include "../../utils/err.h"
#include "../../utils/cont.h"
@@ -44,9 +45,9 @@
static int sp_xsource_send (struct sp_sockbase *self, const void *buf,
size_t len);
static int sp_xsource_recv (struct sp_sockbase *self, void *buf, size_t *len);
-static int sp_xsource_setopt (struct sp_sockbase *self, int option,
+static int sp_xsource_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-static int sp_xsource_getopt (struct sp_sockbase *self, int option,
+static int sp_xsource_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
static const struct sp_sockbase_vfptr sp_xsource_sockbase_vfptr = {
sp_xsource_term,
@@ -112,13 +113,13 @@
return -EAGAIN;
}
-static int sp_xsource_setopt (struct sp_sockbase *self, int option,
+static int sp_xsource_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
return -ENOPROTOOPT;
}
-static int sp_xsource_getopt (struct sp_sockbase *self, int option,
+static int sp_xsource_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/fanout/pull.c b/src/patterns/fanout/pull.c
index b424cde..01b4c13 100644
--- a/src/patterns/fanout/pull.c
+++ b/src/patterns/fanout/pull.c
@@ -24,6 +24,7 @@
#include "xpull.h"
#include "../../sp.h"
+#include "../../fanout.h"
static struct sp_socktype sp_pull_socktype_struct = {
AF_SP,
diff --git a/src/patterns/fanout/push.c b/src/patterns/fanout/push.c
index c3fcd9e..83aeb66 100644
--- a/src/patterns/fanout/push.c
+++ b/src/patterns/fanout/push.c
@@ -24,6 +24,7 @@
#include "xpush.h"
#include "../../sp.h"
+#include "../../fanout.h"
static struct sp_socktype sp_push_socktype_struct = {
AF_SP,
diff --git a/src/patterns/fanout/xpull.c b/src/patterns/fanout/xpull.c
index 70d9dba..7cfadf6 100644
--- a/src/patterns/fanout/xpull.c
+++ b/src/patterns/fanout/xpull.c
@@ -23,6 +23,7 @@
#include "xpull.h"
#include "../../sp.h"
+#include "../../fanout.h"
#include "../../utils/err.h"
#include "../../utils/cont.h"
@@ -44,9 +45,9 @@
static int sp_xpull_send (struct sp_sockbase *self, const void *buf,
size_t len);
static int sp_xpull_recv (struct sp_sockbase *self, void *buf, size_t *len);
-static int sp_xpull_setopt (struct sp_sockbase *self, int option,
+static int sp_xpull_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-static int sp_xpull_getopt (struct sp_sockbase *self, int option,
+static int sp_xpull_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
static const struct sp_sockbase_vfptr sp_xpull_sockbase_vfptr = {
sp_xpull_term,
@@ -109,13 +110,13 @@
buf, len);
}
-static int sp_xpull_setopt (struct sp_sockbase *self, int option,
+static int sp_xpull_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
return -ENOPROTOOPT;
}
-static int sp_xpull_getopt (struct sp_sockbase *self, int option,
+static int sp_xpull_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/fanout/xpush.c b/src/patterns/fanout/xpush.c
index bd2c362..0840841 100644
--- a/src/patterns/fanout/xpush.c
+++ b/src/patterns/fanout/xpush.c
@@ -21,6 +21,10 @@
*/
#include "xpush.h"
+
+#include "../../sp.h"
+#include "../../fanout.h"
+
#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/fast.h"
@@ -53,9 +57,9 @@
static int sp_xpush_send (struct sp_sockbase *self, const void *buf,
size_t len);
static int sp_xpush_recv (struct sp_sockbase *self, void *buf, size_t *len);
-static int sp_xpush_setopt (struct sp_sockbase *self, int option,
+static int sp_xpush_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-static int sp_xpush_getopt (struct sp_sockbase *self, int option,
+static int sp_xpush_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
static const struct sp_sockbase_vfptr sp_xpush_sockbase_vfptr = {
sp_xpush_term,
@@ -166,13 +170,13 @@
return -EAGAIN;
}
-static int sp_xpush_setopt (struct sp_sockbase *self, int option,
+static int sp_xpush_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
return -ENOPROTOOPT;
}
-static int sp_xpush_getopt (struct sp_sockbase *self, int option,
+static int sp_xpush_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/pair/pair.c b/src/patterns/pair/pair.c
index 1ddb251..e4bf645 100644
--- a/src/patterns/pair/pair.c
+++ b/src/patterns/pair/pair.c
@@ -24,6 +24,7 @@
#include "xpair.h"
#include "../../sp.h"
+#include "../../pair.h"
static struct sp_socktype sp_pair_socktype_struct = {
AF_SP,
diff --git a/src/patterns/pair/xpair.c b/src/patterns/pair/xpair.c
index 47f5b46..1a12ad8 100644
--- a/src/patterns/pair/xpair.c
+++ b/src/patterns/pair/xpair.c
@@ -21,6 +21,10 @@
*/
#include "xpair.h"
+
+#include "../../sp.h"
+#include "../../pair.h"
+
#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/fast.h"
@@ -41,9 +45,9 @@
static int sp_xpair_send (struct sp_sockbase *self, const void *buf,
size_t len);
static int sp_xpair_recv (struct sp_sockbase *self, void *buf, size_t *len);
-static int sp_xpair_setopt (struct sp_sockbase *self, int option,
+static int sp_xpair_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-static int sp_xpair_getopt (struct sp_sockbase *self, int option,
+static int sp_xpair_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
static const struct sp_sockbase_vfptr sp_xpair_sockbase_vfptr = {
sp_xpair_term,
@@ -105,13 +109,13 @@
buf, len);
}
-static int sp_xpair_setopt (struct sp_sockbase *self, int option,
+static int sp_xpair_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
return -ENOPROTOOPT;
}
-static int sp_xpair_getopt (struct sp_sockbase *self, int option,
+static int sp_xpair_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/pubsub/pub.c b/src/patterns/pubsub/pub.c
index d7dc94a..3768d72 100644
--- a/src/patterns/pubsub/pub.c
+++ b/src/patterns/pubsub/pub.c
@@ -21,6 +21,10 @@
*/
#include "pub.h"
+
+#include "../../sp.h"
+#include "../../pubsub.h"
+
#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/fast.h"
@@ -50,9 +54,9 @@
static int sp_pub_out (struct sp_sockbase *self, struct sp_pipe *pipe);
static int sp_pub_send (struct sp_sockbase *self, const void *buf, size_t len);
static int sp_pub_recv (struct sp_sockbase *self, void *buf, size_t *len);
-static int sp_pub_setopt (struct sp_sockbase *self, int option,
+static int sp_pub_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-static int sp_pub_getopt (struct sp_sockbase *self, int option,
+static int sp_pub_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
static const struct sp_sockbase_vfptr sp_pub_sockbase_vfptr = {
sp_pub_term,
@@ -157,13 +161,13 @@
return -EAGAIN;
}
-static int sp_pub_setopt (struct sp_sockbase *self, int option,
+static int sp_pub_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
return -ENOPROTOOPT;
}
-static int sp_pub_getopt (struct sp_sockbase *self, int option,
+static int sp_pub_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/pubsub/sub.c b/src/patterns/pubsub/sub.c
index da40147..5edd37b 100644
--- a/src/patterns/pubsub/sub.c
+++ b/src/patterns/pubsub/sub.c
@@ -24,6 +24,7 @@
#include "trie.h"
#include "../../sp.h"
+#include "../../pubsub.h"
#include "../../utils/err.h"
#include "../../utils/cont.h"
@@ -45,9 +46,9 @@
static int sp_sub_out (struct sp_sockbase *self, struct sp_pipe *pipe);
static int sp_sub_send (struct sp_sockbase *self, const void *buf, size_t len);
static int sp_sub_recv (struct sp_sockbase *self, void *buf, size_t *len);
-static int sp_sub_setopt (struct sp_sockbase *self, int option,
+static int sp_sub_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-static int sp_sub_getopt (struct sp_sockbase *self, int option,
+static int sp_sub_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
static const struct sp_sockbase_vfptr sp_sub_sockbase_vfptr = {
sp_sub_term,
@@ -128,7 +129,7 @@
}
}
-static int sp_sub_setopt (struct sp_sockbase *self, int option,
+static int sp_sub_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
int rc;
@@ -136,6 +137,9 @@
sub = sp_cont (self, struct sp_sub, sockbase);
+ if (level != SP_SUB)
+ return -ENOPROTOOPT;
+
if (option == SP_SUBSCRIBE) {
rc = sp_trie_subscribe (&sub->trie, optval, optvallen);
if (rc >= 0)
@@ -153,7 +157,7 @@
return -ENOPROTOOPT;
}
-static int sp_sub_getopt (struct sp_sockbase *self, int option,
+static int sp_sub_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/reqrep/rep.c b/src/patterns/reqrep/rep.c
index 2a5b6ef..feeb4d2 100644
--- a/src/patterns/reqrep/rep.c
+++ b/src/patterns/reqrep/rep.c
@@ -23,6 +23,9 @@
#include "rep.h"
#include "xrep.h"
+#include "../../sp.h"
+#include "../../reqrep.h"
+
#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/alloc.h"
diff --git a/src/patterns/reqrep/req.c b/src/patterns/reqrep/req.c
index 555d059..e20e78c 100644
--- a/src/patterns/reqrep/req.c
+++ b/src/patterns/reqrep/req.c
@@ -23,6 +23,9 @@
#include "req.h"
#include "xreq.h"
+#include "../../sp.h"
+#include "../../reqrep.h"
+
#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/alloc.h"
@@ -52,9 +55,9 @@
static void sp_req_term (struct sp_sockbase *self);
static int sp_req_send (struct sp_sockbase *self, const void *buf, size_t len);
static int sp_req_recv (struct sp_sockbase *self, void *buf, size_t *len);
-static int sp_req_setopt (struct sp_sockbase *self, int option,
+static int sp_req_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-static int sp_req_getopt (struct sp_sockbase *self, int option,
+static int sp_req_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
static const struct sp_sockbase_vfptr sp_req_sockbase_vfptr = {
sp_req_term,
@@ -223,13 +226,16 @@
return 0;
}
-static int sp_req_setopt (struct sp_sockbase *self, int option,
+static int sp_req_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
struct sp_req *req;
req = sp_cont (self, struct sp_req, xreq.sockbase);
+ if (level != SP_REQ)
+ return -ENOPROTOOPT;
+
if (option == SP_RESEND_IVL) {
if (sp_slow (optvallen != sizeof (int)))
return -EINVAL;
@@ -240,13 +246,16 @@
return -ENOPROTOOPT;
}
-static int sp_req_getopt (struct sp_sockbase *self, int option,
+static int sp_req_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
struct sp_req *req;
req = sp_cont (self, struct sp_req, xreq.sockbase);
+ if (level != SP_REQ)
+ return -ENOPROTOOPT;
+
if (option == SP_RESEND_IVL) {
if (sp_slow (*optvallen < sizeof (int)))
return -EINVAL;
diff --git a/src/patterns/reqrep/xrep.c b/src/patterns/reqrep/xrep.c
index b62f026..bc21248 100644
--- a/src/patterns/reqrep/xrep.c
+++ b/src/patterns/reqrep/xrep.c
@@ -21,6 +21,10 @@
*/
#include "xrep.h"
+
+#include "../../sp.h"
+#include "../../reqrep.h"
+
#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/fast.h"
@@ -198,13 +202,13 @@
return 0;
}
-int sp_xrep_setopt (struct sp_sockbase *self, int option,
+int sp_xrep_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
return -ENOPROTOOPT;
}
-int sp_xrep_getopt (struct sp_sockbase *self, int option,
+int sp_xrep_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/reqrep/xrep.h b/src/patterns/reqrep/xrep.h
index ce6583c..8a12146 100644
--- a/src/patterns/reqrep/xrep.h
+++ b/src/patterns/reqrep/xrep.h
@@ -68,9 +68,9 @@
int sp_xrep_out (struct sp_sockbase *self, struct sp_pipe *pipe);
int sp_xrep_send (struct sp_sockbase *self, const void *buf, size_t len);
int sp_xrep_recv (struct sp_sockbase *self, void *buf, size_t *len);
-int sp_xrep_setopt (struct sp_sockbase *self, int option,
+int sp_xrep_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-int sp_xrep_getopt (struct sp_sockbase *self, int option,
+int sp_xrep_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
extern struct sp_socktype *sp_xrep_socktype;
diff --git a/src/patterns/reqrep/xreq.c b/src/patterns/reqrep/xreq.c
index 9ece0d2..72e5a35 100644
--- a/src/patterns/reqrep/xreq.c
+++ b/src/patterns/reqrep/xreq.c
@@ -22,6 +22,9 @@
#include "xreq.h"
+#include "../../sp.h"
+#include "../../reqrep.h"
+
#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/fast.h"
@@ -87,13 +90,13 @@
buf, len);
}
-int sp_xreq_setopt (struct sp_sockbase *self, int option,
+int sp_xreq_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
return -ENOPROTOOPT;
}
-int sp_xreq_getopt (struct sp_sockbase *self, int option,
+int sp_xreq_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/reqrep/xreq.h b/src/patterns/reqrep/xreq.h
index b4d8fea..bdd1189 100644
--- a/src/patterns/reqrep/xreq.h
+++ b/src/patterns/reqrep/xreq.h
@@ -42,9 +42,9 @@
int sp_xreq_out (struct sp_sockbase *self, struct sp_pipe *pipe);
int sp_xreq_send (struct sp_sockbase *self, const void *buf, size_t len);
int sp_xreq_recv (struct sp_sockbase *self, void *buf, size_t *len);
-int sp_xreq_setopt (struct sp_sockbase *self, int option,
+int sp_xreq_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-int sp_xreq_getopt (struct sp_sockbase *self, int option,
+int sp_xreq_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
extern struct sp_socktype *sp_xreq_socktype;
diff --git a/src/patterns/survey/respondent.c b/src/patterns/survey/respondent.c
index 3d242b7..94a262b 100644
--- a/src/patterns/survey/respondent.c
+++ b/src/patterns/survey/respondent.c
@@ -24,6 +24,7 @@
#include "xrespondent.h"
#include "../../sp.h"
+#include "../../survey.h"
#include "../../utils/err.h"
#include "../../utils/cont.h"
diff --git a/src/patterns/survey/surveyor.c b/src/patterns/survey/surveyor.c
index 5ffc9e3..53d042f 100644
--- a/src/patterns/survey/surveyor.c
+++ b/src/patterns/survey/surveyor.c
@@ -23,6 +23,9 @@
#include "surveyor.h"
#include "xsurveyor.h"
+#include "../../sp.h"
+#include "../../survey.h"
+
#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/fast.h"
@@ -51,9 +54,9 @@
static int sp_surveyor_send (struct sp_sockbase *self, const void *buf,
size_t len);
static int sp_surveyor_recv (struct sp_sockbase *self, void *buf, size_t *len);
-static int sp_surveyor_setopt (struct sp_sockbase *self, int option,
+static int sp_surveyor_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-static int sp_surveyor_getopt (struct sp_sockbase *self, int option,
+static int sp_surveyor_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
static const struct sp_sockbase_vfptr sp_surveyor_sockbase_vfptr = {
sp_surveyor_term,
@@ -207,13 +210,16 @@
sp_sockbase_unblock_recv (&surveyor->xsurveyor.sockbase);
}
-static int sp_surveyor_setopt (struct sp_sockbase *self, int option,
+static int sp_surveyor_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
struct sp_surveyor *surveyor;
surveyor = sp_cont (self, struct sp_surveyor, xsurveyor.sockbase);
+ if (level != SP_SURVEYOR)
+ return -ENOPROTOOPT;
+
if (option == SP_DEADLINE) {
if (sp_slow (optvallen != sizeof (int)))
return -EINVAL;
@@ -224,13 +230,16 @@
return -ENOPROTOOPT;
}
-static int sp_surveyor_getopt (struct sp_sockbase *self, int option,
+static int sp_surveyor_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
struct sp_surveyor *surveyor;
surveyor = sp_cont (self, struct sp_surveyor, xsurveyor.sockbase);
+ if (level != SP_SURVEYOR)
+ return -ENOPROTOOPT;
+
if (option == SP_DEADLINE) {
if (sp_slow (*optvallen < sizeof (int)))
return -EINVAL;
diff --git a/src/patterns/survey/xrespondent.c b/src/patterns/survey/xrespondent.c
index e4f24b0..c011d16 100644
--- a/src/patterns/survey/xrespondent.c
+++ b/src/patterns/survey/xrespondent.c
@@ -23,6 +23,7 @@
#include "xrespondent.h"
#include "../../sp.h"
+#include "../../survey.h"
#include "../../utils/err.h"
#include "../../utils/cont.h"
@@ -98,13 +99,13 @@
return sp_excl_recv (&xrespondent->excl, buf, len);
}
-int sp_xrespondent_setopt (struct sp_sockbase *self, int option,
+int sp_xrespondent_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
return -ENOPROTOOPT;
}
-int sp_xrespondent_getopt (struct sp_sockbase *self, int option,
+int sp_xrespondent_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/survey/xrespondent.h b/src/patterns/survey/xrespondent.h
index 326cc88..4c1efae 100644
--- a/src/patterns/survey/xrespondent.h
+++ b/src/patterns/survey/xrespondent.h
@@ -44,9 +44,9 @@
int sp_xrespondent_out (struct sp_sockbase *self, struct sp_pipe *pipe);
int sp_xrespondent_send (struct sp_sockbase *self, const void *buf, size_t len);
int sp_xrespondent_recv (struct sp_sockbase *self, void *buf, size_t *len);
-int sp_xrespondent_setopt (struct sp_sockbase *self, int option,
+int sp_xrespondent_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-int sp_xrespondent_getopt (struct sp_sockbase *self, int option,
+int sp_xrespondent_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
#endif
diff --git a/src/patterns/survey/xsurveyor.c b/src/patterns/survey/xsurveyor.c
index 973d4d7..6d5dd26 100644
--- a/src/patterns/survey/xsurveyor.c
+++ b/src/patterns/survey/xsurveyor.c
@@ -21,6 +21,10 @@
*/
#include "xsurveyor.h"
+
+#include "../../sp.h"
+#include "../../survey.h"
+
#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/fast.h"
@@ -170,13 +174,13 @@
return 0;
}
-int sp_xsurveyor_setopt (struct sp_sockbase *self, int option,
+int sp_xsurveyor_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen)
{
return -ENOPROTOOPT;
}
-int sp_xsurveyor_getopt (struct sp_sockbase *self, int option,
+int sp_xsurveyor_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen)
{
return -ENOPROTOOPT;
diff --git a/src/patterns/survey/xsurveyor.h b/src/patterns/survey/xsurveyor.h
index a31c1f9..da4f386 100644
--- a/src/patterns/survey/xsurveyor.h
+++ b/src/patterns/survey/xsurveyor.h
@@ -59,9 +59,9 @@
int sp_xsurveyor_out (struct sp_sockbase *self, struct sp_pipe *pipe);
int sp_xsurveyor_send (struct sp_sockbase *self, const void *buf, size_t len);
int sp_xsurveyor_recv (struct sp_sockbase *self, void *buf, size_t *len);
-int sp_xsurveyor_setopt (struct sp_sockbase *self, int option,
+int sp_xsurveyor_setopt (struct sp_sockbase *self, int level, int option,
const void *optval, size_t optvallen);
-int sp_xsurveyor_getopt (struct sp_sockbase *self, int option,
+int sp_xsurveyor_getopt (struct sp_sockbase *self, int level, int option,
void *optval, size_t *optvallen);
#endif
diff --git a/src/pubsub.h b/src/pubsub.h
new file mode 100644
index 0000000..358377f
--- /dev/null
+++ b/src/pubsub.h
@@ -0,0 +1,43 @@
+/*
+ Copyright (c) 2012 250bpm s.r.o.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+#ifndef PUBSUB_H_INCLUDED
+#define PUBSUB_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SP_PUBSUB_ID 2
+
+#define SP_PUB (SP_PUBSUB_ID * 16 + 0)
+#define SP_SUB (SP_PUBSUB_ID * 16 + 1)
+
+#define SP_SUBSCRIBE 1
+#define SP_UNSUBSCRIBE 2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/reqrep.h b/src/reqrep.h
new file mode 100644
index 0000000..28af8d1
--- /dev/null
+++ b/src/reqrep.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (c) 2012 250bpm s.r.o.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+#ifndef REQREP_H_INCLUDED
+#define REQREP_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SP_REQREP_ID 3
+
+#define SP_REQ (SP_REQREP_ID * 16 + 0)
+#define SP_REP (SP_REQREP_ID * 16 + 1)
+
+#define SP_RESEND_IVL 1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/sp.h b/src/sp.h
index c0e7005..6ee3d14 100644
--- a/src/sp.h
+++ b/src/sp.h
@@ -145,27 +145,12 @@
/* Max size of an SP address. */
#define SP_SOCKADDR_MAX 128
-/* Socket protocols. */
-#define SP_PAIR 1
-#define SP_PUB 2
-#define SP_SUB 3
-#define SP_REP 4
-#define SP_REQ 5
-#define SP_SINK 6
-#define SP_SOURCE 7
-#define SP_PUSH 8
-#define SP_PULL 9
-#define SP_SURVEYOR 10
-#define SP_RESPONDENT 11
+/* Socket option levels: Negative numbers are reserved for transports,
+ positive for socket types. */
+#define SP_SOL_SOCKET 0
-/* Socket option levels. */
-#define SP_SOL_SOCKET 1
-
-/* Socket options. */
-#define SP_SUBSCRIBE 1
-#define SP_UNSUBSCRIBE 2
-#define SP_RESEND_IVL 3
-#define SP_DEADLINE 4
+/* Generic socket options (SP_SOL_SOCKET level). */
+/* TODO */
/* Send/recv options. */
#define SP_DONTWAIT 1
diff --git a/src/survey.h b/src/survey.h
new file mode 100644
index 0000000..7d33d90
--- /dev/null
+++ b/src/survey.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (c) 2012 250bpm s.r.o.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+#ifndef SURVEY_H_INCLUDED
+#define SURVEY_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SP_SURVEY_ID 6
+
+#define SP_SURVEYOR (SP_SURVEY_ID * 16 + 0)
+#define SP_RESPONDENT (SP_SURVEY_ID * 16 + 1)
+
+#define SP_DEADLINE 1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/tcp.h b/src/tcp.h
new file mode 100644
index 0000000..86a825d
--- /dev/null
+++ b/src/tcp.h
@@ -0,0 +1,37 @@
+/*
+ Copyright (c) 2012 250bpm s.r.o.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+#ifndef TCP_H_INCLUDED
+#define TCP_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SP_TCP -3
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/tests/block.c b/tests/block.c
index 433711e..84f5063 100644
--- a/tests/block.c
+++ b/tests/block.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
#include "../src/utils/err.c"
#include "../src/utils/thread.c"
diff --git a/tests/fanin.c b/tests/fanin.c
index b656338..a3eff8a 100644
--- a/tests/fanin.c
+++ b/tests/fanin.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/fanin.h"
#include "../src/utils/err.c"
int main ()
diff --git a/tests/fanout.c b/tests/fanout.c
index 8a00b46..50196c4 100644
--- a/tests/fanout.c
+++ b/tests/fanout.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/fanout.h"
#include "../src/utils/err.c"
#include "../src/utils/sleep.c"
diff --git a/tests/inproc.c b/tests/inproc.c
index 8fd968d..99dab0b 100644
--- a/tests/inproc.c
+++ b/tests/inproc.c
@@ -21,6 +21,8 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
+#include "../src/inproc.h"
#include "../src/utils/err.c"
diff --git a/tests/ipc.c b/tests/ipc.c
index 4fb5f78..d3a5f3c 100644
--- a/tests/ipc.c
+++ b/tests/ipc.c
@@ -21,6 +21,8 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
+#include "../src/ipc.h"
#include "../src/utils/err.c"
#include "../src/utils/sleep.c"
diff --git a/tests/pair.c b/tests/pair.c
index 0eae1ab..72475a2 100644
--- a/tests/pair.c
+++ b/tests/pair.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
#include "../src/utils/err.c"
diff --git a/tests/pubsub.c b/tests/pubsub.c
index 80896ba..a27abb5 100644
--- a/tests/pubsub.c
+++ b/tests/pubsub.c
@@ -21,6 +21,8 @@
*/
#include "../src/sp.h"
+#include "../src/pubsub.h"
+
#include "../src/utils/err.c"
#include "../src/utils/sleep.c"
@@ -40,13 +42,13 @@
errno_assert (rc >= 0);
sub1 = sp_socket (AF_SP, SP_SUB);
errno_assert (sub1 != -1);
- rc = sp_setsockopt (sub1, SP_SOL_SOCKET, SP_SUBSCRIBE, "", 0);
+ rc = sp_setsockopt (sub1, SP_SUB, SP_SUBSCRIBE, "", 0);
errno_assert (rc == 0);
rc = sp_connect (sub1, "inproc://a");
errno_assert (rc >= 0);
sub2 = sp_socket (AF_SP, SP_SUB);
errno_assert (sub2 != -1);
- rc = sp_setsockopt (sub2, SP_SOL_SOCKET, SP_SUBSCRIBE, "", 0);
+ rc = sp_setsockopt (sub2, SP_SUB, SP_SUBSCRIBE, "", 0);
errno_assert (rc == 0);
rc = sp_connect (sub2, "inproc://a");
errno_assert (rc >= 0);
diff --git a/tests/reqrep.c b/tests/reqrep.c
index b397319..ec735da 100644
--- a/tests/reqrep.c
+++ b/tests/reqrep.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/reqrep.h"
#include "../src/utils/err.c"
@@ -155,7 +156,7 @@
rc = sp_connect (req1, "inproc://a");
errno_assert (rc >= 0);
resend_ivl = 100;
- rc = sp_setsockopt (req1, SP_SOL_SOCKET, SP_RESEND_IVL,
+ rc = sp_setsockopt (req1, SP_REQ, SP_RESEND_IVL,
&resend_ivl, sizeof (resend_ivl));
errno_assert (rc == 0);
diff --git a/tests/shutdown.c b/tests/shutdown.c
index 17c4157..4a97a40 100644
--- a/tests/shutdown.c
+++ b/tests/shutdown.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
#include "../src/utils/err.c"
#include "../src/utils/thread.c"
diff --git a/tests/survey.c b/tests/survey.c
index d9211a4..a3debfd 100644
--- a/tests/survey.c
+++ b/tests/survey.c
@@ -21,6 +21,7 @@
*/
#include "../src/sp.h"
+#include "../src/survey.h"
#include "../src/utils/err.c"
@@ -40,7 +41,7 @@
surveyor = sp_socket (AF_SP, SP_SURVEYOR);
errno_assert (surveyor != -1);
deadline = 100;
- rc = sp_setsockopt (surveyor, SP_SOL_SOCKET, SP_DEADLINE,
+ rc = sp_setsockopt (surveyor, SP_SURVEYOR, SP_DEADLINE,
&deadline, sizeof (deadline));
errno_assert (rc == 0);
rc = sp_bind (surveyor, "inproc://a");
diff --git a/tests/tcp.c b/tests/tcp.c
index efff60e..e222e62 100644
--- a/tests/tcp.c
+++ b/tests/tcp.c
@@ -21,6 +21,8 @@
*/
#include "../src/sp.h"
+#include "../src/pair.h"
+#include "../src/tcp.h"
#include "../src/utils/err.c"
#include "../src/utils/sleep.c"