Skip to content

Commit

Permalink
Merge pull request #1615 from bluca/ziflist_ipv6
Browse files Browse the repository at this point in the history
Problem: ziflist does not support IPv6
  • Loading branch information
sappo authored Jan 30, 2017
2 parents 9d2b5fe + 4e89146 commit 6f41bc5
Show file tree
Hide file tree
Showing 20 changed files with 479 additions and 62 deletions.
15 changes: 15 additions & 0 deletions api/ziflist.api
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,19 @@
<method name = "print">
Return the list of interfaces.
</method>

<method name = "new ipv6" singleton = "1" state = "draft">
Get a list of network interfaces currently defined on the system
Includes IPv6 interfaces
<return type = "ziflist" fresh = "1" />
</method>

<method name = "reload ipv6" state = "draft">
Reload network interfaces from system, including IPv6
</method>

<method name = "is ipv6" state = "draft">
Return true if the current interface uses IPv6
<return type = "boolean" />
</method>
</class>
20 changes: 20 additions & 0 deletions bindings/jni/src/main/c/org_zeromq_czmq_Ziflist.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ Java_org_zeromq_czmq_Ziflist__1_1print (JNIEnv *env, jclass c, jlong self)
ziflist_print ((ziflist_t *) (intptr_t) self);
}

JNIEXPORT jlong JNICALL
Java_org_zeromq_czmq_Ziflist__1_1newIpv6 (JNIEnv *env, jclass c)
{
jlong new_ipv6_ = (jlong) (intptr_t) ziflist_new_ipv6 ();
return new_ipv6_;
}

JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Ziflist__1_1reloadIpv6 (JNIEnv *env, jclass c, jlong self)
{
ziflist_reload_ipv6 ((ziflist_t *) (intptr_t) self);
}

JNIEXPORT jboolean JNICALL
Java_org_zeromq_czmq_Ziflist__1_1isIpv6 (JNIEnv *env, jclass c, jlong self)
{
jboolean is_ipv6_ = (jboolean) ziflist_is_ipv6 ((ziflist_t *) (intptr_t) self);
return is_ipv6_;
}

JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Ziflist__1_1test (JNIEnv *env, jclass c, jboolean verbose)
{
Expand Down
22 changes: 22 additions & 0 deletions bindings/jni/src/main/java/org/zeromq/czmq/Ziflist.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,28 @@ public void print () {
__print (self);
}
/*
Get a list of network interfaces currently defined on the system
Includes IPv6 interfaces
*/
native static long __newIpv6 ();
public Ziflist newIpv6 () {
return new Ziflist (__newIpv6 ());
}
/*
Reload network interfaces from system, including IPv6
*/
native static void __reloadIpv6 (long self);
public void reloadIpv6 () {
__reloadIpv6 (self);
}
/*
Return true if the current interface uses IPv6
*/
native static boolean __isIpv6 (long self);
public boolean isIpv6 () {
return __isIpv6 (self);
}
/*
Self test of this class.
*/
native static void __test (boolean verbose);
Expand Down
13 changes: 13 additions & 0 deletions bindings/lua_ffi/czmq_ffi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,19 @@ const char *
void
ziflist_print (ziflist_t *self);

// Get a list of network interfaces currently defined on the system
// Includes IPv6 interfaces
ziflist_t *
ziflist_new_ipv6 (void);

// Reload network interfaces from system, including IPv6
void
ziflist_reload_ipv6 (ziflist_t *self);

// Return true if the current interface uses IPv6
bool
ziflist_is_ipv6 (ziflist_t *self);

// Self test of this class.
void
ziflist_test (bool verbose);
Expand Down
19 changes: 19 additions & 0 deletions bindings/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,25 @@ nothing my_ziflist.print ()

Return the list of interfaces.

```
ziflist my_ziflist.newIpv6 ()
```

Get a list of network interfaces currently defined on the system
Includes IPv6 interfaces

```
nothing my_ziflist.reloadIpv6 ()
```

Reload network interfaces from system, including IPv6

```
boolean my_ziflist.isIpv6 ()
```

Return true if the current interface uses IPv6

```
nothing my_ziflist.test (Boolean)
```
Expand Down
25 changes: 25 additions & 0 deletions bindings/nodejs/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2837,6 +2837,9 @@ NAN_MODULE_INIT (Ziflist::Init) {
Nan::SetPrototypeMethod (tpl, "broadcast", _broadcast);
Nan::SetPrototypeMethod (tpl, "netmask", _netmask);
Nan::SetPrototypeMethod (tpl, "print", _print);
Nan::SetPrototypeMethod (tpl, "newIpv6", _new_ipv6);
Nan::SetPrototypeMethod (tpl, "reloadIpv6", _reload_ipv6);
Nan::SetPrototypeMethod (tpl, "isIpv6", _is_ipv6);
Nan::SetPrototypeMethod (tpl, "test", _test);

constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ());
Expand Down Expand Up @@ -2921,6 +2924,28 @@ NAN_METHOD (Ziflist::_print) {
ziflist_print (ziflist->self);
}

NAN_METHOD (Ziflist::_new_ipv6) {
ziflist_t *result = ziflist_new_ipv6 ();
Ziflist *ziflist_result = new Ziflist (result);
if (ziflist_result) {
// Don't yet know how to return a new object
// ziflist->Wrap (info.This ());
// info.GetReturnValue ().Set (info.This ());
info.GetReturnValue ().Set (Nan::New<Boolean>(true));
}
}

NAN_METHOD (Ziflist::_reload_ipv6) {
Ziflist *ziflist = Nan::ObjectWrap::Unwrap <Ziflist> (info.Holder ());
ziflist_reload_ipv6 (ziflist->self);
}

NAN_METHOD (Ziflist::_is_ipv6) {
Ziflist *ziflist = Nan::ObjectWrap::Unwrap <Ziflist> (info.Holder ());
bool result = ziflist_is_ipv6 (ziflist->self);
info.GetReturnValue ().Set (Nan::New<Boolean>(result));
}

NAN_METHOD (Ziflist::_test) {
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `verbose`");
Expand Down
3 changes: 3 additions & 0 deletions bindings/nodejs/binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ class Ziflist: public Nan::ObjectWrap {
static NAN_METHOD (_broadcast);
static NAN_METHOD (_netmask);
static NAN_METHOD (_print);
static NAN_METHOD (_new_ipv6);
static NAN_METHOD (_reload_ipv6);
static NAN_METHOD (_is_ipv6);
static NAN_METHOD (_test);
};

Expand Down
26 changes: 26 additions & 0 deletions bindings/python/czmq/_czmq_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3116,6 +3116,12 @@ def test(verbose):
lib.ziflist_netmask.argtypes = [ziflist_p]
lib.ziflist_print.restype = None
lib.ziflist_print.argtypes = [ziflist_p]
lib.ziflist_new_ipv6.restype = ziflist_p
lib.ziflist_new_ipv6.argtypes = []
lib.ziflist_reload_ipv6.restype = None
lib.ziflist_reload_ipv6.argtypes = [ziflist_p]
lib.ziflist_is_ipv6.restype = c_bool
lib.ziflist_is_ipv6.argtypes = [ziflist_p]
lib.ziflist_test.restype = None
lib.ziflist_test.argtypes = [c_bool]

Expand Down Expand Up @@ -3215,6 +3221,26 @@ def print(self):
"""
return lib.ziflist_print(self._as_parameter_)

@staticmethod
def new_ipv6():
"""
Get a list of network interfaces currently defined on the system
Includes IPv6 interfaces
"""
return Ziflist(lib.ziflist_new_ipv6(), True)

def reload_ipv6(self):
"""
Reload network interfaces from system, including IPv6
"""
return lib.ziflist_reload_ipv6(self._as_parameter_)

def is_ipv6(self):
"""
Return true if the current interface uses IPv6
"""
return lib.ziflist_is_ipv6(self._as_parameter_)

@staticmethod
def test(verbose):
"""
Expand Down
13 changes: 13 additions & 0 deletions bindings/python_cffi/czmq_cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,19 @@
void
ziflist_print (ziflist_t *self);
// Get a list of network interfaces currently defined on the system
// Includes IPv6 interfaces
ziflist_t *
ziflist_new_ipv6 (void);
// Reload network interfaces from system, including IPv6
void
ziflist_reload_ipv6 (ziflist_t *self);
// Return true if the current interface uses IPv6
bool
ziflist_is_ipv6 (ziflist_t *self);
// Self test of this class.
void
ziflist_test (bool verbose);
Expand Down
21 changes: 21 additions & 0 deletions bindings/qml/src/QmlZiflist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,33 @@ void QmlZiflist::print () {
ziflist_print (self);
};

///
// Reload network interfaces from system, including IPv6
void QmlZiflist::reloadIpv6 () {
ziflist_reload_ipv6 (self);
};

///
// Return true if the current interface uses IPv6
bool QmlZiflist::isIpv6 () {
return ziflist_is_ipv6 (self);
};


QObject* QmlZiflist::qmlAttachedProperties(QObject* object) {
return new QmlZiflistAttached(object);
}


///
// Get a list of network interfaces currently defined on the system
// Includes IPv6 interfaces
QmlZiflist *QmlZiflistAttached::newIpv6 () {
QmlZiflist *retQ_ = new QmlZiflist ();
retQ_->self = ziflist_new_ipv6 ();
return retQ_;
};

///
// Self test of this class.
void QmlZiflistAttached::test (bool verbose) {
Expand Down
10 changes: 10 additions & 0 deletions bindings/qml/src/QmlZiflist.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public slots:

// Return the list of interfaces.
void print ();

// Reload network interfaces from system, including IPv6
void reloadIpv6 ();

// Return true if the current interface uses IPv6
bool isIpv6 ();
};

class QmlZiflistAttached : public QObject
Expand All @@ -64,6 +70,10 @@ class QmlZiflistAttached : public QObject
};

public slots:
// Get a list of network interfaces currently defined on the system
// Includes IPv6 interfaces
QmlZiflist *newIpv6 ();

// Self test of this class.
void test (bool verbose);

Expand Down
25 changes: 25 additions & 0 deletions bindings/qt/src/qziflist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,31 @@ void QZiflist::print ()

}

///
// Get a list of network interfaces currently defined on the system
// Includes IPv6 interfaces
QZiflist * QZiflist::newIpv6 ()
{
QZiflist *rv = new QZiflist (ziflist_new_ipv6 ());
return rv;
}

///
// Reload network interfaces from system, including IPv6
void QZiflist::reloadIpv6 ()
{
ziflist_reload_ipv6 (self);

}

///
// Return true if the current interface uses IPv6
bool QZiflist::isIpv6 ()
{
bool rv = ziflist_is_ipv6 (self);
return rv;
}

///
// Self test of this class.
void QZiflist::test (bool verbose)
Expand Down
10 changes: 10 additions & 0 deletions bindings/qt/src/qziflist.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ class QT_CZMQ_EXPORT QZiflist : public QObject
// Return the list of interfaces.
void print ();

// Get a list of network interfaces currently defined on the system
// Includes IPv6 interfaces
static QZiflist * newIpv6 ();

// Reload network interfaces from system, including IPv6
void reloadIpv6 ();

// Return true if the current interface uses IPv6
bool isIpv6 ();

// Self test of this class.
static void test (bool verbose);

Expand Down
33 changes: 33 additions & 0 deletions bindings/ruby/lib/czmq/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,39 @@ def self.zhashx_pack_own(*)
attach_function :ziflist_broadcast, [:pointer], :string, **opts
attach_function :ziflist_netmask, [:pointer], :string, **opts
attach_function :ziflist_print, [:pointer], :void, **opts
begin # DRAFT method
attach_function :ziflist_new_ipv6, [], :pointer, **opts
rescue ::FFI::NotFoundError
if $VERBOSE || $DEBUG
warn "The DRAFT function ziflist_new_ipv6()" +
" is not provided by the installed CZMQ library."
end
def self.ziflist_new_ipv6(*)
raise NotImplementedError, "compile CZMQ with --enable-drafts"
end
end
begin # DRAFT method
attach_function :ziflist_reload_ipv6, [:pointer], :void, **opts
rescue ::FFI::NotFoundError
if $VERBOSE || $DEBUG
warn "The DRAFT function ziflist_reload_ipv6()" +
" is not provided by the installed CZMQ library."
end
def self.ziflist_reload_ipv6(*)
raise NotImplementedError, "compile CZMQ with --enable-drafts"
end
end
begin # DRAFT method
attach_function :ziflist_is_ipv6, [:pointer], :bool, **opts
rescue ::FFI::NotFoundError
if $VERBOSE || $DEBUG
warn "The DRAFT function ziflist_is_ipv6()" +
" is not provided by the installed CZMQ library."
end
def self.ziflist_is_ipv6(*)
raise NotImplementedError, "compile CZMQ with --enable-drafts"
end
end
attach_function :ziflist_test, [:bool], :void, **opts

require_relative 'ffi/ziflist'
Expand Down
Loading

0 comments on commit 6f41bc5

Please sign in to comment.