aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/protocol.h8
-rw-r--r--src/protocol/bus/bus.c1
-rw-r--r--src/protocol/pair/pair.c1
-rw-r--r--src/protocol/pipeline/pull.c1
-rw-r--r--src/protocol/pipeline/push.c1
-rw-r--r--src/protocol/pubsub/pub.c1
-rw-r--r--src/protocol/pubsub/sub.c1
-rw-r--r--src/protocol/reqrep/rep.c1
-rw-r--r--src/protocol/reqrep/req.c1
-rw-r--r--src/protocol/survey/respond.c1
-rw-r--r--src/protocol/survey/survey.c1
11 files changed, 18 insertions, 0 deletions
diff --git a/src/core/protocol.h b/src/core/protocol.h
index 11c4c304..82ebd88f 100644
--- a/src/core/protocol.h
+++ b/src/core/protocol.h
@@ -92,10 +92,18 @@ struct nni_proto {
uint16_t proto_self; // our 16-bit D
uint16_t proto_peer; // who we peer with (ID)
const char * proto_name; // Our name
+ uint16_t proto_flags; // Protocol flags
const nni_proto_sock_ops * proto_sock_ops; // Per-socket opeations
const nni_proto_pipe_ops * proto_pipe_ops; // Per-pipe operations.
};
+// These flags determine which operations make sense. We use them so that
+// we can reject attempts to create notification fds for operations that make
+// no sense.
+#define NNI_PROTO_FLAG_RECV 1 // Protocol can receive
+#define NNI_PROTO_FLAG_SEND 2 // Protocol can send
+#define NNI_PROTO_FLAG_SENDRECV 3 // Protocol can both send & recv
+
// These functions are not used by protocols, but rather by the socket
// core implementation. The lookups can be used by transports as well.
extern nni_proto *nni_proto_find(uint16_t);
diff --git a/src/protocol/bus/bus.c b/src/protocol/bus/bus.c
index 02467ffe..c1334fa5 100644
--- a/src/protocol/bus/bus.c
+++ b/src/protocol/bus/bus.c
@@ -273,6 +273,7 @@ nni_proto nni_bus_proto = {
.proto_self = NNG_PROTO_BUS,
.proto_peer = NNG_PROTO_BUS,
.proto_name = "bus",
+ .proto_flags = NNI_PROTO_FLAG_SENDRECV,
.proto_sock_ops = &nni_bus_sock_ops,
.proto_pipe_ops = &nni_bus_pipe_ops,
};
diff --git a/src/protocol/pair/pair.c b/src/protocol/pair/pair.c
index d6c2eedf..fe0874ca 100644
--- a/src/protocol/pair/pair.c
+++ b/src/protocol/pair/pair.c
@@ -233,6 +233,7 @@ nni_proto nni_pair_proto = {
.proto_self = NNG_PROTO_PAIR,
.proto_peer = NNG_PROTO_PAIR,
.proto_name = "pair",
+ .proto_flags = NNI_PROTO_FLAG_SENDRECV,
.proto_sock_ops = &nni_pair_sock_ops,
.proto_pipe_ops = &nni_pair_pipe_ops,
};
diff --git a/src/protocol/pipeline/pull.c b/src/protocol/pipeline/pull.c
index ca15efef..5b3efd4d 100644
--- a/src/protocol/pipeline/pull.c
+++ b/src/protocol/pipeline/pull.c
@@ -155,6 +155,7 @@ nni_proto nni_pull_proto = {
.proto_self = NNG_PROTO_PULL,
.proto_peer = NNG_PROTO_PUSH,
.proto_name = "pull",
+ .proto_flags = NNI_PROTO_FLAG_RECV,
.proto_pipe_ops = &nni_pull_pipe_ops,
.proto_sock_ops = &nni_pull_sock_ops,
};
diff --git a/src/protocol/pipeline/push.c b/src/protocol/pipeline/push.c
index 1d1e6d88..8794d84f 100644
--- a/src/protocol/pipeline/push.c
+++ b/src/protocol/pipeline/push.c
@@ -313,6 +313,7 @@ nni_proto nni_push_proto = {
.proto_self = NNG_PROTO_PUSH,
.proto_peer = NNG_PROTO_PULL,
.proto_name = "push",
+ .proto_flags = NNI_PROTO_FLAG_SEND,
.proto_pipe_ops = &nni_push_pipe_ops,
.proto_sock_ops = &nni_push_sock_ops,
};
diff --git a/src/protocol/pubsub/pub.c b/src/protocol/pubsub/pub.c
index 5617d92c..24dddf4e 100644
--- a/src/protocol/pubsub/pub.c
+++ b/src/protocol/pubsub/pub.c
@@ -274,6 +274,7 @@ nni_proto nni_pub_proto = {
.proto_self = NNG_PROTO_PUB,
.proto_peer = NNG_PROTO_SUB,
.proto_name = "pub",
+ .proto_flags = NNI_PROTO_FLAG_SEND,
.proto_sock_ops = &nni_pub_sock_ops,
.proto_pipe_ops = &nni_pub_pipe_ops,
};
diff --git a/src/protocol/pubsub/sub.c b/src/protocol/pubsub/sub.c
index cd8dd87c..512765eb 100644
--- a/src/protocol/pubsub/sub.c
+++ b/src/protocol/pubsub/sub.c
@@ -314,6 +314,7 @@ nni_proto nni_sub_proto = {
.proto_self = NNG_PROTO_SUB,
.proto_peer = NNG_PROTO_PUB,
.proto_name = "sub",
+ .proto_flags = NNI_PROTO_FLAG_RECV,
.proto_sock_ops = &nni_sub_sock_ops,
.proto_pipe_ops = &nni_sub_pipe_ops,
};
diff --git a/src/protocol/reqrep/rep.c b/src/protocol/reqrep/rep.c
index a34f6eea..36535fa4 100644
--- a/src/protocol/reqrep/rep.c
+++ b/src/protocol/reqrep/rep.c
@@ -414,6 +414,7 @@ nni_proto nni_rep_proto = {
.proto_self = NNG_PROTO_REP,
.proto_peer = NNG_PROTO_REQ,
.proto_name = "rep",
+ .proto_flags = NNI_PROTO_FLAG_SENDRECV,
.proto_sock_ops = &nni_rep_sock_ops,
.proto_pipe_ops = &nni_rep_pipe_ops,
};
diff --git a/src/protocol/reqrep/req.c b/src/protocol/reqrep/req.c
index 787997e8..5d87e30d 100644
--- a/src/protocol/reqrep/req.c
+++ b/src/protocol/reqrep/req.c
@@ -406,6 +406,7 @@ nni_proto nni_req_proto = {
.proto_self = NNG_PROTO_REQ,
.proto_peer = NNG_PROTO_REP,
.proto_name = "req",
+ .proto_flags = NNI_PROTO_FLAG_SENDRECV,
.proto_sock_ops = &nni_req_sock_ops,
.proto_pipe_ops = &nni_req_pipe_ops,
};
diff --git a/src/protocol/survey/respond.c b/src/protocol/survey/respond.c
index 263e023a..a915eace 100644
--- a/src/protocol/survey/respond.c
+++ b/src/protocol/survey/respond.c
@@ -416,6 +416,7 @@ nni_proto nni_respondent_proto = {
.proto_self = NNG_PROTO_RESPONDENT,
.proto_peer = NNG_PROTO_SURVEYOR,
.proto_name = "respondent",
+ .proto_flags = NNI_PROTO_FLAG_SENDRECV,
.proto_sock_ops = &nni_resp_sock_ops,
.proto_pipe_ops = &nni_resp_pipe_ops,
};
diff --git a/src/protocol/survey/survey.c b/src/protocol/survey/survey.c
index 087211a2..b887a6e9 100644
--- a/src/protocol/survey/survey.c
+++ b/src/protocol/survey/survey.c
@@ -427,6 +427,7 @@ nni_proto nni_surveyor_proto = {
.proto_self = NNG_PROTO_SURVEYOR,
.proto_peer = NNG_PROTO_RESPONDENT,
.proto_name = "surveyor",
+ .proto_flags = NNI_PROTO_FLAG_SENDRECV,
.proto_sock_ops = &nni_surv_sock_ops,
.proto_pipe_ops = &nni_surv_pipe_ops,
};