aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/config/configuration.c
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-10-07 09:52:33 +0200
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-10-07 15:55:42 +0200
commit6b84ec54083da9911f5ad4816d0eb4f4745afad4 (patch)
treee4296ebb218fff02dc0bbea73ce1c8d12aba7bcc /hicn-light/src/hicn/config/configuration.c
parent85a791ac2cdd35d79c00141e748b4c68fbdafb0d (diff)
[HICN-298] Release new hICN app for Android
Change-Id: I43adc62fadf00690b687078d739788dffdc5e566 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'hicn-light/src/hicn/config/configuration.c')
-rw-r--r--hicn-light/src/hicn/config/configuration.c77
1 files changed, 53 insertions, 24 deletions
diff --git a/hicn-light/src/hicn/config/configuration.c b/hicn-light/src/hicn/config/configuration.c
index 182c2fdc1..b14ea551a 100644
--- a/hicn-light/src/hicn/config/configuration.c
+++ b/hicn-light/src/hicn/config/configuration.c
@@ -363,30 +363,32 @@ struct iovec *configuration_ProcessCreateTunnel(Configuration *config,
Address *source = NULL;
Address *destination = NULL;
- if (!symbolicNameTable_Exists(config->symbolicNameTable, symbolicName)) {
- if (control->ipType == ADDR_INET) {
- source =
- addressFromInaddr4Port(&control->localIp.ipv4, &control->localPort);
- destination =
- addressFromInaddr4Port(&control->remoteIp.ipv4, &control->remotePort);
- } else if (control->ipType == ADDR_INET6) {
- source =
- addressFromInaddr6Port(&control->localIp.ipv6, &control->localPort);
- destination =
- addressFromInaddr6Port(&control->remoteIp.ipv6, &control->remotePort);
- } else {
- printf("Invalid IP type.\n"); // will generate a Nack
- }
-
- AddressPair *pair = addressPair_Create(source, destination);
- conn = (Connection *)connectionTable_FindByAddressPair(
- forwarder_GetConnectionTable(config->forwarder), pair);
+ if (symbolicNameTable_Exists(config->symbolicNameTable, symbolicName)) {
+ logger_Log(config->logger, LoggerFacility_Config, PARCLogLevel_Error,
+ __func__, "Listener symbolic name already exists");
+ goto ERR;
+ }
- addressPair_Release(&pair);
+ if (control->ipType == ADDR_INET) {
+ source =
+ addressFromInaddr4Port(&control->localIp.ipv4, &control->localPort);
+ destination =
+ addressFromInaddr4Port(&control->remoteIp.ipv4, &control->remotePort);
+ } else if (control->ipType == ADDR_INET6) {
+ source =
+ addressFromInaddr6Port(&control->localIp.ipv6, &control->localPort);
+ destination =
+ addressFromInaddr6Port(&control->remoteIp.ipv6, &control->remotePort);
} else {
- conn = NULL;
+ printf("Invalid IP type.\n"); // will generate a Nack
}
+ AddressPair *pair = addressPair_Create(source, destination);
+ conn = (Connection *)connectionTable_FindByAddressPair(
+ forwarder_GetConnectionTable(config->forwarder), pair);
+
+ addressPair_Release(&pair);
+
if (!conn) {
IoOperations *ops = NULL;
switch (control->connectionType) {
@@ -460,11 +462,14 @@ struct iovec *configuration_ProcessCreateTunnel(Configuration *config,
if (destination)
addressDestroy(&destination);
- if (success) { // ACK
- return utils_CreateAck(header, control, sizeof(add_connection_command));
- } else { // NACK
+ if (!success)
+ goto ERR;
+
+ // ACK
+ return utils_CreateAck(header, control, sizeof(add_connection_command));
+
+ERR:
return utils_CreateNack(header, control, sizeof(add_connection_command));
- }
}
/**
@@ -577,6 +582,13 @@ struct iovec *configuration_ProcessRemoveTunnel(Configuration *config,
return response;
}
+void _strlwr(char *string) {
+ char *p = string;
+ while ((*p = tolower(*p))) {
+ p++;
+ }
+}
+
struct iovec *configuration_ProcessConnectionList(Configuration *config,
struct iovec *request) {
ConnectionTable *table = forwarder_GetConnectionTable(config->forwarder);
@@ -603,8 +615,17 @@ struct iovec *configuration_ProcessConnectionList(Configuration *config,
// set structure fields
listConnectionsCommand->connid = connection_GetConnectionId(original);
+
+ const char *connectionName = symbolicNameTable_GetNameByIndex(config->symbolicNameTable, connection_GetConnectionId(original));
+ snprintf(listConnectionsCommand->connectionName, 16, "%s", connectionName);
+ _strlwr(listConnectionsCommand->connectionName);
+
+ snprintf(listConnectionsCommand->interfaceName, 16, "%s", ioOperations_GetInterfaceName(connection_GetIoOperations(original)));
+
listConnectionsCommand->state =
connection_IsUp(original) ? IFACE_UP : IFACE_DOWN;
+ listConnectionsCommand->admin_state =
+ (connection_GetAdminState(original) == CONNECTION_STATE_UP) ? IFACE_UP : IFACE_DOWN;
listConnectionsCommand->connectionData.connectionType =
ioOperations_GetConnectionType(connection_GetIoOperations(original));
@@ -707,6 +728,14 @@ struct iovec *configuration_ProcessListenersList(Configuration *config,
listListenersCommand->address.ipv6 = tmpAddr6.sin6_addr;
listListenersCommand->port = tmpAddr6.sin6_port;
}
+
+ const char * listenerName = listenerEntry->getListenerName(listenerEntry);
+ snprintf(listListenersCommand->listenerName, 16, "%s", listenerName);
+ if (listenerEntry->getEncapType(listenerEntry) == ENCAP_TCP ||
+ listenerEntry->getEncapType(listenerEntry) == ENCAP_UDP) {
+ const char * interfaceName = listenerEntry->getInterfaceName(listenerEntry);
+ snprintf(listListenersCommand->interfaceName, 16, "%s", interfaceName);
+ }
}
// send response