diff options
author | Dimitri Staessens <[email protected]> | 2016-02-26 15:34:47 +0100 |
---|---|---|
committer | Dimitri Staessens <[email protected]> | 2016-02-26 15:34:47 +0100 |
commit | 63054ef2da3e49bc36a7facb9539c98c031c56c8 (patch) | |
tree | 1fd8007e4c38b621902adae3197b15433530c5be | |
parent | 90740422f230ad064972c0f5b45b6c7f7190efb4 (diff) | |
download | ouroboros-63054ef2da3e49bc36a7facb9539c98c031c56c8.tar.gz ouroboros-63054ef2da3e49bc36a7facb9539c98c031c56c8.zip |
ipcp: Addresses comments on 62eba34
-rw-r--r-- | include/ouroboros/common.h | 2 | ||||
-rw-r--r-- | src/ipcpd/pci.c | 47 | ||||
-rw-r--r-- | src/ipcpd/pci.h | 4 |
3 files changed, 24 insertions, 29 deletions
diff --git a/include/ouroboros/common.h b/include/ouroboros/common.h index a18a8548..36f6171c 100644 --- a/include/ouroboros/common.h +++ b/include/ouroboros/common.h @@ -67,6 +67,8 @@ struct dif_info { /* values, octets */ uint32_t min_pdu_size; uint32_t max_pdu_size; + + struct dt_const dtc; }; #endif /* OUROBOROS_COMMON_H */ diff --git a/src/ipcpd/pci.c b/src/ipcpd/pci.c index 1fd263d3..d4ef9033 100644 --- a/src/ipcpd/pci.c +++ b/src/ipcpd/pci.c @@ -25,13 +25,13 @@ #include <malloc.h> #include <errno.h> -#define head_size(a, b) a.addr_size * 2 + \ +#define HEAD_SIZE(a, b) a.addr_size * 2 + \ a.cep_id_size * 2 + \ a.pdu_length_size + \ a.seqno_size + \ a.qos_id_size + \ b.ttl_size -#define tail_size(b) b.chk_size +#define TAIL_SIZE(b) b.chk_size struct pci { @@ -41,7 +41,8 @@ struct pci { uint8_t * dst_cep_id; uint8_t * src_cep_id; uint8_t * pdu_length; - uint8_t * ttl; uint8_t * seqno; + uint8_t * ttl; + uint8_t * seqno; uint8_t * qos_id; uint8_t * chk; @@ -53,9 +54,9 @@ struct pci { }; -pci_t * pci_create(du_buff_t * dub, - const struct ipcp_dtp_const dtpc, - const struct ipcp_dup_const dupc) +pci_t * pci_create(du_buff_t * dub, + const struct ipcp_dtp_const * dtpc, + const struct ipcp_dup_const * dupc) { if (dub == NULL) { @@ -69,34 +70,26 @@ pci_t * pci_create(du_buff_t * dub, return NULL; p->dub = dub; -/* - p->dtpc = malloc( sizeof *(p->dtpc)); - if (p->dtpc == NULL) - return NULL; - p->dupc = malloc( sizeof *(p->dupc)); - if (p->dupc == NULL) - return NULL; -*/ - p->dtpc = dtpc; - p->dupc = dupc; + p->dtpc = *dtpc; + p->dupc = *dupc; - p->dst_addr = NULL; - p->src_addr =NULL; + p->dst_addr = NULL; + p->src_addr = NULL; p->dst_cep_id = NULL; p->src_cep_id = NULL; p->pdu_length = NULL; - p->ttl = NULL; - p->seqno = NULL; - p->qos_id = NULL; - p->chk = NULL; + p->ttl = NULL; + p->seqno = NULL; + p->qos_id = NULL; + p->chk = NULL; return p; } void pci_destroy(pci_t * pci) { - free (pci); + free(pci); } int pci_init(pci_t * pci) @@ -107,8 +100,8 @@ int pci_init(pci_t * pci) } uint8_t * pci_head = du_buff_head_alloc(pci->dub, - head_size(pci->dtpc,pci->dupc)); - uint8_t * pci_tail = du_buff_tail_alloc(pci->dub, tail_size(pci->dupc)); + HEAD_SIZE(pci->dtpc,pci->dupc)); + uint8_t * pci_tail = du_buff_tail_alloc(pci->dub, TAIL_SIZE(pci->dupc)); if (pci_head == NULL) { LOG_DBG("Failed to allocate space for PCI at head."); @@ -142,6 +135,6 @@ void pci_release(pci_t * pci) if (pci->dub == NULL) return; - du_buff_head_release(pci->dub, head_size(pci->dtpc, pci->dupc)); - du_buff_tail_release(pci->dub, tail_size(pci->dupc)); + du_buff_head_release(pci->dub, HEAD_SIZE(pci->dtpc, pci->dupc)); + du_buff_tail_release(pci->dub, TAIL_SIZE(pci->dupc)); } diff --git a/src/ipcpd/pci.h b/src/ipcpd/pci.h index 5b11a021..c7095bbd 100644 --- a/src/ipcpd/pci.h +++ b/src/ipcpd/pci.h @@ -35,8 +35,8 @@ struct pci; typedef struct pci pci_t; pci_t * pci_create(du_buff_t * dub, - const struct ipcp_dtp_const dtpc, - const struct ipcp_dup_const dupc); + const struct ipcp_dtp_const * dtpc, + const struct ipcp_dup_const * dupc); void pci_destroy(pci_t * pci); int pci_init(pci_t * pci); |