summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-04-21 12:35:48 +0200
committerSander Vrijders <[email protected]>2016-04-21 12:35:48 +0200
commita618984537f7790cd274d097223b4029473044c2 (patch)
tree0de76147c8a7beb4c23a1931f822113b61c51a5b /src
parent468729f048f1cdafa7a83ba388bfe2e26588d776 (diff)
parent0921044139bf323c308ff73109b508250db9db02 (diff)
downloadouroboros-a618984537f7790cd274d097223b4029473044c2.tar.gz
ouroboros-a618984537f7790cd274d097223b4029473044c2.zip
Merged in dstaesse/ouroboros/be-ipcp-data (pull request #59)
ipcpd: fixes in ipcp-data
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/ipcp-data.c29
-rw-r--r--src/ipcpd/ipcp-data.h9
2 files changed, 30 insertions, 8 deletions
diff --git a/src/ipcpd/ipcp-data.c b/src/ipcpd/ipcp-data.c
index 2ed20943..1828fda9 100644
--- a/src/ipcpd/ipcp-data.c
+++ b/src/ipcpd/ipcp-data.c
@@ -436,8 +436,8 @@ uint64_t ipcp_data_get_addr(struct ipcp_data * data,
return addr;
}
-static flow_t * find_flow(struct ipcp_data * data,
- uint32_t port_id)
+flow_t * ipcp_data_find_flow(struct ipcp_data * data,
+ uint32_t port_id)
{
struct list_head * h;
list_for_each(h, &data->flows) {
@@ -452,7 +452,7 @@ static flow_t * find_flow(struct ipcp_data * data,
bool ipcp_data_has_flow(struct ipcp_data * data,
uint32_t port_id)
{
- return find_flow(data, port_id) != NULL;
+ return ipcp_data_find_flow(data, port_id) != NULL;
}
int ipcp_data_add_flow(struct ipcp_data * data,
@@ -474,3 +474,26 @@ int ipcp_data_add_flow(struct ipcp_data * data,
return 0;
}
+
+int ipcp_data_del_flow(struct ipcp_data * data,
+ uint32_t port_id)
+{
+ flow_t * f;
+
+ if (data == NULL)
+ return -1;
+
+ pthread_mutex_lock(&data->flow_lock);
+
+ f = ipcp_data_find_flow(data, port_id);
+ if (f == NULL)
+ return -1;
+
+ list_del(&f->list);
+
+ free(f);
+
+ pthread_mutex_unlock(&data->flow_lock);
+
+ return 0;
+}
diff --git a/src/ipcpd/ipcp-data.h b/src/ipcpd/ipcp-data.h
index a8db44f7..3f036ef5 100644
--- a/src/ipcpd/ipcp-data.h
+++ b/src/ipcpd/ipcp-data.h
@@ -80,12 +80,11 @@ uint64_t ipcp_data_get_addr(struct ipcp_data * data,
const char * ap_name);
bool ipcp_data_has_flow(struct ipcp_data * data,
uint32_t port_id);
-bool ipcp_data_has_flow_s(struct ipcp_data * data,
- uint32_t port_id,
- enum flow_state state);
+flow_t * ipcp_data_find_flow(struct ipcp_data * data,
+ uint32_t port_id);
int ipcp_data_add_flow(struct ipcp_data * data,
flow_t * flow);
-int ipcp_data_remove_flow(struct ipcp_data * data,
- uint32_t port_id);
+int ipcp_data_del_flow(struct ipcp_data * data,
+ uint32_t port_id);
#endif /* IPCPD_IPCP_DATA_H */