]> www.average.org Git - psmb.git/commitdiff
fix types and options
authorEugene Crosser <evgenii.cherkashin@cloud.ionos.com>
Wed, 13 Mar 2019 15:02:17 +0000 (16:02 +0100)
committerEugene Crosser <evgenii.cherkashin@cloud.ionos.com>
Wed, 13 Mar 2019 15:02:17 +0000 (16:02 +0100)
Signed-off-by: Eugene Crosser <evgenii.cherkashin@profitbricks.com>
include/psmb.h
src/psmb_priv.h
src/psmb_socket.c

index 8925aea3bdce79cea17bce930eca1ee99a7a5a38..022d5b8cdfa1aaaf451e8be8a16a851f63fe7b98 100644 (file)
@@ -5,7 +5,7 @@
 #include <netinet/in.h>
 
 typedef struct _psmb_ctx psmb_ctx_t;
 #include <netinet/in.h>
 
 typedef struct _psmb_ctx psmb_ctx_t;
-typedef struct _psmb_result psmb_result_t;
+typedef struct _psmb_result { int code; } psmb_result_t;
 
 psmb_ctx_t *psmb_new(void);
 psmb_ctx_t *psmb_new_mm(void *(*malloc)(size_t size),
 
 psmb_ctx_t *psmb_new(void);
 psmb_ctx_t *psmb_new_mm(void *(*malloc)(size_t size),
index 517f0cf67ece3853dcee9bd24b0a9d3478cfb29f..5e3c2adb596dc5c8fc223ecedf6630fa2e47c4f8 100644 (file)
@@ -38,10 +38,6 @@ struct _psmb_ctx {
        struct _msg incoming;
 };
 
        struct _msg incoming;
 };
 
-struct _psmb_result {
-       int code;
-};
-
 #define LOG(ctx, ...) (*ctx->logf)(ctx->log_priv, __VA_ARGS__)
 
 #endif
 #define LOG(ctx, ...) (*ctx->logf)(ctx->log_priv, __VA_ARGS__)
 
 #endif
index 28344a7a65c04138712f1dc5922a37e167a3b2e7..538b87c9c766e6159240d05d5ce36757f3c9ac07 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
+#include <sys/types.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
@@ -102,7 +103,7 @@ psmb_result_t psmb_open(psmb_ctx_t *ctx)
                errno = EBUSY;
                return (psmb_result_t){PSMB_ERROR};
        }
                errno = EBUSY;
                return (psmb_result_t){PSMB_ERROR};
        }
-       ctx->fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IPV6);
+       ctx->fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
        if (ctx->fd == -1) {
                int sverr = errno;
                LOG(ctx, LOG_ERR, "socket: %m");
        if (ctx->fd == -1) {
                int sverr = errno;
                LOG(ctx, LOG_ERR, "socket: %m");
@@ -118,7 +119,7 @@ psmb_result_t psmb_open(psmb_ctx_t *ctx)
                errno = sverr;
                return (psmb_result_t){PSMB_ERROR};
        }
                errno = sverr;
                return (psmb_result_t){PSMB_ERROR};
        }
-       if (setsockopt(ctx->fd, IPPROTO_IPV6, IPV6_PKTINFO,
+       if (setsockopt(ctx->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
                        &on, sizeof(on)) < 0) {
                int sverr = errno;
                LOG(ctx, LOG_ERR, "setsockopt(..., IPV6_PKTINFO, ...): %m");
                        &on, sizeof(on)) < 0) {
                int sverr = errno;
                LOG(ctx, LOG_ERR, "setsockopt(..., IPV6_PKTINFO, ...): %m");
@@ -128,7 +129,7 @@ psmb_result_t psmb_open(psmb_ctx_t *ctx)
                return (psmb_result_t){PSMB_ERROR};
        }
        if (bind(ctx->fd, (struct sockaddr *)&addr,
                return (psmb_result_t){PSMB_ERROR};
        }
        if (bind(ctx->fd, (struct sockaddr *)&addr,
-                       sizeof(struct sockaddr)) == -1) {
+                       sizeof(struct sockaddr_in6)) == -1) {
                int sverr = errno;
                LOG(ctx, LOG_ERR, "bind(): %m");
                close(ctx->fd);
                int sverr = errno;
                LOG(ctx, LOG_ERR, "bind(): %m");
                close(ctx->fd);