aboutsummaryrefslogtreecommitdiff
path: root/src/sp/protocol/pair1/pair.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2025-01-01 12:44:02 -0800
committerGarrett D'Amore <garrett@damore.org>2025-01-01 12:44:02 -0800
commit0d23af92531b7c0dd6d7b74c73c1a8c4811c7d13 (patch)
tree2dc9ded3dfc724df42a360a9f2de359f406e537f /src/sp/protocol/pair1/pair.c
parentf8a2abaf931557030fd6e6683617c6a7877eebf7 (diff)
downloadnng-0d23af92531b7c0dd6d7b74c73c1a8c4811c7d13.tar.gz
nng-0d23af92531b7c0dd6d7b74c73c1a8c4811c7d13.tar.bz2
nng-0d23af92531b7c0dd6d7b74c73c1a8c4811c7d13.zip
protocols: move content from the protocols to nng.h
This should simplify things for developers. Just one header to include in most cases now.
Diffstat (limited to 'src/sp/protocol/pair1/pair.c')
-rw-r--r--src/sp/protocol/pair1/pair.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/sp/protocol/pair1/pair.c b/src/sp/protocol/pair1/pair.c
index b7e40f9d..65ee66ad 100644
--- a/src/sp/protocol/pair1/pair.c
+++ b/src/sp/protocol/pair1/pair.c
@@ -1,5 +1,5 @@
//
-// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -11,7 +11,6 @@
#include <stdlib.h>
#include "core/nng_impl.h"
-#include "nng/protocol/pair1/pair.h"
// Pair protocol. The PAIRv1 protocol is a simple 1:1 messaging pattern.
@@ -21,6 +20,11 @@
#define BUMP_STAT(x)
#endif
+#define PAIR1_SELF_NAME "pair1"
+#define PAIR1_PEER_NAME "pair1"
+#define PAIR1_SELF 0x11
+#define PAIR1_PEER 0x11
+
typedef struct pair1_pipe pair1_pipe;
typedef struct pair1_sock pair1_sock;
@@ -262,12 +266,12 @@ pair1_pipe_start(void *arg)
pair1_pipe *p = arg;
pair1_sock *s = p->pair;
- if (nni_pipe_peer(p->pipe) != NNG_PAIR1_PEER) {
+ if (nni_pipe_peer(p->pipe) != PAIR1_PEER) {
BUMP_STAT(&s->stat_reject_mismatch);
// Peer protocol mismatch.
nng_log_warn("NNG-PEER-MISMATCH",
"Peer protocol mismatch: %d != %d, rejected.",
- nni_pipe_peer(p->pipe), NNG_PAIR1_PEER);
+ nni_pipe_peer(p->pipe), PAIR1_PEER);
return (NNG_EPROTO);
}
@@ -782,8 +786,8 @@ static nni_proto_sock_ops pair1_sock_ops = {
static nni_proto pair1_proto = {
.proto_version = NNI_PROTOCOL_VERSION,
- .proto_self = { NNG_PAIR1_SELF, NNG_PAIR1_SELF_NAME },
- .proto_peer = { NNG_PAIR1_PEER, NNG_PAIR1_PEER_NAME },
+ .proto_self = { PAIR1_SELF, PAIR1_SELF_NAME },
+ .proto_peer = { PAIR1_PEER, PAIR1_PEER_NAME },
.proto_flags = NNI_PROTO_FLAG_SNDRCV,
.proto_sock_ops = &pair1_sock_ops,
.proto_pipe_ops = &pair1_pipe_ops,
@@ -810,8 +814,8 @@ static nni_proto_sock_ops pair1_sock_ops_raw = {
static nni_proto pair1_proto_raw = {
.proto_version = NNI_PROTOCOL_VERSION,
- .proto_self = { NNG_PAIR1_SELF, NNG_PAIR1_SELF_NAME },
- .proto_peer = { NNG_PAIR1_PEER, NNG_PAIR1_PEER_NAME },
+ .proto_self = { PAIR1_SELF, PAIR1_SELF_NAME },
+ .proto_peer = { PAIR1_PEER, PAIR1_PEER_NAME },
.proto_flags = NNI_PROTO_FLAG_SNDRCV | NNI_PROTO_FLAG_RAW,
.proto_sock_ops = &pair1_sock_ops_raw,
.proto_pipe_ops = &pair1_pipe_ops,