]> www.average.org Git - psmb.git/blobdiff - src/psmb_socket.c
fix types and options
[psmb.git] / src / psmb_socket.c
index 28344a7a65c04138712f1dc5922a37e167a3b2e7..538b87c9c766e6159240d05d5ce36757f3c9ac07 100644 (file)
@@ -1,6 +1,7 @@
 #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>
@@ -102,7 +103,7 @@ psmb_result_t psmb_open(psmb_ctx_t *ctx)
                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");
@@ -118,7 +119,7 @@ psmb_result_t psmb_open(psmb_ctx_t *ctx)
                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");
@@ -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,
-                       sizeof(struct sockaddr)) == -1) {
+                       sizeof(struct sockaddr_in6)) == -1) {
                int sverr = errno;
                LOG(ctx, LOG_ERR, "bind(): %m");
                close(ctx->fd);