From 4424cf627d0bb45b65128ccfd8f2a7e5739b3917 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 26 Feb 2016 03:58:37 +0100 Subject: ipcps: initial code for pci structure --- src/ipcpd/pci.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ipcpd/pci.h | 45 ++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 src/ipcpd/pci.c create mode 100644 src/ipcpd/pci.h diff --git a/src/ipcpd/pci.c b/src/ipcpd/pci.c new file mode 100644 index 00000000..1987957a --- /dev/null +++ b/src/ipcpd/pci.c @@ -0,0 +1,98 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * Protocol Control Information + * + * Dimitri Staessens + * Sander Vrijders + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +struct pci { + uint8_t * src_addr; + uint8_t * dst_addr; + uint8_t * pdu_length; + uint8_t * qos_id; + uint8_t * seqnr; + uint8_t * pad_h; + uint8_t * pad_t; + + uint8_t head_sz; + uint8_t tail_sz; + +}; + +pci_t * pci_create(struct dtp_const * dtc) +{ + int i = 0; + + if (dtc == NULL) + return NULL; + + struct pci * p = malloc(sizeof pci); + + if (p == NULL) + return NULL: + + p->src_addr =NULL; + p->dst_addr = NULL; + p->pdu_length = NULL; + p->qos_id = NULL; + p->seqnr = NULL; + p->pad_h = NULL; + p->pad_t = NULL; + + head_sz = 0; + tail_sz = 0; + + return p; +} + +/* policy... one could reorder the data fields + exercise left to the idiot that cares */ +int * pci_init(pci_t * pci, + d_buff_t * dub, + struct dtp_const * dtc, + struct dup_const * dupc) +{ + uint8_t * pci_head; + uint8_t * pci_tail; + + /* nastiness ahead, all members are uint8_t's */ + uint8_t * n = (uint8_t *) dtc; + for (i=0; i < sizeof *dtc; ++i) + n[i] & 0x80 ? tail_sz += n[i] & 0x80: + head_sz += n[i]; + head_sz += n[0] & 0x80 ? n[0] : 0; /* dst_addr */ + + n = (uint8_t *) dupc; + for (i=0; i < sizeof *dupc; ++i) + n[i] & 0x80 ? tail_sz += n[i] & 0x80 : + head_sz += n[i]; + tail_sz += n[0] & 0x80 ? n[0] : 0; /* dst_addr */ + + /* end of nastiness */ + + pci_head = du_buff_head_alloc(dub, head_sz); + pci_tail = du_buff_tail_alloc(dub, tail_sz); + + LOG_MISSING(); +} + +void pci_destroy(pci_t * pci) +{ + free (pci); +} diff --git a/src/ipcpd/pci.h b/src/ipcpd/pci.h new file mode 100644 index 00000000..936a1b1b --- /dev/null +++ b/src/ipcpd/pci.h @@ -0,0 +1,45 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * Protocol Control Information + * + * Dimitri Staessens + * Sander Vrijders + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef OUROBOROS_IPCP_PCI_H +#define OUROBOROS_IPCP_PCI_H +#endif + +#include "ouroboros/common.h" +#include "ouroboros/du_buff.h" + +struct pci; + +typedef struct pci pci_t; + +pci_t * pci_create(struct dtp_const * dtc); +void pci_destroy(pci_t * pci); + +int pci_init(pci_t * pci, + du_buff_t * dub, + struct dtp_const * dtc, + struct dup_const * dupc); + +int pci_release(du_buff_t dub); + +#endif /* OUROBOROS_IPCP_PCI_H */ -- cgit v1.2.3 From b1d605781449aaa7c32b28e0b3466deaec3c576f Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 26 Feb 2016 04:00:18 +0100 Subject: include: added data transfer constants to common.h dt_const contains data transfer constants dup_const contains constants for du protection --- include/ouroboros/common.h | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/include/ouroboros/common.h b/include/ouroboros/common.h index 09900a1f..d1ddddfa 100644 --- a/include/ouroboros/common.h +++ b/include/ouroboros/common.h @@ -38,22 +38,48 @@ typedef struct { typedef struct { char * ap_name; - int api_id; + int api_id; char * ae_name; - int aei_id; + int aei_id; } rina_name_t; /* FIXME: To be extended to have all QoS params */ struct qos_spec { - char * name; - char * dif_name; - double delay; - double jitter; + uint32_t delay; + uint32_t jitter; + +}; + +struct dtp_const { + /* pci field lengths, bits */ + /* most significant bit indicates head (0) or tail (1) */ + uint8_t addr_sz; + uint8_t cep_id_sz; + uint8_t pdu_length_sz; + /* not sure about port_id_sz... port_id's are not + part of dtp and should not go on the wire */ + /* uint8_t port_id_sz; */ + uint8_t qos_id_sz; + uint8_t seqnr_sz; + /* uint8_t ctrl_sqnum_sz; is this crap in the spec?? */ + + /* one will need this for hardware alignment */ + uint8_t pad_head_sz; + uint8_t pad_tail_sz; +}; + +struct dup_const { + /* pci field lengths, bits */ + /* most significant bit indicates head (0) or tail (1) */ + uint8_t ttl_sz; + uint8_t chk_sz; }; /* FIXME: What should be configurable in the DIF? */ struct dif_info { - int cep_id_size; + /* values, octets */ + uint32_t min_pdu_sz; + uint32_t max_pdu_sz; }; #endif -- cgit v1.2.3 From 66c25ea6e07852522430acfcd37a3a98abf6ac9e Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 26 Feb 2016 12:24:12 +0100 Subject: include: Updated common.h various fixes based on discussion on bitbucket --- include/ouroboros/common.h | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/include/ouroboros/common.h b/include/ouroboros/common.h index d1ddddfa..c416df97 100644 --- a/include/ouroboros/common.h +++ b/include/ouroboros/common.h @@ -47,39 +47,27 @@ typedef struct { struct qos_spec { uint32_t delay; uint32_t jitter; - }; -struct dtp_const { - /* pci field lengths, bits */ - /* most significant bit indicates head (0) or tail (1) */ - uint8_t addr_sz; - uint8_t cep_id_sz; - uint8_t pdu_length_sz; - /* not sure about port_id_sz... port_id's are not - part of dtp and should not go on the wire */ - /* uint8_t port_id_sz; */ - uint8_t qos_id_sz; - uint8_t seqnr_sz; - /* uint8_t ctrl_sqnum_sz; is this crap in the spec?? */ - - /* one will need this for hardware alignment */ - uint8_t pad_head_sz; - uint8_t pad_tail_sz; -}; +struct dt_const { + /* constants for dtp */ + uint8_t addr_size; + uint8_t cep_id_size; + uint8_t pdu_length_size; + uint8_t qos_id_size; + uint8_t seqno_size; + /* uint8_t ctrl_sqnum_sz; is this in the spec?? */ -struct dup_const { - /* pci field lengths, bits */ - /* most significant bit indicates head (0) or tail (1) */ - uint8_t ttl_sz; - uint8_t chk_sz; + /* constants for dup */ + uint8_t ttl_size; + uint8_t chk_size; }; /* FIXME: What should be configurable in the DIF? */ struct dif_info { /* values, octets */ - uint32_t min_pdu_sz; - uint32_t max_pdu_sz; + uint32_t min_pdu_size; + uint32_t max_pdu_size; }; -#endif +#endif /* OUROBOROS_COMMON_H */ -- cgit v1.2.3 From 80da69bbed02a727abf18808c5addc6a3e17a213 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 26 Feb 2016 12:27:50 +0100 Subject: includ: Updated comment in common.h Now explains the size values are in bits as this comment was accidentally removed --- include/ouroboros/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ouroboros/common.h b/include/ouroboros/common.h index c416df97..a5140c16 100644 --- a/include/ouroboros/common.h +++ b/include/ouroboros/common.h @@ -50,7 +50,7 @@ struct qos_spec { }; struct dt_const { - /* constants for dtp */ + /* dt field sizes in bits */ uint8_t addr_size; uint8_t cep_id_size; uint8_t pdu_length_size; -- cgit v1.2.3 From 7fe7ee2b190128cadee38664c59a595fac1fd3b1 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 26 Feb 2016 14:35:10 +0100 Subject: include: changed dt constants sizes back to bytes --- include/ouroboros/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ouroboros/common.h b/include/ouroboros/common.h index a5140c16..ed55a06c 100644 --- a/include/ouroboros/common.h +++ b/include/ouroboros/common.h @@ -50,7 +50,7 @@ struct qos_spec { }; struct dt_const { - /* dt field sizes in bits */ + /* dt field sizes in octets */ uint8_t addr_size; uint8_t cep_id_size; uint8_t pdu_length_size; -- cgit v1.2.3 From 62eba345ce0ab3fb58e6998261da20bbc2f5cc3a Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 26 Feb 2016 14:35:50 +0100 Subject: ipcp: PCI structure ipcpd/dt_const.h: ipcp-internal datastructures for dtp and dip constants ipcpd/pci.h : header for pci structure ipcpd/pci.c : pci structure ipcpd : updated makefile commit not fully tested yet --- src/ipcpd/CMakeLists.txt | 1 + src/ipcpd/pci.c | 143 +++++++++++++++++++++++++++++++---------------- src/ipcpd/pci.h | 18 +++--- 3 files changed, 106 insertions(+), 56 deletions(-) diff --git a/src/ipcpd/CMakeLists.txt b/src/ipcpd/CMakeLists.txt index b16413cc..00ace9d5 100644 --- a/src/ipcpd/CMakeLists.txt +++ b/src/ipcpd/CMakeLists.txt @@ -7,6 +7,7 @@ include_directories(${CMAKE_BINARY_DIR}/include) set(SOURCE_FILES # Add source files here main.c + pci.c ) add_executable (ipcpd ${SOURCE_FILES}) diff --git a/src/ipcpd/pci.c b/src/ipcpd/pci.c index 1987957a..1fd263d3 100644 --- a/src/ipcpd/pci.c +++ b/src/ipcpd/pci.c @@ -21,78 +21,127 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "pci.h" +#include +#include + +#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 + + struct pci { - uint8_t * src_addr; + /* head */ uint8_t * dst_addr; + uint8_t * src_addr; + uint8_t * dst_cep_id; + uint8_t * src_cep_id; uint8_t * pdu_length; + uint8_t * ttl; uint8_t * seqno; uint8_t * qos_id; - uint8_t * seqnr; - uint8_t * pad_h; - uint8_t * pad_t; - uint8_t head_sz; - uint8_t tail_sz; + uint8_t * chk; + + du_buff_t * dub; + + struct ipcp_dtp_const dtpc; + struct ipcp_dup_const dupc; }; -pci_t * pci_create(struct dtp_const * dtc) +pci_t * pci_create(du_buff_t * dub, + const struct ipcp_dtp_const dtpc, + const struct ipcp_dup_const dupc) { - int i = 0; - if (dtc == NULL) + if (dub == NULL) { + LOG_DBGF("Bogus input. Bugging out."); return NULL; + } - struct pci * p = malloc(sizeof pci); + struct pci * p = malloc(sizeof *p); if (p == NULL) - return NULL: + 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->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->seqnr = NULL; - p->pad_h = NULL; - p->pad_t = NULL; - - head_sz = 0; - tail_sz = 0; + p->chk = NULL; return p; } -/* policy... one could reorder the data fields - exercise left to the idiot that cares */ -int * pci_init(pci_t * pci, - d_buff_t * dub, - struct dtp_const * dtc, - struct dup_const * dupc) +void pci_destroy(pci_t * pci) { - uint8_t * pci_head; - uint8_t * pci_tail; - - /* nastiness ahead, all members are uint8_t's */ - uint8_t * n = (uint8_t *) dtc; - for (i=0; i < sizeof *dtc; ++i) - n[i] & 0x80 ? tail_sz += n[i] & 0x80: - head_sz += n[i]; - head_sz += n[0] & 0x80 ? n[0] : 0; /* dst_addr */ - - n = (uint8_t *) dupc; - for (i=0; i < sizeof *dupc; ++i) - n[i] & 0x80 ? tail_sz += n[i] & 0x80 : - head_sz += n[i]; - tail_sz += n[0] & 0x80 ? n[0] : 0; /* dst_addr */ - - /* end of nastiness */ - - pci_head = du_buff_head_alloc(dub, head_sz); - pci_tail = du_buff_tail_alloc(dub, tail_sz); + free (pci); +} - LOG_MISSING(); +int pci_init(pci_t * pci) +{ + if (pci == NULL) { + LOG_DBGF("Bogus input. Bugging out."); + return -EINVAL; + } + + 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)); + + if (pci_head == NULL) { + LOG_DBG("Failed to allocate space for PCI at head."); + return -ENOBUFS; + } + + if (pci_tail == NULL) { + LOG_DBG("Failed to allocate space for PCI at tail."); + return -ENOBUFS; + } + + pci->dst_addr = pci_head; + pci->src_addr = (pci_head += pci->dtpc.addr_size); + pci->dst_cep_id = (pci_head += pci->dtpc.addr_size); + pci->src_cep_id = (pci_head += pci->dtpc.cep_id_size); + pci->pdu_length = (pci_head += pci->dtpc.cep_id_size); + pci->ttl = (pci_head += pci->dtpc.pdu_length_size); + pci->seqno = (pci_head += pci->dupc.ttl_size); + pci->qos_id = (pci_head += pci->dtpc.seqno_size); + + pci->chk = (pci_tail); + + return 0; } -void pci_destroy(pci_t * pci) +void pci_release(pci_t * pci) { - free (pci); + if (pci == NULL) + return; + + 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)); } diff --git a/src/ipcpd/pci.h b/src/ipcpd/pci.h index 936a1b1b..5b11a021 100644 --- a/src/ipcpd/pci.h +++ b/src/ipcpd/pci.h @@ -23,23 +23,23 @@ #ifndef OUROBOROS_IPCP_PCI_H #define OUROBOROS_IPCP_PCI_H -#endif -#include "ouroboros/common.h" +#define OUROBOROS_PREFIX "ipcp/pci" + #include "ouroboros/du_buff.h" +#include "ouroboros/logs.h" +#include "dt_const.h" struct pci; typedef struct pci pci_t; -pci_t * pci_create(struct dtp_const * dtc); +pci_t * pci_create(du_buff_t * dub, + const struct ipcp_dtp_const dtpc, + const struct ipcp_dup_const dupc); void pci_destroy(pci_t * pci); -int pci_init(pci_t * pci, - du_buff_t * dub, - struct dtp_const * dtc, - struct dup_const * dupc); - -int pci_release(du_buff_t dub); +int pci_init(pci_t * pci); +void pci_release(pci_t * pci); #endif /* OUROBOROS_IPCP_PCI_H */ -- cgit v1.2.3 From 63054ef2da3e49bc36a7facb9539c98c031c56c8 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 26 Feb 2016 15:34:47 +0100 Subject: ipcp: Addresses comments on 62eba34 --- include/ouroboros/common.h | 2 ++ src/ipcpd/pci.c | 47 ++++++++++++++++++++-------------------------- 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 #include -#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); -- cgit v1.2.3 From b08723425e76eafcdb88e501410c910e3c7bd2c0 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 26 Feb 2016 16:57:49 +0100 Subject: ipcpd: Fixes in pci.c HEAD_SIZE and TAIL_SIZE renamed PCI_HEAD_SIZE and PCI_TAIL_SIZE broke up a mixed definition and assignment --- src/ipcpd/pci.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/ipcpd/pci.c b/src/ipcpd/pci.c index d4ef9033..19c42e53 100644 --- a/src/ipcpd/pci.c +++ b/src/ipcpd/pci.c @@ -25,13 +25,13 @@ #include #include -#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 PCI_HEAD_SIZE(a, b) a.addr_size * 2 + \ + a.cep_id_size * 2 + \ + a.pdu_length_size + \ + b.ttl_size + \ + a.seqno_size + \ + a.qos_id_size +#define PCI_TAIL_SIZE(b) b.chk_size struct pci { @@ -58,13 +58,14 @@ pci_t * pci_create(du_buff_t * dub, const struct ipcp_dtp_const * dtpc, const struct ipcp_dup_const * dupc) { + struct pci * p; if (dub == NULL) { LOG_DBGF("Bogus input. Bugging out."); return NULL; } - struct pci * p = malloc(sizeof *p); + p = malloc(sizeof *p); if (p == NULL) return NULL; @@ -99,9 +100,10 @@ int pci_init(pci_t * pci) return -EINVAL; } - 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)); + uint8_t * pci_head = du_buff_head_alloc(pci->dub, PCI_HEAD_SIZE( + pci->dtpc,pci->dupc)); + uint8_t * pci_tail = du_buff_tail_alloc(pci->dub, PCI_TAIL_SIZE( + pci->dupc)); if (pci_head == NULL) { LOG_DBG("Failed to allocate space for PCI at head."); @@ -135,6 +137,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, PCI_HEAD_SIZE(pci->dtpc, pci->dupc)); + du_buff_tail_release(pci->dub, PCI_TAIL_SIZE(pci->dupc)); } -- cgit v1.2.3 From c5413eb544851530eb0436d3e04df54c603b7d12 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 26 Feb 2016 17:01:36 +0100 Subject: ipcpd: Added dt_const.h forgot to add the dt_const.h file in my previous commits. this completes the pull request --- src/ipcpd/dt_const.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/ipcpd/dt_const.h diff --git a/src/ipcpd/dt_const.h b/src/ipcpd/dt_const.h new file mode 100644 index 00000000..bc0c1466 --- /dev/null +++ b/src/ipcpd/dt_const.h @@ -0,0 +1,44 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * Data Transfer Constants for the IPCP + * + * Dimitri Staessens + * Sander Vrijders + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef IPCP_DT_CONST_H +#define IPCP_DT_CONST_H + +#include "ouroboros/common.h" + +struct ipcp_dtp_const { + /* sizes in octets */ + uint8_t addr_size; + uint8_t cep_id_size; + uint8_t pdu_length_size; + uint8_t seqno_size; + uint8_t qos_id_size; + /* uint8_t ctrl_sqnum_sz; is this in the spec?? */ +}; + +struct ipcp_dup_const { + uint8_t ttl_size; + uint8_t chk_size; +}; + +#endif /* IPCP_DT_CONST_H */ -- cgit v1.2.3