Skip to content
Snippets Groups Projects
Commit 9e1e3c77 authored by Guy Zana's avatar Guy Zana
Browse files

cli: added if_up() to ifconfig command

parent e308e579
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,11 @@ var ifconfig_cmd = {
var rc = networking_interface.set_ip(ifname, ip, netmask);
return rc;
},
if_up: function(ifname) {
var rc = networking_interface.if_up(ifname);
return rc;
},
invoke: function(inp) {
if (inp.length != 6) {
......@@ -23,6 +28,11 @@ var ifconfig_cmd = {
if (!rc) {
print ("ifconfig: unable to set ip, wrong input");
}
rc = this.if_up(ifname);
if (!rc) {
print ("ifconfig: unable to ifup interface");
}
},
help: function() {
......
......@@ -23,6 +23,17 @@ public class Networking extends ScriptableObject {
}
}
@JSFunction
public static boolean if_up(String ifname)
{
try {
IFConfig.if_up(ifname);
return true;
} catch (IOException e) {
return false;
}
}
@Override
public String getClassName() {
return "Networking";
......
......@@ -11,4 +11,7 @@ public class IFConfig {
public native static void set_ip(String ifname, String ip, String netmask)
throws IOException;
public native static void if_up(String ifname) throws IOException;
}
......@@ -23,3 +23,22 @@ extern "C" JNIEXPORT void JNICALL Java_com_cloudius_net_IFConfig_set_1ip
env->ReleaseStringUTFChars(ip, ip_c);
env->ReleaseStringUTFChars(netmask, netmask_c);
}
/*
* Class: com_cloudius_net_IFConfig
* Method: if_up
* Signature: (Ljava/lang/String;)V
*/
extern "C" JNIEXPORT void JNICALL Java_com_cloudius_net_IFConfig_if_1up
(JNIEnv *env , jclass self, jstring ifname)
{
const char * ifname_c = env->GetStringUTFChars(ifname, 0);
int error = osv_ifup(ifname_c);
if (error) {
jclass cls = env->FindClass("java/io/IOException");
env->ThrowNew(cls, "osv_ifup failed");
}
env->ReleaseStringUTFChars(ifname, ifname_c);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment