aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/defs.h4
-rw-r--r--src/core/endpt.c11
-rw-r--r--src/core/platform.h8
3 files changed, 16 insertions, 7 deletions
diff --git a/src/core/defs.h b/src/core/defs.h
index b08ce838..c449aa32 100644
--- a/src/core/defs.h
+++ b/src/core/defs.h
@@ -111,8 +111,8 @@ typedef struct {
} while (0)
#define NNI_GET16(ptr, v) \
- v = (((uint32_t)((uint8_t)(ptr)[0])) << 8) + \
- (((uint32_t)(uint8_t)(ptr)[1]))
+ v = (((uint16_t)((uint8_t)(ptr)[0])) << 8) + \
+ (((uint16_t)(uint8_t)(ptr)[1]))
#define NNI_GET32(ptr, v) \
v = (((uint32_t)((uint8_t)(ptr)[0])) << 24) + \
diff --git a/src/core/endpt.c b/src/core/endpt.c
index 4d3727bc..4d3d9031 100644
--- a/src/core/endpt.c
+++ b/src/core/endpt.c
@@ -618,10 +618,6 @@ nni_ep_getopt(nni_ep *ep, const char *name, void *valp, size_t *szp)
{
nni_tran_ep_option *eo;
- if (strcmp(name, NNG_OPT_URL) == 0) {
- return (nni_getopt_str(ep->ep_url->u_rawurl, valp, szp));
- }
-
for (eo = ep->ep_ops.ep_options; eo && eo->eo_name; eo++) {
int rv;
if (strcmp(eo->eo_name, name) != 0) {
@@ -636,6 +632,13 @@ nni_ep_getopt(nni_ep *ep, const char *name, void *valp, size_t *szp)
return (rv);
}
+ // We provide a fallback on the URL, but let the implementation
+ // override. This allows the URL to be created with wildcards,
+ // that are resolved later.
+ if (strcmp(name, NNG_OPT_URL) == 0) {
+ return (nni_getopt_str(ep->ep_url->u_rawurl, valp, szp));
+ }
+
return (nni_sock_getopt(ep->ep_sock, name, valp, szp));
}
diff --git a/src/core/platform.h b/src/core/platform.h
index cf635f4a..3f336f11 100644
--- a/src/core/platform.h
+++ b/src/core/platform.h
@@ -207,7 +207,7 @@ extern void nni_plat_tcp_ep_close(nni_plat_tcp_ep *);
// nni_plat_tcp_listen creates an TCP socket in listening mode, bound
// to the specified path.
-extern int nni_plat_tcp_ep_listen(nni_plat_tcp_ep *);
+extern int nni_plat_tcp_ep_listen(nni_plat_tcp_ep *, nni_sockaddr *);
// nni_plat_tcp_ep_accept starts an accept to receive an incoming connection.
// An accepted connection will be passed back in the a_pipe member.
@@ -248,6 +248,12 @@ extern int nni_plat_tcp_pipe_peername(nni_plat_tcp_pipe *, nni_sockaddr *);
// nni_plat_tcp_pipe_sockname gets the local name.
extern int nni_plat_tcp_pipe_sockname(nni_plat_tcp_pipe *, nni_sockaddr *);
+// nni_plat_tcp_ntop obtains the IP address for the socket (enclosing it
+// in brackets if it is IPv6) and port. Enough space for both must
+// be present (48 bytes and 6 bytes each), although if either is NULL then
+// those components are skipped.
+extern int nni_plat_tcp_ntop(const nni_sockaddr *, char *, char *);
+
// nni_plat_tcp_resolv resolves a TCP name asynchronously. The family
// should be one of NNG_AF_INET, NNG_AF_INET6, or NNG_AF_UNSPEC. The
// first two constrain the name to those families, while the third will