X-Git-Url: http://www.average.org/gitweb/?p=psmb.git;a=blobdiff_plain;f=src%2Fpsmb_socket.c;h=c962651bc8ac21f19e7b61c63e9e815c590e1d2e;hp=660a563c375ac8ab5ffcc439ab2b631b09088b6d;hb=20b696a4f530bab420be36972f6a19d36b0f7080;hpb=b59ce6ecc3287f39125703670720c8323235c8ac diff --git a/src/psmb_socket.c b/src/psmb_socket.c index 660a563..c962651 100644 --- a/src/psmb_socket.c +++ b/src/psmb_socket.c @@ -8,6 +8,8 @@ #include #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); @@ -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, - .pmtu = PSMB_DEFAULT_PMTU, .port = PSMB_DEFAULT_PORT}; + .logf = dummy_log, + .pmtu = PSMB_DEFAULT_PMTU, + .port = PSMB_DEFAULT_PORT}; 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) { @@ -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;