From: Eugene Crosser Date: Wed, 13 Mar 2019 11:12:50 +0000 (+0100) Subject: function to set mgrp (IPv6 prefix and length) X-Git-Url: http://www.average.org/gitweb/?p=psmb.git;a=commitdiff_plain;h=20b696a4f530bab420be36972f6a19d36b0f7080;hp=0e17b577419dd949124a0ca44c335c4ca929e928 function to set mgrp (IPv6 prefix and length) Signed-off-by: Eugene Crosser --- diff --git a/include/psmb.h b/include/psmb.h index cc320e0..8925aea 100644 --- a/include/psmb.h +++ b/include/psmb.h @@ -2,6 +2,7 @@ #include #include +#include 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); -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); diff --git a/src/psmb_priv.h b/src/psmb_priv.h index 464665b..b2717f9 100644 --- a/src/psmb_priv.h +++ b/src/psmb_priv.h @@ -31,6 +31,8 @@ struct _psmb_ctx { void *log_priv; unsigned short port; int pmtu; + struct in6_addr prefix; + unsigned char prefixlen; /* subscription set here */ struct _msg incoming; }; diff --git a/src/psmb_socket.c b/src/psmb_socket.c index 4d26352..c962651 100644 --- a/src/psmb_socket.c +++ b/src/psmb_socket.c @@ -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;