]> www.average.org Git - psmb.git/commitdiff
function to set mgrp (IPv6 prefix and length)
authorEugene Crosser <evgenii.cherkashin@cloud.ionos.com>
Wed, 13 Mar 2019 11:12:50 +0000 (12:12 +0100)
committerEugene Crosser <evgenii.cherkashin@cloud.ionos.com>
Wed, 13 Mar 2019 11:12:50 +0000 (12:12 +0100)
Signed-off-by: Eugene Crosser <evgenii.cherkashin@profitbricks.com>
include/psmb.h
src/psmb_priv.h
src/psmb_socket.c

index cc320e093a557044848df900a1667d59c8d72d9a..8925aea3bdce79cea17bce930eca1ee99a7a5a38 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <stdlib.h>
 #include <stdbool.h>
 
 #include <stdlib.h>
 #include <stdbool.h>
+#include <netinet/in.h>
 
 typedef struct _psmb_ctx psmb_ctx_t;
 typedef struct _psmb_result psmb_result_t;
 
 typedef struct _psmb_ctx psmb_ctx_t;
 typedef struct _psmb_result psmb_result_t;
@@ -15,7 +16,8 @@ psmb_result_t psmb_set_logf(psmb_ctx_t *ctx,
        void *log_priv);
 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 *log_priv);
 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_set_mgrp(psmb_ctx_t *ctx, struct in6_addr prefix,
+       unsigned char prefixlen);
 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 464665b2c010c53871325b3635cfd11a390d54ca..b2717f9281f931dc1ceabe65b716fc766ef21cf2 100644 (file)
@@ -31,6 +31,8 @@ struct _psmb_ctx {
        void *log_priv;
        unsigned short port;
        int pmtu;
        void *log_priv;
        unsigned short port;
        int pmtu;
+       struct in6_addr prefix;
+       unsigned char prefixlen;
        /* subscription set here */
        struct _msg incoming;
 };
        /* subscription set here */
        struct _msg incoming;
 };
index 4d263526362d5137f5c616d9a2658b8220d0b0dd..c962651bc8ac21f19e7b61c63e9e815c590e1d2e 100644 (file)
@@ -67,6 +67,19 @@ psmb_result_t psmb_set_port(psmb_ctx_t *ctx, unsigned short port)
        }
 }
 
        }
 }
 
+psmb_result_t psmb_set_mgrp(psmb_ctx_t *ctx, struct in6_addr prefix,
+       unsigned char prefixlen)
+{
+       if (ctx->fd == -1) {
+               ctx->prefix = prefix;
+               ctx->prefixlen = prefixlen;
+               return (psmb_result_t){PSMB_OK};
+       } else {
+               errno = EBUSY;
+               return (psmb_result_t){PSMB_ERROR};
+       }
+}
+
 psmb_result_t psmb_open(psmb_ctx_t *ctx)
 {
        unsigned long on = 1;
 psmb_result_t psmb_open(psmb_ctx_t *ctx)
 {
        unsigned long on = 1;