summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dif_config.proto4
-rw-r--r--src/lib/irm.c8
-rw-r--r--src/lib/shm_rdrbuff.c117
3 files changed, 35 insertions, 94 deletions
diff --git a/src/lib/dif_config.proto b/src/lib/dif_config.proto
index dbdf19e5..338634d1 100644
--- a/src/lib/dif_config.proto
+++ b/src/lib/dif_config.proto
@@ -7,8 +7,8 @@ message dif_config_msg {
optional uint32 pdu_length_size = 5;
optional uint32 qos_id_size = 6;
optional uint32 seqno_size = 7;
- optional uint32 ttl_size = 8;
- optional uint32 chk_size = 9;
+ optional bool has_ttl = 8;
+ optional bool has_chk = 9;
optional uint32 min_pdu_size = 10;
optional uint32 max_pdu_size = 11;
// Config for shim UDP
diff --git a/src/lib/irm.c b/src/lib/irm.c
index 64a4fa0f..fce11ba5 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -115,8 +115,8 @@ int irm_bootstrap_ipcp(pid_t api,
config.has_pdu_length_size = true;
config.has_qos_id_size = true;
config.has_seqno_size = true;
- config.has_ttl_size = true;
- config.has_chk_size = true;
+ config.has_has_ttl = true;
+ config.has_has_chk = true;
config.has_min_pdu_size = true;
config.has_max_pdu_size = true;
@@ -125,8 +125,8 @@ int irm_bootstrap_ipcp(pid_t api,
config.pdu_length_size = conf->pdu_length_size;
config.qos_id_size = conf->qos_id_size;
config.seqno_size = conf->seqno_size;
- config.ttl_size = conf->ttl_size;
- config.chk_size = conf->chk_size;
+ config.has_ttl = conf->has_ttl;
+ config.has_chk = conf->has_chk;
config.min_pdu_size = conf->min_pdu_size;
config.max_pdu_size = conf->max_pdu_size;
break;
diff --git a/src/lib/shm_rdrbuff.c b/src/lib/shm_rdrbuff.c
index 93a889ce..b0d295d9 100644
--- a/src/lib/shm_rdrbuff.c
+++ b/src/lib/shm_rdrbuff.c
@@ -690,32 +690,32 @@ int shm_rdrbuff_remove(struct shm_rdrbuff * rdrb, ssize_t idx)
return 0;
}
-uint8_t * shm_du_buff_head_alloc(struct shm_rdrbuff * rdrb,
- ssize_t idx,
- size_t size)
+uint8_t * shm_du_buff_head(struct shm_du_buff * sdb)
{
- struct shm_du_buff * sdb;
- uint8_t * buf;
-
- if (rdrb == NULL)
+ if (sdb == NULL)
return NULL;
- if (idx < 0 || idx > SHM_BUFFER_SIZE)
+ return (uint8_t *) (sdb + 1) + sdb->du_head;
+}
+
+uint8_t * shm_du_buff_tail(struct shm_du_buff * sdb)
+{
+ if (sdb == NULL)
return NULL;
-#ifdef __APPLE__
- pthread_mutex_lock(rdrb->lock);
-#else
- if (pthread_mutex_lock(rdrb->lock) == EOWNERDEAD) {
- LOG_DBGF("Recovering dead mutex.");
- pthread_mutex_consistent(rdrb->lock);
- }
-#endif
- sdb = idx_to_du_buff_ptr(rdrb, idx);
+ return (uint8_t *) (sdb + 1) + sdb->du_tail;
+}
+
+uint8_t * shm_du_buff_head_alloc(struct shm_du_buff * sdb,
+ size_t size)
+{
+ uint8_t * buf = NULL;
+
+ if (sdb == NULL)
+ return NULL;
if ((long) (sdb->du_head - size) < 0) {
- pthread_mutex_unlock(rdrb->lock);
- LOG_DBGF("Failed to allocate PCI headspace.");
+ LOG_ERR("Failed to allocate PCI headspace.");
return NULL;
}
@@ -723,37 +723,19 @@ uint8_t * shm_du_buff_head_alloc(struct shm_rdrbuff * rdrb,
buf = (uint8_t *) (sdb + 1) + sdb->du_head;
- pthread_mutex_unlock(rdrb->lock);
-
return buf;
}
-uint8_t * shm_du_buff_tail_alloc(struct shm_rdrbuff * rdrb,
- ssize_t idx,
+uint8_t * shm_du_buff_tail_alloc(struct shm_du_buff * sdb,
size_t size)
{
- struct shm_du_buff * sdb;
- uint8_t * buf;
-
- if (rdrb == NULL)
- return NULL;
+ uint8_t * buf = NULL;
- if (idx < 0 || idx > SHM_BUFFER_SIZE)
+ if (sdb == NULL)
return NULL;
-#ifdef __APPLE__
- pthread_mutex_lock(rdrb->lock);
-#else
- if (pthread_mutex_lock(rdrb->lock) == EOWNERDEAD) {
- LOG_DBGF("Recovering dead mutex.");
- pthread_mutex_consistent(rdrb->lock);
- }
-#endif
- sdb = idx_to_du_buff_ptr(rdrb, idx);
-
if (sdb->du_tail + size >= sdb->size) {
- pthread_mutex_unlock(rdrb->lock);
- LOG_DBGF("Failed to allocate PCI tailspace.");
+ LOG_ERR("Failed to allocate PCI tailspace.");
return NULL;
}
@@ -761,78 +743,37 @@ uint8_t * shm_du_buff_tail_alloc(struct shm_rdrbuff * rdrb,
sdb->du_tail += size;
- pthread_mutex_unlock(rdrb->lock);
-
return buf;
}
-int shm_du_buff_head_release(struct shm_rdrbuff * rdrb,
- ssize_t idx,
+int shm_du_buff_head_release(struct shm_du_buff * sdb,
size_t size)
{
- struct shm_du_buff * sdb;
-
- if (rdrb == NULL)
- return -1;
-
- if (idx < 0 || idx > SHM_BUFFER_SIZE)
+ if (sdb == NULL)
return -1;
-#ifdef __APPLE__
- pthread_mutex_lock(rdrb->lock);
-#else
- if (pthread_mutex_lock(rdrb->lock) == EOWNERDEAD) {
- LOG_DBGF("Recovering dead mutex.");
- pthread_mutex_consistent(rdrb->lock);
- }
-#endif
-
- sdb = idx_to_du_buff_ptr(rdrb, idx);
-
if (size > sdb->du_tail - sdb->du_head) {
- pthread_mutex_unlock(rdrb->lock);
- LOG_DBGF("Tried to release beyond sdu boundary.");
+ LOG_DBGF("Tried to release beyond SDU boundary.");
return -EOVERFLOW;
}
sdb->du_head += size;
- pthread_mutex_unlock(rdrb->lock);
-
return 0;
}
-int shm_du_buff_tail_release(struct shm_rdrbuff * rdrb,
- ssize_t idx,
+int shm_du_buff_tail_release(struct shm_du_buff * sdb,
size_t size)
{
- struct shm_du_buff * sdb;
-
- if (rdrb == NULL)
- return -1;
-
- if (idx < 0 || idx > SHM_BUFFER_SIZE)
+ if (sdb == NULL)
return -1;
-#ifdef __APPLE__
- pthread_mutex_lock(rdrb->lock);
-#else
- if (pthread_mutex_lock(rdrb->lock) == EOWNERDEAD) {
- LOG_DBGF("Recovering dead mutex.");
- pthread_mutex_consistent(rdrb->lock);
- }
-#endif
- sdb = idx_to_du_buff_ptr(rdrb, idx);
-
if (size > sdb->du_tail - sdb->du_head) {
- pthread_mutex_unlock(rdrb->lock);
- LOG_DBGF("Tried to release beyond sdu boundary.");
+ LOG_ERR("Tried to release beyond SDU boundary.");
return -EOVERFLOW;
}
sdb->du_tail -= size;
- pthread_mutex_unlock(rdrb->lock);
-
return 0;
}