]> www.average.org Git - psmb.git/blobdiff - src/psmb_socket.c
function to set mgrp (IPv6 prefix and length)
[psmb.git] / src / psmb_socket.c
index 660a563c375ac8ab5ffcc439ab2b631b09088b6d..c962651bc8ac21f19e7b61c63e9e815c590e1d2e 100644 (file)
@@ -8,6 +8,8 @@
 #include <psmb.h>
 #include "psmb_priv.h"
 
 #include <psmb.h>
 #include "psmb_priv.h"
 
+static void dummy_log(void *log_priv, int priority, const char *format, ...) {}
+
 psmb_ctx_t *psmb_new(void)
 {
        return psmb_new_mm(malloc, free, realloc);
 psmb_ctx_t *psmb_new(void)
 {
        return psmb_new_mm(malloc, free, realloc);
@@ -23,10 +25,26 @@ psmb_ctx_t *psmb_new_mm(void *(*malloc)(size_t size),
        *ctx = (psmb_ctx_t){
                .fd = -1,
                .malloc = malloc, .free = free, .realloc = realloc,
        *ctx = (psmb_ctx_t){
                .fd = -1,
                .malloc = malloc, .free = free, .realloc = realloc,
-               .pmtu = PSMB_DEFAULT_PMTU, .port = PSMB_DEFAULT_PORT};
+               .logf = dummy_log,
+               .pmtu = PSMB_DEFAULT_PMTU,
+               .port = PSMB_DEFAULT_PORT};
        return ctx;
 }
 
        return ctx;
 }
 
+psmb_result_t psmb_set_logf(psmb_ctx_t *ctx,
+       void (*logf)(void *log_priv, int priority, const char *format, ...),
+       void *log_priv)
+{
+       if (ctx->fd == -1) {
+               ctx->logf = logf;
+               ctx->log_priv = log_priv;
+               return (psmb_result_t){PSMB_OK};
+       } else {
+               errno = EBUSY;
+               return (psmb_result_t){PSMB_ERROR};
+       }
+}
+
 psmb_result_t psmb_set_pmtu(psmb_ctx_t *ctx, unsigned int pmtu)
 {
        if (ctx->fd == -1) {
 psmb_result_t psmb_set_pmtu(psmb_ctx_t *ctx, unsigned int pmtu)
 {
        if (ctx->fd == -1) {
@@ -49,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;