summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-udp
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2016-06-28 17:02:42 +0200
committerdimitri staessens <[email protected]>2016-06-28 17:02:42 +0200
commita19521aa74edfa4a2eb62466b04c9264c3b6576c (patch)
tree36b94730d8690c2d131f39b3cc3ff715674f9fcc /src/ipcpd/shim-udp
parentacd29da104d0d8ddace2b2693314542bb5a56fcc (diff)
parent99d19307fae8f1370f52a62aee88fded624ad464 (diff)
downloadouroboros-a19521aa74edfa4a2eb62466b04c9264c3b6576c.tar.gz
ouroboros-a19521aa74edfa4a2eb62466b04c9264c3b6576c.zip
Merged in sandervrijders/ouroboros/be (pull request #144)
lib, irmd, ipcpd: Change of IRM API
Diffstat (limited to 'src/ipcpd/shim-udp')
-rw-r--r--src/ipcpd/shim-udp/main.c65
-rw-r--r--src/ipcpd/shim-udp/tests/shim_udp_test.c3
2 files changed, 23 insertions, 45 deletions
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index 221e60d2..a28c262f 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -29,7 +29,7 @@
#include <ouroboros/list.h>
#include <ouroboros/utils.h>
#include <ouroboros/ipcp.h>
-#include <ouroboros/dif_config.h>
+#include <ouroboros/irm_config.h>
#include <ouroboros/sockets.h>
#include <ouroboros/bitmap.h>
#include <ouroboros/flow.h>
@@ -69,7 +69,7 @@ typedef ShimUdpMsg shim_udp_msg_t;
_ipcp->data)->s_saddr.sin_addr.s_addr)
/* global for trapping signal */
-int irmd_pid;
+int irmd_api;
/* this IPCP's data */
#ifdef MAKE_CHECK
@@ -86,7 +86,7 @@ struct ipcp * _ipcp;
/* the shim needs access to these internals */
struct shim_ap_data {
- instance_name_t * api;
+ pid_t api;
struct shm_du_map * dum;
struct bmp * fds;
struct shm_ap_rbuff * rb;
@@ -103,7 +103,7 @@ struct shim_ap_data {
pthread_mutex_t fd_set_lock;
} * _ap_instance;
-static int shim_ap_init(char * ap_name)
+static int shim_ap_init()
{
int i;
@@ -112,30 +112,16 @@ static int shim_ap_init(char * ap_name)
return -1;
}
- _ap_instance->api = instance_name_create();
- if (_ap_instance->api == NULL) {
- free(_ap_instance);
- return -1;
- }
-
- if (instance_name_init_from(_ap_instance->api,
- ap_name,
- getpid()) == NULL) {
- instance_name_destroy(_ap_instance->api);
- free(_ap_instance);
- return -1;
- }
+ _ap_instance->api = getpid();
_ap_instance->fds = bmp_create(AP_MAX_FLOWS, 0);
if (_ap_instance->fds == NULL) {
- instance_name_destroy(_ap_instance->api);
free(_ap_instance);
return -1;
}
_ap_instance->dum = shm_du_map_open();
if (_ap_instance->dum == NULL) {
- instance_name_destroy(_ap_instance->api);
bmp_destroy(_ap_instance->fds);
free(_ap_instance);
return -1;
@@ -143,7 +129,6 @@ static int shim_ap_init(char * ap_name)
_ap_instance->rb = shm_ap_rbuff_create();
if (_ap_instance->rb == NULL) {
- instance_name_destroy(_ap_instance->api);
shm_du_map_close(_ap_instance->dum);
bmp_destroy(_ap_instance->fds);
free(_ap_instance);
@@ -174,8 +159,6 @@ void shim_ap_fini()
if (_ipcp->state != IPCP_SHUTDOWN)
LOG_WARN("Cleaning up AP while not in shutdown.");
- if (_ap_instance->api != NULL)
- instance_name_destroy(_ap_instance->api);
if (_ap_instance->fds != NULL)
bmp_destroy(_ap_instance->fds);
if (_ap_instance->dum != NULL)
@@ -834,7 +817,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
case SIGINT:
case SIGTERM:
case SIGHUP:
- if (info->si_pid == irmd_pid) {
+ if (info->si_pid == irmd_api) {
bool clean_threads = false;
LOG_DBG("Terminating by order of %d. Bye.",
info->si_pid);
@@ -964,7 +947,7 @@ static int ipcp_udp_bootstrap(struct dif_config * conf)
pthread_rwlock_unlock(&_ipcp->state_lock);
- LOG_DBG("Bootstrapped shim IPCP over UDP with pid %d.",
+ LOG_DBG("Bootstrapped shim IPCP over UDP with api %d.",
getpid());
LOG_DBG("Bound to IP address %s.", ipstr);
@@ -978,7 +961,7 @@ static int ipcp_udp_bootstrap(struct dif_config * conf)
/* NOTE: Disgusted with this crap */
static int ddns_send(char * cmd)
{
- pid_t pid = 0;
+ pid_t api = 0;
int wstatus;
int pipe_fd[2];
char * argv[] = {NSUPDATE_EXEC, 0};
@@ -989,13 +972,13 @@ static int ddns_send(char * cmd)
return -1;
}
- pid = fork();
- if (pid == -1) {
+ api = fork();
+ if (api == -1) {
LOG_ERR("Failed to fork.");
return -1;
}
- if (pid == 0) {
+ if (api == 0) {
close(pipe_fd[1]);
dup2(pipe_fd[0], 0);
execve(argv[0], &argv[0], envp);
@@ -1009,7 +992,7 @@ static int ddns_send(char * cmd)
return -1;
}
- waitpid(pid, &wstatus, 0);
+ waitpid(api, &wstatus, 0);
if (WIFEXITED(wstatus) == true &&
WEXITSTATUS(wstatus) == 0)
LOG_DBG("Succesfully communicated with DNS server.");
@@ -1022,7 +1005,7 @@ static int ddns_send(char * cmd)
static uint32_t ddns_resolve(char * name, uint32_t dns_addr)
{
- pid_t pid = 0;
+ pid_t api = 0;
int wstatus;
int pipe_fd[2];
char dnsstr[INET_ADDRSTRLEN];
@@ -1043,13 +1026,13 @@ static uint32_t ddns_resolve(char * name, uint32_t dns_addr)
return 0;
}
- pid = fork();
- if (pid == -1) {
+ api = fork();
+ if (api == -1) {
LOG_ERR("Failed to fork.");
return 0;
}
- if (pid == 0) {
+ if (api == 0) {
char * argv[] = {NSLOOKUP_EXEC, name, dnsstr, 0};
char * envp[] = {0};
@@ -1069,7 +1052,7 @@ static uint32_t ddns_resolve(char * name, uint32_t dns_addr)
close(pipe_fd[0]);
- waitpid(pid, &wstatus, 0);
+ waitpid(api, &wstatus, 0);
if (WIFEXITED(wstatus) == true &&
WEXITSTATUS(wstatus) == 0)
LOG_DBG("Succesfully communicated with nslookup.");
@@ -1215,7 +1198,7 @@ static int ipcp_udp_name_unreg(char * name)
return 0;
}
-static int ipcp_udp_flow_alloc(pid_t n_pid,
+static int ipcp_udp_flow_alloc(pid_t n_api,
int port_id,
char * dst_name,
char * src_ae_name,
@@ -1245,7 +1228,7 @@ static int ipcp_udp_flow_alloc(pid_t n_pid,
if (qos != QOS_CUBE_BE)
LOG_DBG("QoS requested. UDP/IP can't do that.");
- rb = shm_ap_rbuff_open(n_pid);
+ rb = shm_ap_rbuff_open(n_api);
if (rb == NULL)
return -1; /* -ENORBUFF */
@@ -1365,7 +1348,7 @@ static int ipcp_udp_flow_alloc(pid_t n_pid,
return fd;
}
-static int ipcp_udp_flow_alloc_resp(pid_t n_pid,
+static int ipcp_udp_flow_alloc_resp(pid_t n_api,
int port_id,
int response)
{
@@ -1406,7 +1389,7 @@ static int ipcp_udp_flow_alloc_resp(pid_t n_pid,
return -1;
}
- rb = shm_ap_rbuff_open(n_pid);
+ rb = shm_ap_rbuff_open(n_api);
if (rb == NULL) {
LOG_ERR("Could not open N + 1 ringbuffer.");
_ap_instance->flows[fd].state = FLOW_NULL;
@@ -1576,8 +1559,6 @@ static struct ipcp * ipcp_udp_create()
int main (int argc, char * argv[])
{
- /* argument 1: pid of irmd ? */
- /* argument 2: ap name */
struct sigaction sig_act;
sigset_t sigset;
sigemptyset(&sigset);
@@ -1591,11 +1572,11 @@ int main (int argc, char * argv[])
exit(1);
}
- if (shim_ap_init(argv[2]) < 0)
+ if (shim_ap_init() < 0)
exit(1);
/* store the process id of the irmd */
- irmd_pid = atoi(argv[1]);
+ irmd_api = atoi(argv[1]);
/* init sig_act */
memset(&sig_act, 0, sizeof(sig_act));
diff --git a/src/ipcpd/shim-udp/tests/shim_udp_test.c b/src/ipcpd/shim-udp/tests/shim_udp_test.c
index e5e8b32d..b222ac42 100644
--- a/src/ipcpd/shim-udp/tests/shim_udp_test.c
+++ b/src/ipcpd/shim-udp/tests/shim_udp_test.c
@@ -34,9 +34,6 @@ struct ipcp * _ipcp;
int shim_udp_test(int argc, char ** argv)
{
- /* argument 1: pid of irmd ? */
- /* argument 2: ap name */
- /* argument 3: instance id */
struct shm_du_map * dum;
char * ipcp_name = "test-shim-ipcp";
int i = 0;