aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/facemgr/src/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'ctrl/facemgr/src/interfaces')
-rw-r--r--ctrl/facemgr/src/interfaces/android_utility/android_utility.c13
-rw-r--r--ctrl/facemgr/src/interfaces/bonjour/bonjour.c8
-rw-r--r--ctrl/facemgr/src/interfaces/dummy/dummy.c10
-rw-r--r--ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c37
-rw-r--r--ctrl/facemgr/src/interfaces/netlink/netlink.c11
-rw-r--r--ctrl/facemgr/src/interfaces/network_framework/network_framework.c1
-rw-r--r--ctrl/facemgr/src/interfaces/updown/updown.c8
7 files changed, 43 insertions, 45 deletions
diff --git a/ctrl/facemgr/src/interfaces/android_utility/android_utility.c b/ctrl/facemgr/src/interfaces/android_utility/android_utility.c
index a4aa2cbfc..e7c73df8b 100644
--- a/ctrl/facemgr/src/interfaces/android_utility/android_utility.c
+++ b/ctrl/facemgr/src/interfaces/android_utility/android_utility.c
@@ -24,17 +24,18 @@
#include <hicn/ctrl/face.h>
#include <hicn/util/log.h>
#include "../../common.h"
-#include "../../facelet.h"
#include "../../interface.h"
#include <hicn/android_utility/android_utility.h>
#define FACEMGR_ANDROID_UTILITY_CLASS "com/cisco/hicn/forwarder/supportlibrary/AndroidUtility"
+
#define AU_INTERFACE_TYPE_UNDEFINED 0
#define AU_INTERFACE_TYPE_WIRED 1
#define AU_INTERFACE_TYPE_WIFI 2
#define AU_INTERFACE_TYPE_CELLULAR 3
-#define AU_INTERFACE_TYPE_LOOPBACK 4 /* not supported yet */
+#define AU_INTERFACE_TYPE_LOOPBACK 4
+#define AU_INTERFACE_TYPE_UNAVAILABLE 5
#define ERR_STR_JAVA "Java VM parameters are required in the interface configuration."
@@ -77,14 +78,12 @@ int au_on_event(interface_t * interface, const facelet_t * facelet)
* correct interface type, based on the value returned by the Android
* utility shipped with the Android forwarder.
*/
- DEBUG("Android utility received request");
au_data_t * data = (au_data_t*)interface->data;
netdevice_t netdevice = NETDEVICE_EMPTY;
int rc = facelet_get_netdevice(facelet, &netdevice);
if (rc < 0)
return -1;
- DEBUG("[au_on_event] netdevice=%s", netdevice.name);
JNIEnv *env;
JavaVM *jvm = data->cfg.jvm;
@@ -95,8 +94,6 @@ int au_on_event(interface_t * interface, const facelet_t * facelet)
jint interface_type = (*env)->CallStaticIntMethod(env, cls, getNetworkType,
(*env)->NewStringUTF(env, netdevice.name));
- DEBUG("Processing results for interface %s", netdevice.name);
-
netdevice_type_t netdevice_type = AU_INTERFACE_TYPE_UNDEFINED;
switch(interface_type) {
case AU_INTERFACE_TYPE_UNDEFINED:
@@ -114,15 +111,17 @@ int au_on_event(interface_t * interface, const facelet_t * facelet)
netdevice_type = NETDEVICE_TYPE_LOOPBACK;
break;
default:
+ DEBUG("AU RETURNED ERROR");
return -1;
}
+ DEBUG("AU RETURNED %s : %s", netdevice.name, netdevice_type_str[netdevice_type]);
+
facelet_t * facelet_new = facelet_create();
facelet_set_netdevice(facelet_new, netdevice);
facelet_set_status(facelet_new, FACELET_STATUS_CLEAN);
facelet_set_netdevice_type(facelet_new, netdevice_type);
- DEBUG("sending AU udpate");
facelet_set_event(facelet_new, FACELET_EVENT_UPDATE);
interface_raise_event(interface, facelet_new);
diff --git a/ctrl/facemgr/src/interfaces/bonjour/bonjour.c b/ctrl/facemgr/src/interfaces/bonjour/bonjour.c
index 4d09d89bb..87f1e1257 100644
--- a/ctrl/facemgr/src/interfaces/bonjour/bonjour.c
+++ b/ctrl/facemgr/src/interfaces/bonjour/bonjour.c
@@ -26,7 +26,6 @@
#include <hicn/util/log.h>
#include "../../common.h"
-#include "../../facelet.h"
#include "../../interface.h"
#include "../../util/map.h"
#include "mdns/mdns.h"
@@ -107,10 +106,15 @@ int bj_initialize(interface_t * interface, void * cfg)
WSAStartup(versionWanted, &wsaData);
#endif
- interface_register_fd(interface, data->sock, NULL);
+ if (interface_register_fd(interface, data->sock, NULL) < 0) {
+ ERROR("[bj_initialize] Error registering fd");
+ goto ERR_FD;
+ }
return 0;
+ERR_FD:
+ free(data->buffer);
ERR_BUFFER:
#ifndef __ANDROID__
ERR_SOCK_OPT:
diff --git a/ctrl/facemgr/src/interfaces/dummy/dummy.c b/ctrl/facemgr/src/interfaces/dummy/dummy.c
index 6a21792a2..25180465e 100644
--- a/ctrl/facemgr/src/interfaces/dummy/dummy.c
+++ b/ctrl/facemgr/src/interfaces/dummy/dummy.c
@@ -24,7 +24,6 @@
#include <hicn/facemgr.h>
#include "../../common.h"
-#include "../../facelet.h"
#include "../../interface.h"
#include "dummy.h"
@@ -65,6 +64,12 @@ int dummy_initialize(interface_t * interface, void * cfg)
/* ... */
data->fd = 0;
+#if 0
+ if (interface_register_fd(interface, data->fd, NULL) < 0) {
+ ERROR("[dummy_initialize] Error registering fd");
+ goto ERR_FD;
+ }
+#endif
/* ... */
@@ -74,8 +79,9 @@ int dummy_initialize(interface_t * interface, void * cfg)
* - a file descriptor (>0) will be added to the event loop; or
* - 0 if we don't use any file descriptor
*/
- return data->fd;
+ return 0;
+ERR_FD:
ERR_MALLOC:
return -1;
}
diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
index 1f20177c2..e8f168706 100644
--- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
+++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
@@ -27,7 +27,6 @@
#include <hicn/util/ip_address.h>
#include <hicn/util/log.h>
-#include "../../facelet.h"
#include "../../interface.h"
#include "../../util/map.h"
@@ -69,18 +68,6 @@ int hl_process_state(interface_t * interface)
return -1;
}
break;
-#if 0
- foreach_face(f, faces) {
-#if 0
- hc_face_snprintf(buf, MAXSZ_FACE, f);
- printf("Face: %s\n", buf);
-#endif
- facelet_t * facelet = facelet_create_from_face(&f->face);
- facelet_set_event(facelet, FACELET_EVENT_GET);
- interface_raise_event(interface, facelet);
- }
- break;
-#endif
case HL_STATE_FACES_SENT:
break;
@@ -97,7 +84,6 @@ int
hl_after_connect(interface_t * interface)
{
hl_data_t * data = interface->data;
- // XXX cancel timer
/* File descriptor for control socket operations */
if (interface_register_fd(interface, hc_sock_get_fd(data->s), NULL) < 0) {
@@ -123,7 +109,7 @@ hl_connect_timeout(interface_t * interface, int fd, void * unused)
{
int rc = _hl_connect(interface);
if (rc < 0) {
- ERROR("[hl_initialize] Error during connection reattempt; next attempt in %ds", INTERVAL_MS / 1000);
+ DEBUG("[hl_initialize] Error during connection reattempt; next attempt in %ds", INTERVAL_MS / 1000);
return -1;
}
@@ -149,11 +135,11 @@ _hl_connect(interface_t * interface)
}
if (hc_sock_connect(data->s) < 0) {
- ERROR("[hc_connect] Could not connect control socket");
+ DEBUG("[hc_connect] Could not connect control socket");
goto ERR_CONNECT;
}
- return hl_after_connect(interface);
+ return 0;
ERR_CONNECT:
hc_sock_free(data->s);
@@ -183,7 +169,7 @@ hl_connect(interface_t * interface)
hl_data_t * data = interface->data;
if (_hl_connect(interface) >= 0)
- return 0;
+ return hl_after_connect(interface);
/* Timer for managing the connection to the forwarder */
DEBUG("Connection to forwarder failed... next retry in %ds", INTERVAL_MS / 1000);
@@ -250,12 +236,12 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet)
*/
if (facelet_get_face(facelet, &face) < 0) {
ERROR("Could not retrieve face from facelet");
- return -1;
+ goto ERR_FACE;
}
if (!data->s) {
/* We are not connected to the forwarder */
- return -1;
+ goto ERR;
}
@@ -270,7 +256,7 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet)
ERROR("Failed to create face\n");
goto ERR;
}
- INFO("Created face id=%d\n", hc_face.id);
+ INFO("Created face id=%d", hc_face.id);
/* Adding default routs e*/
#if 1
@@ -336,7 +322,6 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet)
hc_face.face = *face;
hc_face_t * face_found;
- printf("hc_face_get\n");
rc = hc_face_get(data->s, &hc_face, &face_found);
if (rc < 0) {
ERROR("Failed to find face\n");
@@ -356,8 +341,6 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet)
goto ERR;
}
- printf("Setting admin state");
- printf("hc_connection_set_admin_state\n");
if (hc_connection_set_admin_state(data->s, conn_id_or_name, admin_state) < 0) {
ERROR("Failed to update admin state");
goto ERR;
@@ -377,6 +360,7 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet)
ERR:
face_free(face);
+ERR_FACE:
return -1;
}
@@ -398,15 +382,14 @@ int hl_callback(interface_t * interface, int fd, void * unused)
if (faces->complete) {
foreach_face(f, faces) {
-#if 1
+#if 0
char buf[MAXSZ_FACE];
hc_face_snprintf(buf, MAXSZ_FACE, f);
printf("Face: %s\n", buf);
-#else
+#endif
facelet_t * facelet = facelet_create_from_face(&f->face);
facelet_set_event(facelet, FACELET_EVENT_GET);
interface_raise_event(interface, facelet);
-#endif
}
}
hc_data_free(faces);
diff --git a/ctrl/facemgr/src/interfaces/netlink/netlink.c b/ctrl/facemgr/src/interfaces/netlink/netlink.c
index babf1c305..a9c8c889e 100644
--- a/ctrl/facemgr/src/interfaces/netlink/netlink.c
+++ b/ctrl/facemgr/src/interfaces/netlink/netlink.c
@@ -29,7 +29,6 @@
#include <hicn/util/log.h>
#include "../../common.h"
-#include "../../facelet.h"
#include "../../interface.h"
typedef enum {
@@ -142,7 +141,7 @@ int nl_initialize(interface_t * interface, void * cfg)
data->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (data->fd < 0) {
- printf("Failed to create netlink socket: %s\n", (char*)strerror(errno));
+ ERROR("[nl_initialize] Failed to create netlink socket: %s", (char*)strerror(errno));
goto ERR_SOCKET;
}
@@ -164,13 +163,16 @@ int nl_initialize(interface_t * interface, void * cfg)
local.nl_pid = getpid(); // set out id using current process id
if (bind(data->fd, (struct sockaddr*)&local, sizeof(local)) < 0) { // bind socket
- printf("Failed to bind netlink socket: %s\n", (char*)strerror(errno));
+ ERROR("[nl_initialize] Failed to bind netlink socket: %s", (char*)strerror(errno));
goto ERR_BIND;
}
interface->data = data;
- interface_register_fd(interface, data->fd, NULL);
+ if (interface_register_fd(interface, data->fd, NULL) < 0) {
+ ERROR("[nl_initialize] Error registering fd");
+ goto ERR_FD;
+ }
#if 1
nl_process_state(interface);
@@ -178,6 +180,7 @@ int nl_initialize(interface_t * interface, void * cfg)
return 0;
+ERR_FD:
ERR_BIND:
close(data->fd);
ERR_SOCKET:
diff --git a/ctrl/facemgr/src/interfaces/network_framework/network_framework.c b/ctrl/facemgr/src/interfaces/network_framework/network_framework.c
index f438d34d5..19fe7bbe2 100644
--- a/ctrl/facemgr/src/interfaces/network_framework/network_framework.c
+++ b/ctrl/facemgr/src/interfaces/network_framework/network_framework.c
@@ -32,7 +32,6 @@
#include "../../common.h"
#include <hicn/ctrl/face.h>
-#include "../../facelet.h"
#include "../../interface.h"
#include "../../util/map.h"
diff --git a/ctrl/facemgr/src/interfaces/updown/updown.c b/ctrl/facemgr/src/interfaces/updown/updown.c
index c864c8c04..6a7ab83f4 100644
--- a/ctrl/facemgr/src/interfaces/updown/updown.c
+++ b/ctrl/facemgr/src/interfaces/updown/updown.c
@@ -28,7 +28,6 @@
#include <hicn/facemgr.h>
#include "../../common.h"
-#include "../../facelet.h"
#include "../../interface.h"
/**
@@ -71,7 +70,12 @@ int updown_initialize(interface_t * interface, void * cfg)
return -1;
}
- return data->fd;
+ if (interface_register_fd(interface, data->fd, NULL) < 0) {
+ ERROR("[updown_initialize] Error registering fd");
+ goto ERR_FD;
+ }
+
+ return 0;
ERR_MALLOC:
return -1;