summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/ipcp-data.h1
-rw-r--r--src/ipcpd/ipcp-ops.h6
-rw-r--r--src/ipcpd/ipcp.c12
-rw-r--r--src/ipcpd/local/main.c49
-rw-r--r--src/ipcpd/shim-eth-llc/main.c22
-rw-r--r--src/ipcpd/shim-udp/main.c65
-rw-r--r--src/ipcpd/shim-udp/tests/shim_udp_test.c3
7 files changed, 54 insertions, 104 deletions
diff --git a/src/ipcpd/ipcp-data.h b/src/ipcpd/ipcp-data.h
index 2e86ba11..ce20730b 100644
--- a/src/ipcpd/ipcp-data.h
+++ b/src/ipcpd/ipcp-data.h
@@ -25,7 +25,6 @@
#define IPCPD_IPCP_DATA_H
#include <ouroboros/common.h>
-#include <ouroboros/instance_name.h>
#include <ouroboros/list.h>
#include <sys/types.h>
#include <pthread.h>
diff --git a/src/ipcpd/ipcp-ops.h b/src/ipcpd/ipcp-ops.h
index a1d9f23f..40c331ec 100644
--- a/src/ipcpd/ipcp-ops.h
+++ b/src/ipcpd/ipcp-ops.h
@@ -24,7 +24,7 @@
#ifndef IPCPD_IPCP_OPS_H
#define IPCPD_IPCP_OPS_H
-#include <ouroboros/dif_config.h>
+#include <ouroboros/irm_config.h>
#include <ouroboros/common.h>
#include <sys/types.h>
@@ -38,12 +38,12 @@ struct ipcp_ops {
size_t len);
int (* ipcp_name_reg)(char * name);
int (* ipcp_name_unreg)(char * name);
- int (* ipcp_flow_alloc)(pid_t n_pid,
+ int (* ipcp_flow_alloc)(pid_t n_api,
int port_id,
char * dst_ap_name,
char * src_ae_name,
enum qos_cube qos);
- int (* ipcp_flow_alloc_resp)(pid_t n_pid,
+ int (* ipcp_flow_alloc_resp)(pid_t n_api,
int port_id,
int response);
int (* ipcp_flow_dealloc)(int port_id);
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index b5108712..4acbffa2 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -47,17 +47,13 @@ struct ipcp * ipcp_instance_create()
int ipcp_arg_check(int argc, char * argv[])
{
- if (argc != 3)
+ if (argc != 2)
return -1;
- /* argument 1: pid of irmd */
+ /* argument 1: api of irmd */
if (atoi(argv[1]) == 0)
return -1;
- /* name conformity responsibility of NMS */
-
- /* argument 2: ap name */
-
return 0;
}
@@ -207,7 +203,7 @@ void * ipcp_main_loop(void * o)
}
ret_msg.has_result = true;
ret_msg.result =
- _ipcp->ops->ipcp_flow_alloc(msg->pid,
+ _ipcp->ops->ipcp_flow_alloc(msg->api,
msg->port_id,
msg->dst_name,
msg->src_ae_name,
@@ -220,7 +216,7 @@ void * ipcp_main_loop(void * o)
}
ret_msg.has_result = true;
ret_msg.result =
- _ipcp->ops->ipcp_flow_alloc_resp(msg->pid,
+ _ipcp->ops->ipcp_flow_alloc_resp(msg->api,
msg->port_id,
msg->result);
break;
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 06e2b0a4..2120e4e8 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -28,7 +28,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/common.h>
@@ -50,7 +50,7 @@
#define shim_data(type) ((struct ipcp_local_data *) type->data)
/* global for trapping signal */
-int irmd_pid;
+int irmd_api;
/* this IPCP's data */
#ifdef MAKE_CHECK
@@ -67,7 +67,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;
@@ -82,7 +82,7 @@ struct shim_ap_data {
} * _ap_instance;
-static int shim_ap_init(char * ap_name)
+static int shim_ap_init()
{
int i;
@@ -91,30 +91,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;
@@ -122,7 +108,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);
@@ -153,8 +138,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)
@@ -243,7 +226,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
case SIGTERM:
case SIGHUP:
case SIGQUIT:
- 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);
@@ -293,7 +276,7 @@ static int ipcp_local_bootstrap(struct dif_config * conf)
pthread_rwlock_unlock(&_ipcp->state_lock);
- LOG_DBG("Bootstrapped local IPCP with pid %d.",
+ LOG_DBG("Bootstrapped local IPCP with api %d.",
getpid());
return 0;
@@ -337,7 +320,7 @@ static int ipcp_local_name_unreg(char * name)
return 0;
}
-static int ipcp_local_flow_alloc(pid_t n_pid,
+static int ipcp_local_flow_alloc(pid_t n_api,
int port_id,
char * dst_name,
char * src_ae_name,
@@ -363,7 +346,7 @@ static int ipcp_local_flow_alloc(pid_t n_pid,
return -1; /* -ENOTENROLLED */
}
- rb = shm_ap_rbuff_open(n_pid);
+ rb = shm_ap_rbuff_open(n_api);
if (rb == NULL) {
pthread_rwlock_unlock(&_ipcp->state_lock);
return -1; /* -ENORBUFF */
@@ -393,13 +376,13 @@ static int ipcp_local_flow_alloc(pid_t n_pid,
pthread_rwlock_unlock(&_ap_instance->flows_lock);
pthread_rwlock_unlock(&_ipcp->state_lock);
LOG_ERR("Could not get port id from IRMd");
- /* shm_ap_rbuff_close(n_pid); */
+ /* shm_ap_rbuff_close(n_api); */
return -1;
}
out_fd = bmp_allocate(_ap_instance->fds);
if (!bmp_is_id_valid(_ap_instance->fds, out_fd)) {
- /* shm_ap_rbuff_close(n_pid); */
+ /* shm_ap_rbuff_close(n_api); */
pthread_rwlock_unlock(&_ap_instance->flows_lock);
pthread_rwlock_unlock(&_ipcp->state_lock);
return -1; /* -ENOMOREFDS */
@@ -420,7 +403,7 @@ static int ipcp_local_flow_alloc(pid_t n_pid,
return 0;
}
-static int ipcp_local_flow_alloc_resp(pid_t n_pid,
+static int ipcp_local_flow_alloc_resp(pid_t n_api,
int port_id,
int response)
{
@@ -453,7 +436,7 @@ static int ipcp_local_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[in_fd].state = FLOW_NULL;
@@ -592,8 +575,6 @@ static struct ipcp * ipcp_local_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);
@@ -607,11 +588,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-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index 9bd6920b..48b6391f 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -31,7 +31,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>
@@ -70,7 +70,7 @@ typedef ShimEthLlcMsg shim_eth_llc_msg_t;
#define MAX_SAPS 64
/* global for trapping signal */
-int irmd_pid;
+int irmd_api;
struct ipcp * _ipcp;
@@ -675,7 +675,6 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
dst_mac,
MAC_SIZE) &&
memcmp(br_addr, dst_mac, MAC_SIZE)) {
- LOG_DBG("Not a unicast or broadcast frame.");
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
offset = (offset + 1) & (SHM_BLOCKS_IN_MAP - 1);
header->tp_status = TP_STATUS_KERNEL;
@@ -715,7 +714,6 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
if (j < 0) {
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
pthread_rwlock_unlock(&_ipcp->state_lock);
- LOG_DBG("Received data for unknown flow.");
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
offset = (offset + 1)
& (SHM_BLOCKS_IN_MAP - 1);
@@ -818,7 +816,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);
@@ -990,7 +988,7 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf)
pthread_rwlock_unlock(&_ipcp->state_lock);
- LOG_DBG("Bootstrapped shim IPCP over Ethernet with LLC with pid %d.",
+ LOG_DBG("Bootstrapped shim IPCP over Ethernet with LLC with api %d.",
getpid());
return 0;
@@ -1030,7 +1028,7 @@ static int eth_llc_ipcp_name_unreg(char * name)
return 0;
}
-static int eth_llc_ipcp_flow_alloc(pid_t n_pid,
+static int eth_llc_ipcp_flow_alloc(pid_t n_api,
int port_id,
char * dst_name,
char * src_ae_name,
@@ -1049,7 +1047,7 @@ static int eth_llc_ipcp_flow_alloc(pid_t n_pid,
if (qos != QOS_CUBE_BE)
LOG_DBGF("QoS requested. Ethernet LLC can't do that. For now.");
- rb = shm_ap_rbuff_open(n_pid);
+ rb = shm_ap_rbuff_open(n_api);
if (rb == NULL)
return -1; /* -ENORBUFF */
@@ -1108,7 +1106,7 @@ static int eth_llc_ipcp_flow_alloc(pid_t n_pid,
return index;
}
-static int eth_llc_ipcp_flow_alloc_resp(pid_t n_pid,
+static int eth_llc_ipcp_flow_alloc_resp(pid_t n_api,
int port_id,
int response)
{
@@ -1134,7 +1132,7 @@ static int eth_llc_ipcp_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.");
ipcp_flow(index)->state = FLOW_NULL;
@@ -1236,8 +1234,6 @@ static struct ipcp_ops eth_llc_ops = {
int main(int argc, char * argv[])
{
- /* argument 1: pid of irmd ? */
- /* argument 2: ap name */
struct sigaction sig_act;
sigset_t sigset;
int i = 0;
@@ -1254,7 +1250,7 @@ int main(int argc, char * argv[])
}
/* 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/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;