summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-06-28 16:38:03 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-06-28 16:45:45 +0200
commit99d19307fae8f1370f52a62aee88fded624ad464 (patch)
tree36b94730d8690c2d131f39b3cc3ff715674f9fcc /src/lib
parent0d789ed8d938cc342c8f2138280795a1d5a61e3d (diff)
downloadouroboros-99d19307fae8f1370f52a62aee88fded624ad464.tar.gz
ouroboros-99d19307fae8f1370f52a62aee88fded624ad464.zip
lib, irmd, ipcpd: Change pid to api
Changes the variable name as well to API instead of PID.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dev.c20
-rw-r--r--src/lib/ipcp.c86
-rw-r--r--src/lib/ipcpd_messages.proto2
-rw-r--r--src/lib/irm.c6
-rw-r--r--src/lib/irmd_messages.proto9
-rw-r--r--src/lib/shm_ap_rbuff.c14
-rw-r--r--src/lib/shm_du_map.c10
-rw-r--r--src/lib/sockets.c18
8 files changed, 82 insertions, 83 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index c6f25cdf..ac995b2d 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -148,12 +148,12 @@ int flow_accept(char ** ae_name)
int cfd = -1;
msg.code = IRM_MSG_CODE__IRM_FLOW_ACCEPT;
- msg.has_pid = true;
+ msg.has_api = true;
pthread_rwlock_rdlock(&_ap_instance->data_lock);
msg.ap_name = _ap_instance->ap_name;
- msg.pid = _ap_instance->api;
+ msg.api = _ap_instance->api;
pthread_rwlock_unlock(&_ap_instance->data_lock);
@@ -162,7 +162,7 @@ int flow_accept(char ** ae_name)
return -1;
}
- if (!recv_msg->has_pid || !recv_msg->has_port_id) {
+ if (!recv_msg->has_api || !recv_msg->has_port_id) {
irm_msg__free_unpacked(recv_msg, NULL);
return -1;
}
@@ -178,7 +178,7 @@ int flow_accept(char ** ae_name)
return -1;
}
- _ap_instance->flows[cfd].rb = shm_ap_rbuff_open(recv_msg->pid);
+ _ap_instance->flows[cfd].rb = shm_ap_rbuff_open(recv_msg->api);
if (_ap_instance->flows[cfd].rb == NULL) {
bmp_release(_ap_instance->fds, cfd);
pthread_rwlock_unlock(&_ap_instance->flows_lock);
@@ -221,8 +221,8 @@ int flow_alloc_resp(int fd,
return -EBADF;
msg.code = IRM_MSG_CODE__IRM_FLOW_ALLOC_RESP;
- msg.has_pid = true;
- msg.pid = _ap_instance->api;
+ msg.has_api = true;
+ msg.api = _ap_instance->api;
msg.has_port_id = true;
pthread_rwlock_rdlock(&_ap_instance->data_lock);
@@ -279,11 +279,11 @@ int flow_alloc(char * dst_name,
msg.code = IRM_MSG_CODE__IRM_FLOW_ALLOC;
msg.dst_name = dst_name;
msg.ae_name = src_ae_name;
- msg.has_pid = true;
+ msg.has_api = true;
pthread_rwlock_rdlock(&_ap_instance->data_lock);
- msg.pid = _ap_instance->api;
+ msg.api = _ap_instance->api;
pthread_rwlock_unlock(&_ap_instance->data_lock);
@@ -292,7 +292,7 @@ int flow_alloc(char * dst_name,
return -1;
}
- if (!recv_msg->has_pid || !recv_msg->has_port_id) {
+ if (!recv_msg->has_api || !recv_msg->has_port_id) {
irm_msg__free_unpacked(recv_msg, NULL);
return -1;
}
@@ -308,7 +308,7 @@ int flow_alloc(char * dst_name,
return -1;
}
- _ap_instance->flows[fd].rb = shm_ap_rbuff_open(recv_msg->pid);
+ _ap_instance->flows[fd].rb = shm_ap_rbuff_open(recv_msg->api);
if (_ap_instance->flows[fd].rb == NULL) {
bmp_release(_ap_instance->fds, fd);
pthread_rwlock_unlock(&_ap_instance->flows_lock);
diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c
index 70f73e0e..2b6b6825 100644
--- a/src/lib/ipcp.c
+++ b/src/lib/ipcp.c
@@ -35,7 +35,7 @@
#include <sys/types.h>
#include <sys/wait.h>
-static ipcp_msg_t * send_recv_ipcp_msg(pid_t pid,
+static ipcp_msg_t * send_recv_ipcp_msg(pid_t api,
ipcp_msg_t * msg)
{
int sockfd = 0;
@@ -44,7 +44,7 @@ static ipcp_msg_t * send_recv_ipcp_msg(pid_t pid,
ssize_t count = 0;
ipcp_msg_t * recv_msg = NULL;
- sock_path = ipcp_sock_path(pid);
+ sock_path = ipcp_sock_path(api);
if (sock_path == NULL)
return NULL;
@@ -101,23 +101,23 @@ static ipcp_msg_t * send_recv_ipcp_msg(pid_t pid,
pid_t ipcp_create(enum ipcp_type ipcp_type)
{
- pid_t pid = 0;
- char irmd_pid[10];
+ pid_t api = 0;
+ char irmd_api[10];
size_t len = 0;
char * ipcp_dir = "/sbin/";
char * full_name = NULL;
char * exec_name = NULL;
- sprintf(irmd_pid, "%u", getpid());
+ sprintf(irmd_api, "%u", getpid());
- pid = fork();
- if (pid == -1) {
+ api = fork();
+ if (api == -1) {
LOG_ERR("Failed to fork");
- return pid;
+ return api;
}
- if (pid != 0) {
- return pid;
+ if (api != 0) {
+ return api;
}
if (ipcp_type == IPCP_NORMAL)
@@ -148,7 +148,7 @@ pid_t ipcp_create(enum ipcp_type ipcp_type)
full_name[len] = '\0';
char * argv[] = {full_name,
- irmd_pid,
+ irmd_api,
0};
char * envp[] = {0};
@@ -162,16 +162,16 @@ pid_t ipcp_create(enum ipcp_type ipcp_type)
exit(EXIT_FAILURE);
}
-int ipcp_destroy(pid_t pid)
+int ipcp_destroy(pid_t api)
{
int status;
- if (kill(pid, SIGTERM)) {
+ if (kill(api, SIGTERM)) {
LOG_ERR("Failed to destroy IPCP");
return -1;
}
- if (waitpid(pid, &status, 0) < 0) {
+ if (waitpid(api, &status, 0) < 0) {
LOG_ERR("Failed to destroy IPCP");
return -1;
}
@@ -179,7 +179,7 @@ int ipcp_destroy(pid_t pid)
return 0;
}
-int ipcp_reg(pid_t pid,
+int ipcp_reg(pid_t api,
char ** dif_names,
size_t len)
{
@@ -196,7 +196,7 @@ int ipcp_reg(pid_t pid,
msg.dif_names = dif_names;
msg.len = len;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -211,7 +211,7 @@ int ipcp_reg(pid_t pid,
return ret;
}
-int ipcp_unreg(pid_t pid,
+int ipcp_unreg(pid_t api,
char ** dif_names,
size_t len)
{
@@ -228,7 +228,7 @@ int ipcp_unreg(pid_t pid,
msg.dif_names = dif_names;
msg.len = len;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -244,7 +244,7 @@ int ipcp_unreg(pid_t pid,
}
-int ipcp_bootstrap(pid_t pid,
+int ipcp_bootstrap(pid_t api,
dif_config_msg_t * conf)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
@@ -257,7 +257,7 @@ int ipcp_bootstrap(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_BOOTSTRAP;
msg.conf = conf;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -272,7 +272,7 @@ int ipcp_bootstrap(pid_t pid,
return ret;
}
-int ipcp_enroll(pid_t pid,
+int ipcp_enroll(pid_t api,
char * dif_name,
char * n_1_dif)
{
@@ -287,7 +287,7 @@ int ipcp_enroll(pid_t pid,
msg.dif_name = dif_name;
msg.n_1_dif = n_1_dif;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL) {
return -1;
}
@@ -303,7 +303,7 @@ int ipcp_enroll(pid_t pid,
return ret;
}
-int ipcp_name_reg(pid_t pid,
+int ipcp_name_reg(pid_t api,
char * name)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
@@ -316,7 +316,7 @@ int ipcp_name_reg(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_NAME_REG;
msg.name = name;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -331,7 +331,7 @@ int ipcp_name_reg(pid_t pid,
return ret;
}
-int ipcp_name_unreg(pid_t pid,
+int ipcp_name_unreg(pid_t api,
char * name)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
@@ -341,7 +341,7 @@ int ipcp_name_unreg(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_NAME_UNREG;
msg.name = name;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -356,9 +356,9 @@ int ipcp_name_unreg(pid_t pid,
return ret;
}
-int ipcp_flow_alloc(pid_t pid,
+int ipcp_flow_alloc(pid_t api,
int port_id,
- pid_t n_pid,
+ pid_t n_api,
char * dst_name,
char * src_ae_name,
enum qos_cube qos)
@@ -373,14 +373,14 @@ int ipcp_flow_alloc(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_FLOW_ALLOC;
msg.has_port_id = true;
msg.port_id = port_id;
- msg.has_pid = true;
- msg.pid = n_pid;
+ msg.has_api = true;
+ msg.api = n_api;
msg.src_ae_name = src_ae_name;
msg.dst_name = dst_name;
msg.has_qos_cube = true;
msg.qos_cube = qos;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -395,9 +395,9 @@ int ipcp_flow_alloc(pid_t pid,
return ret;
}
-int ipcp_flow_alloc_resp(pid_t pid,
+int ipcp_flow_alloc_resp(pid_t api,
int port_id,
- pid_t n_pid,
+ pid_t n_api,
int response)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
@@ -407,12 +407,12 @@ int ipcp_flow_alloc_resp(pid_t pid,
msg.code = IPCP_MSG_CODE__IPCP_FLOW_ALLOC_RESP;
msg.has_port_id = true;
msg.port_id = port_id;
- msg.has_pid = true;
- msg.pid = n_pid;
+ msg.has_api = true;
+ msg.api = n_api;
msg.has_response = true;
msg.response = response;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return -1;
@@ -427,7 +427,7 @@ int ipcp_flow_alloc_resp(pid_t pid,
return ret;
}
-int ipcp_flow_req_arr(pid_t pid,
+int ipcp_flow_req_arr(pid_t api,
char * dst_name,
char * src_ae_name)
{
@@ -439,8 +439,8 @@ int ipcp_flow_req_arr(pid_t pid,
return -EINVAL;
msg.code = IRM_MSG_CODE__IPCP_FLOW_REQ_ARR;
- msg.has_pid = true;
- msg.pid = pid;
+ msg.has_api = true;
+ msg.api = api;
msg.dst_name = dst_name;
msg.ae_name = src_ae_name;
@@ -459,7 +459,7 @@ int ipcp_flow_req_arr(pid_t pid,
return port_id;
}
-int ipcp_flow_alloc_reply(pid_t pid,
+int ipcp_flow_alloc_reply(pid_t api,
int port_id,
int response)
{
@@ -489,10 +489,10 @@ int ipcp_flow_alloc_reply(pid_t pid,
}
-int ipcp_flow_dealloc(pid_t pid,
+int ipcp_flow_dealloc(pid_t api,
int port_id)
{
- if (pid != 0) {
+ if (api != 0) {
ipcp_msg_t msg = IPCP_MSG__INIT;
ipcp_msg_t * recv_msg = NULL;
int ret = -1;
@@ -501,7 +501,7 @@ int ipcp_flow_dealloc(pid_t pid,
msg.has_port_id = true;
msg.port_id = port_id;
- recv_msg = send_recv_ipcp_msg(pid, &msg);
+ recv_msg = send_recv_ipcp_msg(api, &msg);
if (recv_msg == NULL)
return 0;
diff --git a/src/lib/ipcpd_messages.proto b/src/lib/ipcpd_messages.proto
index 9eb5707c..f9e0f972 100644
--- a/src/lib/ipcpd_messages.proto
+++ b/src/lib/ipcpd_messages.proto
@@ -27,7 +27,7 @@ message ipcp_msg {
optional sint32 qos_cube = 11;
optional dif_config_msg conf = 12;
optional sint32 fd = 13;
- optional sint32 pid = 14;
+ optional sint32 api = 14;
optional sint32 response = 15;
optional sint32 result = 16;
};
diff --git a/src/lib/irm.c b/src/lib/irm.c
index e3902469..6b296258 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -177,12 +177,12 @@ ssize_t irm_list_ipcps(char * name,
return -1;
}
- if (recv_msg->pids == NULL) {
+ if (recv_msg->apis == NULL) {
irm_msg__free_unpacked(recv_msg, NULL);
return -1;
}
- nr = recv_msg->n_pids;
+ nr = recv_msg->n_apis;
*apis = malloc(nr * sizeof(pid_t));
if (*apis == NULL) {
irm_msg__free_unpacked(recv_msg, NULL);
@@ -190,7 +190,7 @@ ssize_t irm_list_ipcps(char * name,
}
for (i = 0; i < nr; i++) {
- (*apis)[i] = recv_msg->pids[i];
+ (*apis)[i] = recv_msg->apis[i];
}
irm_msg__free_unpacked(recv_msg, NULL);
diff --git a/src/lib/irmd_messages.proto b/src/lib/irmd_messages.proto
index ab09f0db..fa2ca258 100644
--- a/src/lib/irmd_messages.proto
+++ b/src/lib/irmd_messages.proto
@@ -54,9 +54,8 @@ message irm_msg {
optional sint32 response = 8;
optional string dst_name = 9;
optional sint32 port_id = 10;
- optional int32 pid = 11;
- optional dif_config_msg conf = 12;
- optional uint32 opts = 13;
- repeated int32 pids = 14;
- optional sint32 result = 15;
+ optional dif_config_msg conf = 11;
+ optional uint32 opts = 12;
+ repeated int32 apis = 13;
+ optional sint32 result = 14;
};
diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c
index 6ee2936c..69e96c40 100644
--- a/src/lib/shm_ap_rbuff.c
+++ b/src/lib/shm_ap_rbuff.c
@@ -55,7 +55,7 @@ struct shm_ap_rbuff {
size_t * ptr_tail; /* start of ringbuffer tail */
pthread_mutex_t * shm_mutex; /* lock all free space in shm */
pthread_cond_t * work; /* threads will wait for a signal */
- pid_t pid; /* pid to which this rb belongs */
+ pid_t api; /* api to which this rb belongs */
int fd;
};
@@ -138,19 +138,19 @@ struct shm_ap_rbuff * shm_ap_rbuff_create()
*rb->ptr_tail = 0;
rb->fd = shm_fd;
- rb->pid = getpid();
+ rb->api = getpid();
return rb;
}
-struct shm_ap_rbuff * shm_ap_rbuff_open(pid_t pid)
+struct shm_ap_rbuff * shm_ap_rbuff_open(pid_t api)
{
struct shm_ap_rbuff * rb;
int shm_fd;
struct rb_entry * shm_base;
char fn[25];
- sprintf(fn, SHM_AP_RBUFF_PREFIX "%d", pid);
+ sprintf(fn, SHM_AP_RBUFF_PREFIX "%d", api);
rb = malloc(sizeof(*rb));
if (rb == NULL) {
@@ -190,7 +190,7 @@ struct shm_ap_rbuff * shm_ap_rbuff_open(pid_t pid)
rb->work = (pthread_cond_t *) (rb->shm_mutex + 1);
rb->fd = shm_fd;
- rb->pid = pid;
+ rb->api = api;
return rb;
}
@@ -219,7 +219,7 @@ void shm_ap_rbuff_destroy(struct shm_ap_rbuff * rb)
return;
}
- if (rb->pid != getpid()) {
+ if (rb->api != getpid()) {
LOG_ERR("Tried to destroy other AP's rbuff.");
return;
}
@@ -227,7 +227,7 @@ void shm_ap_rbuff_destroy(struct shm_ap_rbuff * rb)
if (close(rb->fd) < 0)
LOG_DBGF("Couldn't close shared memory.");
- sprintf(fn, SHM_AP_RBUFF_PREFIX "%d", rb->pid);
+ sprintf(fn, SHM_AP_RBUFF_PREFIX "%d", rb->api);
if (munmap(rb->shm_base, SHM_RBUFF_FILE_SIZE) == -1)
LOG_DBGF("Couldn't unmap shared memory.");
diff --git a/src/lib/shm_du_map.c b/src/lib/shm_du_map.c
index f5909e11..2a316265 100644
--- a/src/lib/shm_du_map.c
+++ b/src/lib/shm_du_map.c
@@ -75,7 +75,7 @@ struct shm_du_map {
size_t * ptr_tail; /* start of ringbuffer tail */
pthread_mutex_t * shm_mutex; /* lock all free space in shm */
pthread_cond_t * sanitize; /* run sanitizer when buffer full */
- pid_t * pid; /* pid of the irmd owner */
+ pid_t * api; /* api of the irmd owner */
int fd;
};
@@ -141,7 +141,7 @@ struct shm_du_map * shm_du_map_create()
dum->ptr_tail = dum->ptr_head + 1;
dum->shm_mutex = (pthread_mutex_t *) (dum->ptr_tail + 1);
dum->sanitize = (pthread_cond_t *) (dum->shm_mutex + 1);
- dum->pid = (pid_t *) (dum->sanitize + 1);
+ dum->api = (pid_t *) (dum->sanitize + 1);
pthread_mutexattr_init(&mattr);
pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
@@ -155,7 +155,7 @@ struct shm_du_map * shm_du_map_create()
*dum->ptr_head = 0;
*dum->ptr_tail = 0;
- *dum->pid = getpid();
+ *dum->api = getpid();
dum->fd = shm_fd;
@@ -203,7 +203,7 @@ struct shm_du_map * shm_du_map_open()
dum->ptr_tail = dum->ptr_head + 1;
dum->shm_mutex = (pthread_mutex_t *) (dum->ptr_tail + 1);
dum->sanitize = (pthread_cond_t *) (dum->shm_mutex + 1);
- dum->pid = (pid_t *) (dum->sanitize + 1);
+ dum->api = (pid_t *) (dum->sanitize + 1);
dum->fd = shm_fd;
@@ -212,7 +212,7 @@ struct shm_du_map * shm_du_map_open()
pid_t shm_du_map_owner(struct shm_du_map * dum)
{
- return *dum->pid;
+ return *dum->api;
}
void * shm_du_map_sanitize(void * o)
diff --git a/src/lib/sockets.c b/src/lib/sockets.c
index 403d2833..9bfbad5e 100644
--- a/src/lib/sockets.c
+++ b/src/lib/sockets.c
@@ -149,19 +149,19 @@ irm_msg_t * send_recv_irm_msg(irm_msg_t * msg)
}
-char * ipcp_sock_path(pid_t pid)
+char * ipcp_sock_path(pid_t api)
{
char * full_name = NULL;
- char * pid_string = NULL;
+ char * api_string = NULL;
size_t len = 0;
char * delim = "_";
- len = n_digits(pid);
- pid_string = malloc(len + 1);
- if (pid_string == NULL)
+ len = n_digits(api);
+ api_string = malloc(len + 1);
+ if (api_string == NULL)
return NULL;
- sprintf(pid_string, "%d", pid);
+ sprintf(api_string, "%d", api);
len += strlen(IPCP_SOCK_PATH_PREFIX);
len += strlen(delim);
@@ -169,16 +169,16 @@ char * ipcp_sock_path(pid_t pid)
full_name = malloc(len + 1);
if (full_name == NULL) {
- free(pid_string);
+ free(api_string);
return NULL;
}
strcpy(full_name, IPCP_SOCK_PATH_PREFIX);
strcat(full_name, delim);
- strcat(full_name, pid_string);
+ strcat(full_name, api_string);
strcat(full_name, SOCK_PATH_SUFFIX);
- free(pid_string);
+ free(api_string);
return full_name;
}