]> www.average.org Git - psmb.git/commitdiff
save errnos
authorEugene Crosser <crosser@average.org>
Tue, 12 Mar 2019 08:47:57 +0000 (09:47 +0100)
committerEugene Crosser <crosser@average.org>
Tue, 12 Mar 2019 08:47:57 +0000 (09:47 +0100)
include/psmb.h
src/psmb_socket.c

index 4b92756b85b394a6a6717b4519ab545dc6dfa74d..5092f6a3eaceb117869961e4ba6bf542a8dea5fb 100644 (file)
@@ -12,6 +12,7 @@ psmb_ctx_t *psmb_new_mm(void *(*malloc)(size_t size),
                        void *(*realloc)(void *ptr, size_t size));
 psmb_result_t psmb_set_pmtu(psmb_ctx_t *ctx, unsigned int pmtu);
 psmb_result_t psmb_set_port(psmb_ctx_t *ctx, unsigned short pmtu);
                        void *(*realloc)(void *ptr, size_t size));
 psmb_result_t psmb_set_pmtu(psmb_ctx_t *ctx, unsigned int pmtu);
 psmb_result_t psmb_set_port(psmb_ctx_t *ctx, unsigned short pmtu);
+psmb_result_t psmb_set_mgrp(psmb_ctx_t *ctx, struct {unsigned char _uc[16];} pfx, unsigned char bits);
 psmb_result_t psmb_open(psmb_ctx_t *ctx);
 void psmb_destroy(psmb_ctx_t *ctx);
 int psmb_getfd(psmb_ctx_t *ctx);
 psmb_result_t psmb_open(psmb_ctx_t *ctx);
 void psmb_destroy(psmb_ctx_t *ctx);
 int psmb_getfd(psmb_ctx_t *ctx);
index a7c42efa9a6177443264731eff064ad6fe9bfcc4..660a563c375ac8ab5ffcc439ab2b631b09088b6d 100644 (file)
@@ -68,20 +68,26 @@ psmb_result_t psmb_open(psmb_ctx_t *ctx)
        }
        if (setsockopt(ctx->fd, SOL_SOCKET, SO_REUSEADDR,
                        &on, sizeof(on)) < 0) {
        }
        if (setsockopt(ctx->fd, SOL_SOCKET, SO_REUSEADDR,
                        &on, sizeof(on)) < 0) {
+               int sverr = errno;
                close(ctx->fd);
                ctx->fd = -1;
                close(ctx->fd);
                ctx->fd = -1;
+               errno = sverr;
                return (psmb_result_t){PSMB_ERROR};
        }
        if (setsockopt(ctx->fd, IPPROTO_IPV6, IPV6_PKTINFO,
                        &on, sizeof(on)) < 0) {
                return (psmb_result_t){PSMB_ERROR};
        }
        if (setsockopt(ctx->fd, IPPROTO_IPV6, IPV6_PKTINFO,
                        &on, sizeof(on)) < 0) {
+               int sverr = errno;
                close(ctx->fd);
                ctx->fd = -1;
                close(ctx->fd);
                ctx->fd = -1;
+               errno = sverr;
                return (psmb_result_t){PSMB_ERROR};
        }
        if (bind(ctx->fd, (struct sockaddr *)&addr,
                        sizeof(struct sockaddr)) == -1) {
                return (psmb_result_t){PSMB_ERROR};
        }
        if (bind(ctx->fd, (struct sockaddr *)&addr,
                        sizeof(struct sockaddr)) == -1) {
+               int sverr = errno;
                close(ctx->fd);
                ctx->fd = -1;
                close(ctx->fd);
                ctx->fd = -1;
+               errno = sverr;
                return (psmb_result_t){PSMB_ERROR};
        }
        return (psmb_result_t){PSMB_OK};
                return (psmb_result_t){PSMB_ERROR};
        }
        return (psmb_result_t){PSMB_OK};