[zeromq-dev] Zyre patch for IPv6 link local

Pieter Hintjens ph at imatix.com
Thu Dec 17 21:11:45 CET 2015


Looks great, would you send a pull request to the Zyre project? Thanks.

On Wed, Dec 16, 2015 at 8:09 PM,  <Sathish_Yenna at dell.com> wrote:
> Hi all,
>
>
>
> I need to use IPv6 link local addressing for an application in development.
> I have applied patches to ZeroMQ and CZMQ and they were accepted into the
> upstream already. Now, I need to patch Zyre to add interface name to the
> ipaddress if it’s IPv6 address. I have come up with a patch that seemed to
> work, but not so sure if it’s appropriate to be accepted by Zyre owners.
> Would you please review the following patch (also in the attached file) and
> let me know what changes you will make.
>
>
>
> Thanks in advance for your time.
>
>
>
> Regards,
>
> Sathish
>
>
>
> diff --git a/src/zyre_node.c b/src/zyre_node.c
>
> index 13deb77..e93e4be 100644
>
> --- a/src/zyre_node.c
>
> +++ b/src/zyre_node.c
>
> @@ -164,7 +164,11 @@ zyre_node_start (zyre_node_t *self)
>
>          if (streq (hostname, ""))
>
>              return -1;              //  No UDP broadcast interface
> available
>
> -        self->port = zsock_bind (self->inbox, "tcp://%s:*", hostname);
>
> +        if (zsys_ipv6 ())
>
> +            self->port = zsock_bind (self->inbox, "tcp://%s%%%s:*",
> zsys_ipv6_address (), zsys_interface ());
>
> +        else
>
> +            self->port = zsock_bind (self->inbox, "tcp://%s:*", hostname);
>
> +
>
>          zstr_free (&hostname);
>
>          assert (self->port > 0);    //  Die on bad interface or port
> exhaustion
>
>          assert (!self->endpoint);   //  If caller set this, we'd be using
> gossip
>
> @@ -765,8 +769,13 @@ zyre_node_recv_beacon (zyre_node_t *self)
>
>      zuuid_t *uuid = zuuid_new ();
>
>      zuuid_set (uuid, beacon.uuid);
>
>      if (beacon.port) {
>
> -        char endpoint [30];
>
> -        sprintf (endpoint, "tcp://%s:%d", ipaddress, ntohs (beacon.port));
>
> +        char endpoint [100];
>
> +        const char *iface = zsys_interface ();
>
> +
>
> +        if (iface && !streq (iface, "") && !streq (iface, "*"))
>
> +            sprintf (endpoint, "tcp://%s%%%s:%d", ipaddress, iface, ntohs
> (beacon.port));
>
> +        else
>
> +            sprintf (endpoint, "tcp://%s:%d", ipaddress, ntohs
> (beacon.port));
>
>          zyre_peer_t *peer = zyre_node_require_peer (self, uuid, endpoint);
>
>          zyre_peer_refresh (peer);
>
>      }
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



More information about the zeromq-dev mailing list