summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2017-02-07 20:45:14 +0100
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2017-02-07 21:00:45 +0100
commitbfb86b66c8e7d9d8dc45d9075a4db6d10931dccf (patch)
tree022fbb7b2a54ba72affa12938b3bf79abc648b41 /src
parent1bf2dd6aef3af6c81794c0551278373e44310b5c (diff)
downloadouroboros-bfb86b66c8e7d9d8dc45d9075a4db6d10931dccf.tar.gz
ouroboros-bfb86b66c8e7d9d8dc45d9075a4db6d10931dccf.zip
ipcpd: Refactor ipcpi struct
The ipcp-ops header was removed and merged into ipcp.h. The common components dif_name and ipcp_type have been moved to the main ipcp struct. After this move, ipcp_data only contained shim information, so it was renamed to shim_data. The ipcp_init() function checks the type and will only include the shim_data if the type is not an IPCP_NORMAL. All ipcps have been adapted to this change in API.
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/CMakeLists.txt2
-rw-r--r--src/ipcpd/ipcp.c32
-rw-r--r--src/ipcpd/ipcp.h36
-rw-r--r--src/ipcpd/local/main.c16
-rw-r--r--src/ipcpd/normal/main.c4
-rw-r--r--src/ipcpd/shim-data.c (renamed from src/ipcpd/ipcp-data.c)82
-rw-r--r--src/ipcpd/shim-data.h (renamed from src/ipcpd/ipcp-data.h)40
-rw-r--r--src/ipcpd/shim-eth-llc/main.c60
-rw-r--r--src/ipcpd/shim-udp/main.c30
9 files changed, 161 insertions, 141 deletions
diff --git a/src/ipcpd/CMakeLists.txt b/src/ipcpd/CMakeLists.txt
index afce9441..9c77683a 100644
--- a/src/ipcpd/CMakeLists.txt
+++ b/src/ipcpd/CMakeLists.txt
@@ -1,7 +1,7 @@
set(IPCP_SOURCES
# Add source files here
${CMAKE_CURRENT_SOURCE_DIR}/ipcp.c
- ${CMAKE_CURRENT_SOURCE_DIR}/ipcp-data.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/shim-data.c
${CMAKE_CURRENT_SOURCE_DIR}/timerwheel.c
)
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index fe87fbd9..53213c39 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -270,15 +270,17 @@ static void * ipcp_main_loop(void * o)
return (void *) 0;
}
-int ipcp_init(enum ipcp_type type, struct ipcp_ops * ops)
+int ipcp_init(enum ipcp_type type,
+ struct ipcp_ops * ops)
{
pthread_condattr_t cattr;
struct timeval tv = {(IPCP_ACCEPT_TIMEOUT / 1000),
(IPCP_ACCEPT_TIMEOUT % 1000) * 1000};
- ipcpi.irmd_fd = -1;
- ipcpi.state = IPCP_NULL;
+ ipcpi.irmd_fd = -1;
+ ipcpi.state = IPCP_NULL;
+ ipcpi.shim_data = NULL;
ipcpi.threadpool = malloc(sizeof(pthread_t) * IPCPD_THREADPOOL_SIZE);
if (ipcpi.threadpool == NULL) {
@@ -305,15 +307,6 @@ int ipcp_init(enum ipcp_type type, struct ipcp_ops * ops)
ipcpi.ops = ops;
- ipcpi.data = ipcp_data_create();
- if (ipcpi.data == NULL) {
- free(ipcpi.threadpool);
- free(ipcpi.sock_path);
- return -ENOMEM;
- }
-
- ipcp_data_init(ipcpi.data, type);
-
pthread_rwlock_init(&ipcpi.state_lock, NULL);
pthread_mutex_init(&ipcpi.state_mtx, NULL);
pthread_condattr_init(&cattr);
@@ -322,6 +315,16 @@ int ipcp_init(enum ipcp_type type, struct ipcp_ops * ops)
#endif
pthread_cond_init(&ipcpi.state_cond, &cattr);
+ if (type == IPCP_NORMAL)
+ return 0;
+
+ ipcpi.shim_data = shim_data_create();
+ if (ipcpi.shim_data == NULL) {
+ free(ipcpi.threadpool);
+ free(ipcpi.sock_path);
+ return -ENOMEM;
+ }
+
return 0;
}
@@ -364,7 +367,7 @@ void ipcp_fini()
free(ipcpi.sock_path);
free(ipcpi.threadpool);
- ipcp_data_destroy(ipcpi.data);
+ shim_data_destroy(ipcpi.shim_data);
pthread_cond_destroy(&ipcpi.state_cond);
pthread_mutex_destroy(&ipcpi.state_mtx);
@@ -422,7 +425,8 @@ int ipcp_wait_state(enum ipcp_state state,
return ret;
}
-int ipcp_parse_arg(int argc, char * argv[])
+int ipcp_parse_arg(int argc,
+ char * argv[])
{
char * log_file;
size_t len = 0;
diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h
index 8b590cc2..9a4d272a 100644
--- a/src/ipcpd/ipcp.h
+++ b/src/ipcpd/ipcp.h
@@ -23,9 +23,9 @@
#define IPCPD_IPCP_H
#include <ouroboros/config.h>
+#include <ouroboros/irm_config.h>
-#include "ipcp-ops.h"
-#include "ipcp-data.h"
+#include "shim-data.h"
#include <pthread.h>
#include <time.h>
@@ -37,16 +37,42 @@ enum ipcp_state {
IPCP_SHUTDOWN
};
+struct ipcp_ops {
+ int (* ipcp_bootstrap)(struct dif_config * conf);
+
+ int (* ipcp_enroll)(char * dif_name);
+
+ int (* ipcp_name_reg)(char * name);
+
+ int (* ipcp_name_unreg)(char * name);
+
+ int (* ipcp_name_query)(char * name);
+
+ int (* ipcp_flow_alloc)(int fd,
+ char * dst_ap_name,
+ char * src_ae_name,
+ qoscube_t qos);
+
+ int (* ipcp_flow_alloc_resp)(int fd,
+ int response);
+
+ int (* ipcp_flow_dealloc)(int fd);
+};
+
struct ipcp {
int irmd_api;
char * name;
+ enum ipcp_type type;
+ char * dif_name;
+
uint64_t address;
- struct ipcp_data * data;
struct ipcp_ops * ops;
int irmd_fd;
+ struct shim_data * shim_data;
+
enum ipcp_state state;
pthread_rwlock_t state_lock;
pthread_mutex_t state_mtx;
@@ -57,7 +83,7 @@ struct ipcp {
pthread_t * threadpool;
} ipcpi;
-int ipcp_init(enum ipcp_type type,
+int ipcp_init(enum ipcp_type type,
struct ipcp_ops * ops);
int ipcp_boot(void);
@@ -73,7 +99,7 @@ enum ipcp_state ipcp_get_state(void);
int ipcp_wait_state(enum ipcp_state state,
const struct timespec * timeout);
-int ipcp_parse_arg(int argc,
+int ipcp_parse_arg(int argc,
char * argv[]);
#endif
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index c2b22732..2cba053a 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -115,7 +115,9 @@ static void * ipcp_local_sdu_loop(void * o)
return (void *) 0;
}
-void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
+void ipcp_sig_handler(int sig,
+ siginfo_t * info,
+ void * c)
{
(void) c;
@@ -176,7 +178,7 @@ static int ipcp_local_name_reg(char * name)
pthread_rwlock_rdlock(&ipcpi.state_lock);
- if (ipcp_data_reg_add_entry(ipcpi.data, name_dup)) {
+ if (shim_data_reg_add_entry(ipcpi.shim_data, name_dup)) {
pthread_rwlock_unlock(&ipcpi.state_lock);
LOG_DBG("Failed to add %s to local registry.", name);
free(name_dup);
@@ -194,7 +196,7 @@ static int ipcp_local_name_unreg(char * name)
{
pthread_rwlock_rdlock(&ipcpi.state_lock);
- ipcp_data_reg_del_entry(ipcpi.data, name);
+ shim_data_reg_del_entry(ipcpi.shim_data, name);
pthread_rwlock_unlock(&ipcpi.state_lock);
@@ -209,7 +211,7 @@ static int ipcp_local_name_query(char * name)
pthread_rwlock_rdlock(&ipcpi.state_lock);
- ret = (ipcp_data_reg_has(ipcpi.data, name) ? 0 : -1);
+ ret = (shim_data_reg_has(ipcpi.shim_data, name) ? 0 : -1);
pthread_rwlock_unlock(&ipcpi.state_lock);
@@ -253,7 +255,8 @@ static int ipcp_local_flow_alloc(int fd,
return 0;
}
-static int ipcp_local_flow_alloc_resp(int fd, int response)
+static int ipcp_local_flow_alloc_resp(int fd,
+ int response)
{
int out_fd = -1;
int ret = -1;
@@ -325,7 +328,8 @@ static struct ipcp_ops local_ops = {
.ipcp_flow_dealloc = ipcp_local_flow_dealloc
};
-int main(int argc, char * argv[])
+int main(int argc,
+ char * argv[])
{
struct sigaction sig_act;
sigset_t sigset;
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index b9cc6e57..97484958 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -150,8 +150,8 @@ static int boot_components(void)
return -1;
}
- ipcpi.data->dif_name = strdup(buf);
- if (ipcpi.data->dif_name == NULL) {
+ ipcpi.dif_name = strdup(buf);
+ if (ipcpi.dif_name == NULL) {
LOG_ERR("Failed to set DIF name.");
return -1;
}
diff --git a/src/ipcpd/ipcp-data.c b/src/ipcpd/shim-data.c
index 47c4c472..933f3a64 100644
--- a/src/ipcpd/ipcp-data.c
+++ b/src/ipcpd/shim-data.c
@@ -20,15 +20,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#define OUROBOROS_PREFIX "ipcp-utils"
-
#include <ouroboros/config.h>
#include <ouroboros/list.h>
#include <ouroboros/time_utils.h>
-#include <ouroboros/logs.h>
#include <ouroboros/errno.h>
-#include "ipcp-data.h"
+#include "shim-data.h"
#include "ipcp.h"
#include <string.h>
@@ -98,40 +95,26 @@ static void dir_entry_destroy(struct dir_entry * entry)
free(entry);
}
-struct ipcp_data * ipcp_data_create()
+struct shim_data * shim_data_create()
{
- struct ipcp_data * data = malloc(sizeof(*data));
- if (data == NULL)
+ struct shim_data * sd = malloc(sizeof(*sd));
+ if (sd == NULL)
return NULL;
- data->type = 0;
-
- return data;
-}
-
-struct ipcp_data * ipcp_data_init(struct ipcp_data * dst,
- enum ipcp_type ipcp_type)
-{
- if (dst == NULL)
- return NULL;
-
- dst->type = ipcp_type;
- dst->dif_name = NULL;
-
/* init the lists */
- list_head_init(&dst->registry);
- list_head_init(&dst->directory);
- list_head_init(&dst->dir_queries);
+ list_head_init(&sd->registry);
+ list_head_init(&sd->directory);
+ list_head_init(&sd->dir_queries);
/* init the locks */
- pthread_rwlock_init(&dst->reg_lock, NULL);
- pthread_rwlock_init(&dst->dir_lock, NULL);
- pthread_mutex_init(&dst->dir_queries_lock, NULL);
+ pthread_rwlock_init(&sd->reg_lock, NULL);
+ pthread_rwlock_init(&sd->dir_lock, NULL);
+ pthread_mutex_init(&sd->dir_queries_lock, NULL);
- return dst;
+ return sd;
}
-static void clear_registry(struct ipcp_data * data)
+static void clear_registry(struct shim_data * data)
{
struct list_head * h;
struct list_head * t;
@@ -145,7 +128,7 @@ static void clear_registry(struct ipcp_data * data)
}
}
-static void clear_directory(struct ipcp_data * data)
+static void clear_directory(struct shim_data * data)
{
struct list_head * h;
struct list_head * t;
@@ -159,7 +142,7 @@ static void clear_directory(struct ipcp_data * data)
}
}
-static void clear_dir_queries(struct ipcp_data * data)
+static void clear_dir_queries(struct shim_data * data)
{
struct list_head * h;
struct list_head * t;
@@ -169,11 +152,11 @@ static void clear_dir_queries(struct ipcp_data * data)
list_for_each_safe(h, t, &data->dir_queries) {
struct dir_query * e = list_entry(h, struct dir_query, next);
list_del(&e->next);
- ipcp_data_dir_query_destroy(e);
+ shim_data_dir_query_destroy(e);
}
}
-void ipcp_data_destroy(struct ipcp_data * data)
+void shim_data_destroy(struct shim_data * data)
{
if (data == NULL)
return;
@@ -191,9 +174,6 @@ void ipcp_data_destroy(struct ipcp_data * data)
clear_dir_queries(data);
pthread_mutex_unlock(&data->dir_queries_lock);
- if (data->dif_name != NULL)
- free(data->dif_name);
-
pthread_rwlock_destroy(&data->dir_lock);
pthread_rwlock_destroy(&data->reg_lock);
pthread_mutex_destroy(&data->dir_queries_lock);
@@ -201,7 +181,7 @@ void ipcp_data_destroy(struct ipcp_data * data)
free(data);
}
-static struct reg_entry * find_reg_entry_by_name(struct ipcp_data * data,
+static struct reg_entry * find_reg_entry_by_name(struct shim_data * data,
const char * name)
{
struct list_head * h;
@@ -218,7 +198,7 @@ static struct reg_entry * find_reg_entry_by_name(struct ipcp_data * data,
return NULL;
}
-static struct dir_entry * find_dir_entry(struct ipcp_data * data,
+static struct dir_entry * find_dir_entry(struct shim_data * data,
const char * name,
uint64_t addr)
{
@@ -232,7 +212,7 @@ static struct dir_entry * find_dir_entry(struct ipcp_data * data,
return NULL;
}
-static struct dir_entry * find_dir_entry_any(struct ipcp_data * data,
+static struct dir_entry * find_dir_entry_any(struct shim_data * data,
const char * name)
{
struct list_head * h;
@@ -245,7 +225,7 @@ static struct dir_entry * find_dir_entry_any(struct ipcp_data * data,
return NULL;
}
-int ipcp_data_reg_add_entry(struct ipcp_data * data,
+int shim_data_reg_add_entry(struct shim_data * data,
char * name)
{
struct reg_entry * entry;
@@ -273,7 +253,7 @@ int ipcp_data_reg_add_entry(struct ipcp_data * data,
return 0;
}
-int ipcp_data_reg_del_entry(struct ipcp_data * data,
+int shim_data_reg_del_entry(struct shim_data * data,
const char * name)
{
struct reg_entry * e;
@@ -297,7 +277,7 @@ int ipcp_data_reg_del_entry(struct ipcp_data * data,
return 0;
}
-bool ipcp_data_reg_has(struct ipcp_data * data,
+bool shim_data_reg_has(struct shim_data * data,
const char * name)
{
bool ret = false;
@@ -314,7 +294,7 @@ bool ipcp_data_reg_has(struct ipcp_data * data,
return ret;
}
-int ipcp_data_dir_add_entry(struct ipcp_data * data,
+int shim_data_dir_add_entry(struct shim_data * data,
char * name,
uint64_t addr)
{
@@ -347,12 +327,10 @@ int ipcp_data_dir_add_entry(struct ipcp_data * data,
pthread_rwlock_unlock(&data->dir_lock);
- LOG_DBG("Added directory entry for %s.", entry_name);
-
return 0;
}
-int ipcp_data_dir_del_entry(struct ipcp_data * data,
+int shim_data_dir_del_entry(struct shim_data * data,
const char * name,
uint64_t addr)
{
@@ -377,7 +355,7 @@ int ipcp_data_dir_del_entry(struct ipcp_data * data,
return 0;
}
-bool ipcp_data_dir_has(struct ipcp_data * data,
+bool shim_data_dir_has(struct shim_data * data,
const char * name)
{
bool ret = false;
@@ -391,7 +369,7 @@ bool ipcp_data_dir_has(struct ipcp_data * data,
return ret;
}
-uint64_t ipcp_data_dir_get_addr(struct ipcp_data * data,
+uint64_t shim_data_dir_get_addr(struct shim_data * data,
const char * name)
{
struct dir_entry * entry;
@@ -413,7 +391,7 @@ uint64_t ipcp_data_dir_get_addr(struct ipcp_data * data,
return addr;
}
-struct dir_query * ipcp_data_dir_query_create(char * name)
+struct dir_query * shim_data_dir_query_create(char * name)
{
struct dir_query * query;
pthread_condattr_t cattr;
@@ -442,7 +420,7 @@ struct dir_query * ipcp_data_dir_query_create(char * name)
return query;
}
-void ipcp_data_dir_query_respond(struct dir_query * query)
+void shim_data_dir_query_respond(struct dir_query * query)
{
assert(query);
@@ -462,7 +440,7 @@ void ipcp_data_dir_query_respond(struct dir_query * query)
pthread_mutex_unlock(&query->lock);
}
-void ipcp_data_dir_query_destroy(struct dir_query * query)
+void shim_data_dir_query_destroy(struct dir_query * query)
{
assert(query);
@@ -493,7 +471,7 @@ void ipcp_data_dir_query_destroy(struct dir_query * query)
free(query);
}
-int ipcp_data_dir_query_wait(struct dir_query * query,
+int shim_data_dir_query_wait(struct dir_query * query,
const struct timespec * timeout)
{
struct timespec abstime;
diff --git a/src/ipcpd/ipcp-data.h b/src/ipcpd/shim-data.h
index 877aa04a..28087901 100644
--- a/src/ipcpd/ipcp-data.h
+++ b/src/ipcpd/shim-data.h
@@ -26,10 +26,10 @@
#include <ouroboros/shared.h>
#include <ouroboros/list.h>
-#include "ipcp-ops.h"
-
#include <sys/types.h>
#include <pthread.h>
+#include <stdint.h>
+
enum dir_query_state {
QUERY_INIT = 0,
@@ -48,10 +48,7 @@ struct dir_query {
pthread_cond_t cond;
};
-struct ipcp_data {
- enum ipcp_type type;
- char * dif_name;
-
+struct shim_data {
struct list_head registry;
pthread_rwlock_t reg_lock;
@@ -62,42 +59,39 @@ struct ipcp_data {
pthread_mutex_t dir_queries_lock;
};
-struct ipcp_data * ipcp_data_create(void);
-
-struct ipcp_data * ipcp_data_init(struct ipcp_data * dst,
- enum ipcp_type ipcp_type);
+struct shim_data * shim_data_create(void);
-void ipcp_data_destroy(struct ipcp_data * data);
+void shim_data_destroy(struct shim_data * data);
-int ipcp_data_reg_add_entry(struct ipcp_data * data,
+int shim_data_reg_add_entry(struct shim_data * data,
char * name);
-int ipcp_data_reg_del_entry(struct ipcp_data * data,
+int shim_data_reg_del_entry(struct shim_data * data,
const char * name);
-bool ipcp_data_reg_has(struct ipcp_data * data,
+bool shim_data_reg_has(struct shim_data * data,
const char * name);
-int ipcp_data_dir_add_entry(struct ipcp_data * data,
+int shim_data_dir_add_entry(struct shim_data * data,
char * name,
uint64_t addr);
-int ipcp_data_dir_del_entry(struct ipcp_data * data,
+int shim_data_dir_del_entry(struct shim_data * data,
const char * name,
uint64_t addr);
-bool ipcp_data_dir_has(struct ipcp_data * data,
+bool shim_data_dir_has(struct shim_data * data,
const char * name);
-uint64_t ipcp_data_dir_get_addr(struct ipcp_data * data,
+uint64_t shim_data_dir_get_addr(struct shim_data * data,
const char * name);
-struct dir_query * ipcp_data_dir_query_create(char * name);
+struct dir_query * shim_data_dir_query_create(char * name);
-void ipcp_data_dir_query_respond(struct dir_query * query);
+void shim_data_dir_query_respond(struct dir_query * query);
-void ipcp_data_dir_query_destroy(struct dir_query * query);
+void shim_data_dir_query_destroy(struct dir_query * query);
-int ipcp_data_dir_query_wait(struct dir_query * query,
+int shim_data_dir_query_wait(struct dir_query * query,
const struct timespec * timeout);
-#endif /* IPCPD_IPCP_DATA_H */
+#endif /* IPCPD_SHIM_DATA_H */
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index bc0d8a27..fba4f5f3 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -415,11 +415,12 @@ static int eth_llc_ipcp_sap_alloc_reply(uint8_t ssap,
}
-static int eth_llc_ipcp_name_query_req(char * name, uint8_t * r_addr)
+static int eth_llc_ipcp_name_query_req(char * name,
+ uint8_t * r_addr)
{
shim_eth_llc_msg_t msg = SHIM_ETH_LLC_MSG__INIT;
- if (ipcp_data_reg_has(ipcpi.data, name)) {
+ if (shim_data_reg_has(ipcpi.shim_data, name)) {
msg.code = SHIM_ETH_LLC_MSG_CODE__NAME_QUERY_REPLY;
msg.dst_name = name;
@@ -429,29 +430,32 @@ static int eth_llc_ipcp_name_query_req(char * name, uint8_t * r_addr)
return 0;
}
-static int eth_llc_ipcp_name_query_reply(char * name, uint8_t * r_addr)
+static int eth_llc_ipcp_name_query_reply(char * name,
+ uint8_t * r_addr)
{
uint64_t address = 0;
struct list_head * pos;
memcpy(&address, r_addr, MAC_SIZE);
- ipcp_data_dir_add_entry(ipcpi.data, name, address);
+ shim_data_dir_add_entry(ipcpi.shim_data, name, address);
- pthread_mutex_lock(&ipcpi.data->dir_queries_lock);
- list_for_each(pos, &ipcpi.data->dir_queries) {
+ pthread_mutex_lock(&ipcpi.shim_data->dir_queries_lock);
+ list_for_each(pos, &ipcpi.shim_data->dir_queries) {
struct dir_query * e =
list_entry(pos, struct dir_query, next);
if (strcmp(e->name, name) == 0) {
- ipcp_data_dir_query_respond(e);
+ shim_data_dir_query_respond(e);
}
}
- pthread_mutex_unlock(&ipcpi.data->dir_queries_lock);
+ pthread_mutex_unlock(&ipcpi.shim_data->dir_queries_lock);
return 0;
}
-static int eth_llc_ipcp_mgmt_frame(uint8_t * buf, size_t len, uint8_t * r_addr)
+static int eth_llc_ipcp_mgmt_frame(uint8_t * buf,
+ size_t len,
+ uint8_t * r_addr)
{
shim_eth_llc_msg_t * msg = shim_eth_llc_msg__unpack(NULL, len, buf);
if (msg == NULL) {
@@ -461,7 +465,7 @@ static int eth_llc_ipcp_mgmt_frame(uint8_t * buf, size_t len, uint8_t * r_addr)
switch (msg->code) {
case SHIM_ETH_LLC_MSG_CODE__FLOW_REQ:
- if (ipcp_data_reg_has(ipcpi.data, msg->dst_name)) {
+ if (shim_data_reg_has(ipcpi.shim_data, msg->dst_name)) {
eth_llc_ipcp_sap_req(msg->ssap,
r_addr,
msg->dst_name,
@@ -664,7 +668,9 @@ static void * eth_llc_ipcp_sdu_writer(void * o)
return (void *) 1;
}
-void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
+void ipcp_sig_handler(int sig,
+ siginfo_t * info,
+ void * c)
{
(void) c;
@@ -873,7 +879,7 @@ static int eth_llc_ipcp_name_reg(char * name)
pthread_rwlock_rdlock(&ipcpi.state_lock);
- if (ipcp_data_reg_add_entry(ipcpi.data, name_dup)) {
+ if (shim_data_reg_add_entry(ipcpi.shim_data, name_dup)) {
pthread_rwlock_unlock(&ipcpi.state_lock);
LOG_ERR("Failed to add %s to local registry.", name);
free(name_dup);
@@ -891,7 +897,7 @@ static int eth_llc_ipcp_name_unreg(char * name)
{
pthread_rwlock_rdlock(&ipcpi.state_lock);
- ipcp_data_reg_del_entry(ipcpi.data, name);
+ shim_data_reg_del_entry(ipcpi.shim_data, name);
pthread_rwlock_unlock(&ipcpi.state_lock);
@@ -906,7 +912,7 @@ static int eth_llc_ipcp_name_query(char * name)
struct dir_query * query;
int ret;
- if (ipcp_data_dir_has(ipcpi.data, name))
+ if (shim_data_dir_has(ipcpi.shim_data, name))
return 0;
msg.code = SHIM_ETH_LLC_MSG_CODE__NAME_QUERY_REQ;
@@ -914,22 +920,22 @@ static int eth_llc_ipcp_name_query(char * name)
memset(r_addr, 0xff, MAC_SIZE);
- query = ipcp_data_dir_query_create(name);
+ query = shim_data_dir_query_create(name);
if (query == NULL)
return -1;
- pthread_mutex_lock(&ipcpi.data->dir_queries_lock);
- list_add(&query->next, &ipcpi.data->dir_queries);
- pthread_mutex_unlock(&ipcpi.data->dir_queries_lock);
+ pthread_mutex_lock(&ipcpi.shim_data->dir_queries_lock);
+ list_add(&query->next, &ipcpi.shim_data->dir_queries);
+ pthread_mutex_unlock(&ipcpi.shim_data->dir_queries_lock);
eth_llc_ipcp_send_mgmt_frame(&msg, r_addr);
- ret = ipcp_data_dir_query_wait(query, &timeout);
+ ret = shim_data_dir_query_wait(query, &timeout);
- pthread_mutex_lock(&ipcpi.data->dir_queries_lock);
+ pthread_mutex_lock(&ipcpi.shim_data->dir_queries_lock);
list_del(&query->next);
- ipcp_data_dir_query_destroy(query);
- pthread_mutex_unlock(&ipcpi.data->dir_queries_lock);
+ shim_data_dir_query_destroy(query);
+ pthread_mutex_unlock(&ipcpi.shim_data->dir_queries_lock);
return ret;
}
@@ -961,12 +967,12 @@ static int eth_llc_ipcp_flow_alloc(int fd,
return -1; /* -ENOTENROLLED */
}
- if (!ipcp_data_dir_has(ipcpi.data, dst_name)) {
+ if (!shim_data_dir_has(ipcpi.shim_data, dst_name)) {
pthread_rwlock_unlock(&ipcpi.state_lock);
LOG_ERR("Destination unreachable.");
return -1;
}
- addr = ipcp_data_dir_get_addr(ipcpi.data, dst_name);
+ addr = shim_data_dir_get_addr(ipcpi.shim_data, dst_name);
pthread_rwlock_wrlock(&eth_llc_data.flows_lock);
@@ -1007,7 +1013,8 @@ static int eth_llc_ipcp_flow_alloc(int fd,
return 0;
}
-static int eth_llc_ipcp_flow_alloc_resp(int fd, int response)
+static int eth_llc_ipcp_flow_alloc_resp(int fd,
+ int response)
{
uint8_t ssap = 0;
uint8_t r_sap = 0;
@@ -1096,7 +1103,8 @@ static struct ipcp_ops eth_llc_ops = {
.ipcp_flow_dealloc = eth_llc_ipcp_flow_dealloc
};
-int main(int argc, char * argv[])
+int main(int argc,
+ char * argv[])
{
struct sigaction sig_act;
sigset_t sigset;
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index c2f86067..a7c4254a 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -156,7 +156,8 @@ static void clr_fd(int fd)
pthread_mutex_unlock(&udp_data.fd_set_lock);
}
-static int send_shim_udp_msg(shim_udp_msg_t * msg, uint32_t dst_ip_addr)
+static int send_shim_udp_msg(shim_udp_msg_t * msg,
+ uint32_t dst_ip_addr)
{
buffer_t buf;
struct sockaddr_in r_saddr;
@@ -518,7 +519,9 @@ static void * ipcp_udp_sdu_loop(void * o)
return (void *) 1;
}
-void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
+void ipcp_sig_handler(int sig,
+ siginfo_t * info,
+ void * c)
{
(void) c;
@@ -689,7 +692,8 @@ static int ddns_send(char * cmd)
return 0;
}
-static uint32_t ddns_resolve(char * name, uint32_t dns_addr)
+static uint32_t ddns_resolve(char * name,
+ uint32_t dns_addr)
{
pid_t api = -1;
int wstatus;
@@ -791,7 +795,7 @@ static int ipcp_udp_name_reg(char * name)
pthread_rwlock_rdlock(&ipcpi.state_lock);
- if (ipcp_data_reg_add_entry(ipcpi.data, name_dup)) {
+ if (shim_data_reg_add_entry(ipcpi.shim_data, name_dup)) {
pthread_rwlock_unlock(&ipcpi.state_lock);
LOG_ERR("Failed to add %s to local registry.", name);
free(name_dup);
@@ -823,7 +827,7 @@ static int ipcp_udp_name_reg(char * name)
if (ddns_send(cmd)) {
pthread_rwlock_rdlock(&ipcpi.state_lock);
- ipcp_data_reg_del_entry(ipcpi.data, name);
+ shim_data_reg_del_entry(ipcpi.shim_data, name);
pthread_rwlock_unlock(&ipcpi.state_lock);
return -1;
}
@@ -872,7 +876,7 @@ static int ipcp_udp_name_unreg(char * name)
pthread_rwlock_rdlock(&ipcpi.state_lock);
- ipcp_data_reg_del_entry(ipcpi.data, name);
+ shim_data_reg_del_entry(ipcpi.shim_data, name);
pthread_rwlock_unlock(&ipcpi.state_lock);
@@ -902,7 +906,7 @@ static int ipcp_udp_name_query(char * name)
return -1; /* -ENOTENROLLED */
}
- if (ipcp_data_dir_has(ipcpi.data, name)) {
+ if (shim_data_dir_has(ipcpi.shim_data, name)) {
pthread_rwlock_unlock(&ipcpi.state_lock);
return 0;
}
@@ -940,7 +944,7 @@ static int ipcp_udp_name_query(char * name)
}
#endif
- if (ipcp_data_dir_add_entry(ipcpi.data, name, ip_addr)) {
+ if (shim_data_dir_add_entry(ipcpi.shim_data, name, ip_addr)) {
pthread_rwlock_unlock(&ipcpi.state_lock);
LOG_ERR("Failed to add directory entry.");
return -1;
@@ -1006,13 +1010,13 @@ static int ipcp_udp_flow_alloc(int fd,
return -1; /* -ENOTENROLLED */
}
- if (!ipcp_data_dir_has(ipcpi.data, dst_name)) {
+ if (!shim_data_dir_has(ipcpi.shim_data, dst_name)) {
pthread_rwlock_unlock(&ipcpi.state_lock);
LOG_DBG("Could not resolve destination.");
close(skfd);
return -1;
}
- ip_addr = (uint32_t) ipcp_data_dir_get_addr(ipcpi.data, dst_name);
+ ip_addr = (uint32_t) shim_data_dir_get_addr(ipcpi.shim_data, dst_name);
/* connect to server (store the remote IP address in the fd) */
memset((char *) &r_saddr, 0, sizeof(r_saddr));
@@ -1060,7 +1064,8 @@ static int ipcp_udp_flow_alloc(int fd,
return fd;
}
-static int ipcp_udp_flow_alloc_resp(int fd, int response)
+static int ipcp_udp_flow_alloc_resp(int fd,
+ int response)
{
int skfd = -1;
struct sockaddr_in f_saddr;
@@ -1166,7 +1171,8 @@ static struct ipcp_ops udp_ops = {
.ipcp_flow_dealloc = ipcp_udp_flow_dealloc
};
-int main(int argc, char * argv[])
+int main(int argc,
+ char * argv[])
{
struct sigaction sig_act;
sigset_t sigset;