diff --git a/os/net/mac/tsch/sixtop/sixp-nbr.c b/os/net/mac/tsch/sixtop/sixp-nbr.c index 2419f2484..f56206637 100644 --- a/os/net/mac/tsch/sixtop/sixp-nbr.c +++ b/os/net/mac/tsch/sixtop/sixp-nbr.c @@ -59,38 +59,11 @@ typedef struct sixp_nbr { struct sixp_nbr *next; linkaddr_t addr; uint8_t next_seqno; - uint8_t gtx; - uint8_t grx; + uint8_t gen; } sixp_nbr_t; -static int advance_generation_counter(uint8_t *gc); - NBR_TABLE(sixp_nbr_t, sixp_nbrs); -/*---------------------------------------------------------------------------*/ -static int -advance_generation_counter(uint8_t *gc) -{ - assert(gc != NULL); - if(gc == NULL) { - return -1; - } - switch(*gc) { - case 0x00: - case 0x02: - *gc = 0x01; - break; - case 0x01: - *gc = 0x02; - break; - default: - /* unexpected condition */ - PRINTF("6P-nbr: advance_generation_counter() has unexpected gc %02x\n", - *gc); - return -1; - } - return 0; -} /*---------------------------------------------------------------------------*/ sixp_nbr_t * sixp_nbr_find(const linkaddr_t *addr) @@ -130,8 +103,7 @@ sixp_nbr_alloc(const linkaddr_t *addr) linkaddr_copy(&nbr->addr, addr); nbr->next_seqno = SIXP_INITIAL_SEQUENCE_NUMBER; - nbr->gtx = 0; - nbr->grx = 0; + nbr->gen = 0; return nbr; } @@ -146,47 +118,36 @@ sixp_nbr_free(sixp_nbr_t *nbr) } /*---------------------------------------------------------------------------*/ int16_t -sixp_nbr_get_gtx(sixp_nbr_t *nbr) +sixp_nbr_get_gen(sixp_nbr_t *nbr) { assert(nbr != NULL); if(nbr == NULL) { PRINTF("6P-nbr: sixp_nbr_get_gtx() fails because of invalid argument\n"); return -1; } - return nbr->gtx; -} -/*---------------------------------------------------------------------------*/ -int8_t -sixp_nbr_get_grx(sixp_nbr_t *nbr) -{ - assert(nbr != NULL); - if(nbr == NULL) { - PRINTF("6P-nbr: sixp_nbr_get_grx() fails because of invalid argument\n"); - return -1; - } - return nbr->grx; + return nbr->gen; } /*---------------------------------------------------------------------------*/ int -sixp_nbr_advance_gtx(sixp_nbr_t *nbr) +sixp_nbr_advance_gen(sixp_nbr_t *nbr) { assert(nbr != NULL); if(nbr == NULL) { - PRINTF("6P-nbr: sixp_nbr_advance_gtx() fails because of invalid arg\n"); + PRINTF("6P-nbr: sixp_nbr_advance_gen() fails because of invalid arg\n"); return -1; } - return advance_generation_counter(&nbr->gtx); -} -/*---------------------------------------------------------------------------*/ -int -sixp_nbr_advance_grx(sixp_nbr_t *nbr) -{ - assert(nbr != NULL); - if(nbr == NULL) { - PRINTF("6P-nbr: sixp_nbr_advance_grx() fails because of invalid arg\n"); + + if(nbr->gen == 0x00 || nbr->gen == 0x09) { + nbr->gen = 0x01; + } else if(nbr->gen < 0x09) { + nbr->gen++; + } else { + /* unexpected condition */ + PRINTF("6P-nbr: nbr %p has an invalid generation number %02x\n", + nbr, nbr->gen); return -1; } - return advance_generation_counter(&nbr->grx); + return 0; } /*---------------------------------------------------------------------------*/ int diff --git a/os/net/mac/tsch/sixtop/sixp-nbr.h b/os/net/mac/tsch/sixtop/sixp-nbr.h index 4b5cbeb2e..739f35c9f 100644 --- a/os/net/mac/tsch/sixtop/sixp-nbr.h +++ b/os/net/mac/tsch/sixtop/sixp-nbr.h @@ -63,33 +63,18 @@ sixp_nbr_t *sixp_nbr_alloc(const linkaddr_t *addr); void sixp_nbr_free(sixp_nbr_t *nbr); /** - * \brief Return GTX of a neighbor + * \brief Return GEN (Generation Number) of a neighbor * \param nbr The pointer to a neighbor - * \return A value of GTX, -1 on failure + * \return A value of GEN, -1 on failure */ -int16_t sixp_nbr_get_gtx(sixp_nbr_t *nbr); - -/** - * \brief Return GRX of a neighbor - * \param nbr The pointer to a neighbor - * \return A value of GRX - */ -int16_t sixp_nbr_get_grx(sixp_nbr_t *nbr); +int16_t sixp_nbr_get_gen(sixp_nbr_t *nbr); /** * \brief Advance GTX of a neighbor * \param nbr The pointer to a neighbor * \return 0 on success, -1 on failure */ -int sixp_nbr_advance_gtx(sixp_nbr_t *nbr); - -/** - * \brief Advance GRX of a neighbor - * \param nbr The pointer to a neighbor - * \return 0 on success, -1 on failure - */ -int sixp_nbr_advance_grx(sixp_nbr_t *nbr); - +int sixp_nbr_advance_gen(sixp_nbr_t *nbr); /** * \brief Get the next sequence number of a neighbor diff --git a/os/net/mac/tsch/sixtop/sixp-pkt.c b/os/net/mac/tsch/sixtop/sixp-pkt.c index 8d01f372a..5374290a0 100644 --- a/os/net/mac/tsch/sixtop/sixp-pkt.c +++ b/os/net/mac/tsch/sixtop/sixp-pkt.c @@ -61,6 +61,11 @@ static int32_t get_offset_offset(sixp_pkt_type_t type, sixp_pkt_code_t code); static int32_t get_max_num_cells_offset(sixp_pkt_type_t type, sixp_pkt_code_t code); static int32_t get_cell_list_offset(sixp_pkt_type_t type, sixp_pkt_code_t code); +static int32_t get_rel_cell_list_offset(sixp_pkt_type_t type, + sixp_pkt_code_t code); +static int32_t get_total_num_cells_offset(sixp_pkt_type_t type, + sixp_pkt_code_t code); + /*---------------------------------------------------------------------------*/ static int32_t get_metadata_offset(sixp_pkt_type_t type, sixp_pkt_code_t code) @@ -77,7 +82,8 @@ get_cell_options_offset(sixp_pkt_type_t type, sixp_pkt_code_t code) if(type == SIXP_PKT_TYPE_REQUEST && (code.cmd == SIXP_PKT_CMD_ADD || code.cmd == SIXP_PKT_CMD_DELETE || - code.cmd == SIXP_PKT_CMD_STATUS || + code.cmd == SIXP_PKT_CMD_RELOCATE || + code.cmd == SIXP_PKT_CMD_COUNT || code.cmd == SIXP_PKT_CMD_LIST)) { return sizeof(sixp_pkt_metadata_t); } @@ -88,11 +94,10 @@ static int32_t get_num_cells_offset(sixp_pkt_type_t type, sixp_pkt_code_t code) { if(type == SIXP_PKT_TYPE_REQUEST && - (code.value == SIXP_PKT_CMD_ADD || code.value == SIXP_PKT_CMD_DELETE)) { + (code.value == SIXP_PKT_CMD_ADD || + code.value == SIXP_PKT_CMD_DELETE || + code.value == SIXP_PKT_CMD_RELOCATE)) { return sizeof(sixp_pkt_metadata_t) + sizeof(sixp_pkt_cell_options_t); - } else if(type == SIXP_PKT_TYPE_RESPONSE && - code.value == SIXP_PKT_RC_SUCCESS) { - return 0; } return -1; @@ -143,13 +148,33 @@ get_cell_list_offset(sixp_pkt_type_t type, sixp_pkt_code_t code) sizeof(sixp_pkt_num_cells_t)); } else if((type == SIXP_PKT_TYPE_RESPONSE || type == SIXP_PKT_TYPE_CONFIRMATION) && - code.value == SIXP_PKT_RC_SUCCESS) { + (code.value == SIXP_PKT_RC_SUCCESS || + code.value == SIXP_PKT_RC_EOL)) { return 0; } return -1; } /*---------------------------------------------------------------------------*/ -int +static int32_t +get_rel_cell_list_offset(sixp_pkt_type_t type, sixp_pkt_code_t code) +{ + if(type == SIXP_PKT_TYPE_REQUEST && code.value == SIXP_PKT_CMD_RELOCATE) { + return (sizeof(sixp_pkt_metadata_t) + + sizeof(sixp_pkt_cell_options_t) + + sizeof(sixp_pkt_num_cells_t)); + } + return -1; +} +/*---------------------------------------------------------------------------*/ +static int32_t +get_total_num_cells_offset(sixp_pkt_type_t type, sixp_pkt_code_t code) +{ + if(type == SIXP_PKT_TYPE_RESPONSE && code.value == SIXP_PKT_RC_SUCCESS) { + return 0; + } + return -1; +} +/*---------------------------------------------------------------------------*/int sixp_pkt_set_metadata(sixp_pkt_type_t type, sixp_pkt_code_t code, sixp_pkt_metadata_t metadata, uint8_t *body, uint16_t body_len) @@ -294,13 +319,7 @@ sixp_pkt_set_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code, return -1; } - if(body_len < (offset + sizeof(num_cells))) { - PRINTF("6P-pkt: cannot set num_cells; body is too short\n"); - return -1; - } - - /* NumCells is an 8-bit unsigned integer */ - memcpy(body + offset, &num_cells, sizeof(num_cells)); + memcpy(body + offset, &num_cells, sizeof(uint8_t)); return 0; } @@ -549,7 +568,7 @@ sixp_pkt_set_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code, return -1; } - offset += cell_offset * sizeof(sixp_pkt_cell_t); + offset += cell_offset; if(body_len < (offset + cell_list_len)) { PRINTF("6P-pkt: cannot set cell_list; body is too short\n"); @@ -560,6 +579,7 @@ sixp_pkt_set_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code, } memcpy(body + offset, cell_list, cell_list_len); + return 0; } /*---------------------------------------------------------------------------*/ @@ -572,7 +592,7 @@ sixp_pkt_get_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code, int32_t offset; if(cell_list_len == NULL || body == NULL) { - PRINTF("6P-pkt: cannot get cell_list; invalid argument\n"); + PRINTF("6P-pkt: cannot get cell_list\n"); return -1; } @@ -596,6 +616,242 @@ sixp_pkt_get_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code, } *cell_list_len = body_len - offset; + + return 0; +} +/*---------------------------------------------------------------------------*/ +int +sixp_pkt_set_rel_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code, + const uint8_t *rel_cell_list, + uint16_t rel_cell_list_len, + uint16_t cell_offset, + uint8_t *body, uint16_t body_len) +{ + int32_t offset; + sixp_pkt_num_cells_t num_cells; + + if(rel_cell_list == NULL || body == NULL) { + PRINTF("6P-pkt: cannot set rel_cell_list; invalid argument\n"); + return -1; + } + + if(sixp_pkt_get_num_cells(type, code, &num_cells, body, body_len) < 0) { + PRINTF("6P-pkt: cannot set rel_cell_list; no NumCells field\n"); + return -1; + } + + if((offset = get_rel_cell_list_offset(type, code)) < 0) { + PRINTF("6P-pkt: cannot set rel_cell_list; "); + PRINTF("packet [type=%u, code=%u] won't have RelCellList\n", + type, code.value); + return -1; + } + + offset += cell_offset; + + if(body_len < (offset + rel_cell_list_len)) { + PRINTF("6P-pkt: cannot set rel_cell_list; body is too short\n"); + return -1; + } else if((offset + rel_cell_list_len) > + (offset + num_cells * sizeof(sixp_pkt_cell_t))) { + PRINTF("6P-pkt: cannot set rel_cell_list; RelCellList is too long\n"); + return -1; + } else if((rel_cell_list_len % sizeof(sixp_pkt_cell_t)) != 0) { + PRINTF("6P-pkt: cannot set rel_cell_list; invalid body_len\n"); + return -1; + } + + memcpy(body + offset, rel_cell_list, rel_cell_list_len); + + return 0; +} +/*---------------------------------------------------------------------------*/ +int +sixp_pkt_get_rel_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code, + const uint8_t **rel_cell_list, + sixp_pkt_offset_t *rel_cell_list_len, + const uint8_t *body, uint16_t body_len) +{ + int32_t offset; + sixp_pkt_num_cells_t num_cells; + + if(rel_cell_list_len == NULL || body == NULL) { + PRINTF("6P-pkt: cannot get rel_cell_list; invalid argument\n"); + return -1; + } + + if(sixp_pkt_get_num_cells(type, code, &num_cells, body, body_len) < 0) { + PRINTF("6P-pkt: cannot get rel_cell_list; no NumCells field\n"); + return -1; + } + + if((offset = get_rel_cell_list_offset(type, code)) < 0) { + PRINTF("6P-pkt: cannot get rel_cell_list; "); + PRINTF("packet [type=%u, code=%u] won't have RelCellList\n", + type, code.value); + return -1; + } + + if(body_len < (offset + (num_cells * sizeof(sixp_pkt_cell_t)))) { + PRINTF("6P-pkt: cannot set rel_cell_list; body is too short\n"); + return -1; + } else if(((body_len - offset) % sizeof(sixp_pkt_cell_t)) != 0) { + PRINTF("6P-pkt: cannot set rel_cell_list; invalid body_len\n"); + return -1; + } + + if(rel_cell_list != NULL) { + *rel_cell_list = body + offset; + } + + *rel_cell_list_len = num_cells * sizeof(sixp_pkt_cell_t); + + return 0; +} +/*---------------------------------------------------------------------------*/ +int +sixp_pkt_set_cand_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code, + const uint8_t *cand_cell_list, + uint16_t cand_cell_list_len, + uint16_t cell_offset, + uint8_t *body, uint16_t body_len) +{ + int32_t offset; + sixp_pkt_num_cells_t num_cells; + + if(cand_cell_list == NULL || body == NULL) { + PRINTF("6P-pkt: cannot set cand_cell_list; invalid argument\n"); + return -1; + } + + if(sixp_pkt_get_num_cells(type, code, &num_cells, body, body_len) < 0) { + PRINTF("6P-pkt: cannot set cand_cell_list; no NumCells field\n"); + return -1; + } + + if((offset = get_rel_cell_list_offset(type, code)) < 0) { + PRINTF("6P-pkt: cannot set cand_cell_list; "); + PRINTF("packet [type=%u, code=%u] won't have RelCellList\n", + type, code.value); + return -1; + } + + offset += cell_offset + num_cells * sizeof(sixp_pkt_cell_t); + + if(body_len < (offset + cand_cell_list_len)) { + PRINTF("6P-pkt: cannot set cand_cell_list; body is too short\n"); + return -1; + } else if((cand_cell_list_len % sizeof(sixp_pkt_cell_t)) != 0) { + PRINTF("6P-pkt: cannot set cand_cell_list; invalid body_len\n"); + return -1; + } + + memcpy(body + offset, cand_cell_list, cand_cell_list_len); + + return 0; +} +/*---------------------------------------------------------------------------*/ +int +sixp_pkt_get_cand_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code, + const uint8_t **cand_cell_list, + sixp_pkt_offset_t *cand_cell_list_len, + const uint8_t *body, uint16_t body_len) +{ + int32_t offset; + sixp_pkt_num_cells_t num_cells; + + if(cand_cell_list_len == NULL || body == NULL) { + PRINTF("6P-pkt: cannot get cand_cell_list; invalid argument\n"); + return -1; + } + + if(sixp_pkt_get_num_cells(type, code, &num_cells, body, body_len) < 0) { + PRINTF("6P-pkt: cannot get cand_cell_list; no NumCells field\n"); + return -1; + } + + if((offset = get_rel_cell_list_offset(type, code)) < 0) { + PRINTF("6P-pkt: cannot get cand_cell_list; "); + PRINTF("packet [type=%u, code=%u] won't have RelCellList\n", + type, code.value); + return -1; + } + + offset += num_cells * sizeof(sixp_pkt_cell_t); + + if(body_len < offset) { + PRINTF("6P-pkt: cannot set cand_cell_list; body is too short\n"); + return -1; + } else if(((body_len - offset) % sizeof(sixp_pkt_cell_t)) != 0) { + PRINTF("6P-pkt: cannot set cand_cell_list; invalid body_len\n"); + return -1; + } + + if(cand_cell_list != NULL) { + *cand_cell_list = body + offset; + } + + *cand_cell_list_len = body_len - offset; + + return 0; +} +/*---------------------------------------------------------------------------*/ +int +sixp_pkt_set_total_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code, + sixp_pkt_total_num_cells_t total_num_cells, + uint8_t *body, uint16_t body_len) +{ + int32_t offset; + + if(body == NULL) { + PRINTF("6P-pkt: cannot set num_cells; body is null\n"); + return -1; + } + + if((offset = get_total_num_cells_offset(type, code)) < 0) { + PRINTF("6P-pkt: cannot set total_num_cells; "); + PRINTF("packet [type=%u, code=%u] won't have TotalNumCells\n", + type, code.value); + return -1; + } + + /* + * TotalNumCells for 6P Response is a 16-bit unsigned integer, little-endian. + */ + body[offset] = (uint8_t)(total_num_cells & 0xff); + body[offset + 1] = (uint8_t)(total_num_cells >> 8); + + return 0; +} +/*---------------------------------------------------------------------------*/ +int +sixp_pkt_get_total_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code, + sixp_pkt_total_num_cells_t *total_num_cells, + const uint8_t *body, uint16_t body_len) +{ + int32_t offset; + + if(total_num_cells == NULL || body == NULL) { + PRINTF("6P-pkt: cannot get num_cells; invalid argument\n"); + return -1; + } + + if((offset = get_total_num_cells_offset(type, code)) < 0) { + PRINTF("6P-pkt: cannot get num_cells; "); + PRINTF("packet [type=%u, code=%u] won't have TotalNumCells\n", + type, code.value); + return -1; + } + + if(body_len < (offset + sizeof(sixp_pkt_total_num_cells_t))) { + PRINTF("6P-pkt: cannot get num_cells; body is too short\n"); + return -1; + } + + /* TotalNumCells is a 16-bit unsigned integer, little-endian. */ + *total_num_cells = body[0]; + *total_num_cells += ((uint16_t)body[1]) << 8; + return 0; } /*---------------------------------------------------------------------------*/ @@ -626,8 +882,7 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len, pkt->code.value = buf[1]; pkt->sfid = buf[2]; pkt->seqno = buf[3] & 0x0f; - pkt->gab = (buf[3] & 0x30) >> 4; - pkt->gba = (buf[3] & 0xc0) >> 6; + pkt->gen = (buf[3] & 0xf0) >> 4; buf += 4; len -= 4; @@ -649,7 +904,16 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len, return -1; } break; - case SIXP_PKT_CMD_STATUS: + case SIXP_PKT_CMD_RELOCATE: + if(len < (sizeof(sixp_pkt_metadata_t) + + sizeof(sixp_pkt_cell_options_t) + + sizeof(sixp_pkt_num_cells_t)) || + (len % sizeof(uint32_t)) != 0) { + PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n"); + return -1; + } + break; + case SIXP_PKT_CMD_COUNT: if(len != (sizeof(sixp_pkt_metadata_t) + sizeof(sixp_pkt_cell_options_t))) { PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n"); @@ -683,23 +947,30 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len, /* * The "Other Field" contains * - Res to CLEAR: Empty (length 0) - * - Res to STATUS: "Num. Cells" + * - Res to STATUS: "Num. Cells" (total_num_cells) * - Res to ADD, DELETE, LIST: 0, 1, or multiple 6P cells */ if(len != 0 && - len != sizeof(sixp_pkt_num_cells_t) && + len != sizeof(sixp_pkt_total_num_cells_t) && (len % sizeof(uint32_t)) != 0) { PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n"); return -1; } break; - case SIXP_PKT_RC_ERR_VER: - case SIXP_PKT_RC_ERR_SFID: - case SIXP_PKT_RC_ERR_GEN: - case SIXP_PKT_RC_ERR_BUSY: - case SIXP_PKT_RC_ERR_NORES: - case SIXP_PKT_RC_ERR_RESET: - case SIXP_PKT_RC_ERR: + case SIXP_PKT_RC_EOL: + if((len % sizeof(uint32_t)) != 0) { + PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n"); + return -1; + } + break; + case SIXP_PKT_RC_ERROR: + case SIXP_PKT_RC_RESET: + case SIXP_PKT_RC_VERSION: + case SIXP_PKT_RC_SFID: + case SIXP_PKT_RC_GEN: + case SIXP_PKT_RC_BUSY: + case SIXP_PKT_RC_NORES: + case SIXP_PKT_RC_CELLLIST: if(len != 0) { PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n"); return -1; @@ -722,7 +993,7 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len, /*---------------------------------------------------------------------------*/ int sixp_pkt_create(sixp_pkt_type_t type, sixp_pkt_code_t code, - uint8_t sfid, uint8_t seqno, uint8_t gab, uint8_t gba, + uint8_t sfid, uint8_t seqno, uint8_t gen, const uint8_t *body, uint16_t body_len, sixp_pkt_t *pkt) { uint8_t *hdr; @@ -753,7 +1024,7 @@ sixp_pkt_create(sixp_pkt_type_t type, sixp_pkt_code_t code, hdr[0] = (type << 4) | SIXP_PKT_VERSION; hdr[1] = code.value; hdr[2] = sfid; - hdr[3] = (gab << 4) | (gba << 6) | seqno; + hdr[3] = (gen << 4) | seqno; /* data: write body */ if(body_len > 0 && body != NULL) { @@ -767,8 +1038,7 @@ sixp_pkt_create(sixp_pkt_type_t type, sixp_pkt_code_t code, pkt->code = code; pkt->sfid = sfid; pkt->seqno = seqno; - pkt->gab = gab; - pkt->gba = gba; + pkt->gen = gen; pkt->body = body; pkt->body_len = body_len; } diff --git a/os/net/mac/tsch/sixtop/sixp-pkt.h b/os/net/mac/tsch/sixtop/sixp-pkt.h index 38ecb10e2..496634708 100644 --- a/os/net/mac/tsch/sixtop/sixp-pkt.h +++ b/os/net/mac/tsch/sixtop/sixp-pkt.h @@ -43,7 +43,7 @@ #ifndef _SIXTOP_6P_PACKET_H_ #define _SIXTOP_6P_PACKET_H_ -#define SIXP_PKT_VERSION 0x01 +#define SIXP_PKT_VERSION 0x00 /* typedefs for code readability */ typedef uint8_t sixp_pkt_cell_options_t; @@ -53,6 +53,7 @@ typedef uint16_t sixp_pkt_metadata_t; typedef uint16_t sixp_pkt_max_num_cells_t; typedef uint16_t sixp_pkt_offset_t; typedef uint32_t sixp_pkt_cell_t; +typedef uint16_t sixp_pkt_total_num_cells_t; /** * \brief 6P Message Types @@ -70,24 +71,27 @@ typedef enum { typedef enum { SIXP_PKT_CMD_ADD = 0x01, /**< CMD_ADD */ SIXP_PKT_CMD_DELETE = 0x02, /**< CMD_DELETE */ - SIXP_PKT_CMD_STATUS = 0x03, /**< CMD_STATUS */ - SIXP_PKT_CMD_LIST = 0x04, /**< CMD_LIST */ - SIXP_PKT_CMD_CLEAR = 0x05, /**< CMD_CLEAR */ - SIXP_PKT_CMD_UNAVAILABLE /**< for internal use */ + SIXP_PKT_CMD_RELOCATE = 0x03, /**< CMD_STATUS */ + SIXP_PKT_CMD_COUNT = 0x04, /**< CMD_STATUS */ + SIXP_PKT_CMD_LIST = 0x05, /**< CMD_LIST */ + SIXP_PKT_CMD_CLEAR = 0x06, /**< CMD_CLEAR */ + SIXP_PKT_CMD_UNAVAILABLE = 0xff, /**< for internal use */ } sixp_pkt_cmd_t; /** * \brief 6P Return Codes */ typedef enum { - SIXP_PKT_RC_SUCCESS = 0x06, /**< RC_SUCCESS */ - SIXP_PKT_RC_ERR_VER = 0x07, /**< RC_ERR_VER */ - SIXP_PKT_RC_ERR_SFID = 0x08, /**< RC_ERR_SFID */ - SIXP_PKT_RC_ERR_GEN = 0x09, /**< RC_ERR_GEN */ - SIXP_PKT_RC_ERR_BUSY = 0x0a, /**< RC_ERR_BUSY */ - SIXP_PKT_RC_ERR_NORES = 0x0b, /**< RC_ERR_NORES */ - SIXP_PKT_RC_ERR_RESET = 0x0c, /**< RC_ERR_RESET */ - SIXP_PKT_RC_ERR = 0x0d, /**< RC_ERR */ + SIXP_PKT_RC_SUCCESS = 0x00, /**< RC_SUCCESS */ + SIXP_PKT_RC_ERROR = 0x01, /**< RC_ERROR */ + SIXP_PKT_RC_EOL = 0x02, /**< RC_EOL */ + SIXP_PKT_RC_RESET = 0x03, /**< RC_RESET */ + SIXP_PKT_RC_VERSION = 0x04, /**< RC_ERR_VER */ + SIXP_PKT_RC_SFID = 0x05, /**< RC_ERR_SFID */ + SIXP_PKT_RC_GEN = 0x06, /**< RC_ERR_GEN */ + SIXP_PKT_RC_BUSY = 0x07, /**< RC_ERR_BUSY */ + SIXP_PKT_RC_NORES = 0x08, /**< RC_ERR_NORES */ + SIXP_PKT_RC_CELLLIST = 0x09, /**< RC_ERR_CELLLIST */ } sixp_pkt_rc_t; /** @@ -116,8 +120,7 @@ typedef struct { sixp_pkt_code_t code; /**< Code */ uint8_t sfid; /**< SFID */ uint8_t seqno; /**< SeqNum */ - uint8_t gab; /**< GAB */ - uint8_t gba; /**< GBA */ + uint8_t gen; /**< GEN */ const uint8_t *body; /**< Other Fields... */ uint16_t body_len; /**< The length of Other Fields */ } sixp_pkt_t; @@ -426,8 +429,7 @@ int sixp_pkt_parse(const uint8_t *buf, uint16_t len, * \param code 6P Message Code, Command Identifier or Return Code * \param sfid Scheduling Function Identifier * \param seqno Sequence Number - * \param gab GAB - * \param gba GBA + * \param gen GEN * \param body The pointer to "Other Fields" in a buffer * \param body_len The length of body, typically "Other Fields" length * \param pkt The pointer to a sixp_pkt_t structure to store packet info @@ -435,7 +437,7 @@ int sixp_pkt_parse(const uint8_t *buf, uint16_t len, * \return 0 on success, -1 on failure */ int sixp_pkt_create(sixp_pkt_type_t type, sixp_pkt_code_t code, - uint8_t sfid, uint8_t seqno, uint8_t gab, uint8_t gba, + uint8_t sfid, uint8_t seqno, uint8_t gen, const uint8_t *body, uint16_t body_len, sixp_pkt_t *pkt); diff --git a/os/net/mac/tsch/sixtop/sixp.c b/os/net/mac/tsch/sixtop/sixp.c index 05b15ad9e..c80652a02 100644 --- a/os/net/mac/tsch/sixtop/sixp.c +++ b/os/net/mac/tsch/sixtop/sixp.c @@ -120,9 +120,7 @@ send_back_error(sixp_pkt_type_t type, sixp_pkt_code_t code, const linkaddr_t *dest_addr) { /* create a 6P packet within packetbuf */ - /* XXX: set 0 as GAB and GBA for a error response */ - /* XXX: how can we make a confirmation having an error return value? */ - if(sixp_pkt_create(type, code, sfid, seqno, 0, 0, NULL, 0, NULL) < 0) { + if(sixp_pkt_create(type, code, sfid, seqno, 0, NULL, 0, NULL) < 0) { PRINTF("6P: failed to create a 6P packet to return an error [rc:%u]\n", code.value); return -1; @@ -141,6 +139,7 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr) sixp_trans_t *trans; const sixtop_sf_t *sf; int16_t seqno; + int16_t gen; int ret; assert(buf != NULL && src_addr != NULL); @@ -169,7 +168,7 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr) * sent back? */ if(send_back_error(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR_SFID, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SFID, pkt.sfid, pkt.seqno, src_addr) < 0) { PRINTF("6P: sixp_input() fails to return an error response\n"); }; @@ -182,22 +181,20 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr) /* Not need to validate generation counters in a case of CMD_CLEAR */ invalid_schedule_generation = 0; } else if(nbr == NULL) { - if(pkt.gab == 0 && pkt.gba == 0) { + if(pkt.gen == 0) { invalid_schedule_generation = 0; /* valid combination */ } else { - PRINTF("6P: GAB/GBA should be 0 because of no corresponding nbr\n"); + PRINTF("6P: GEN should be 0 because of no corresponding nbr\n"); invalid_schedule_generation = 1; } } else { - PRINTF("6P: GAB: %u, GBA: %u, GTX: %u, GRX: %u\n", - pkt.gab, pkt.gba, sixp_nbr_get_grx(nbr), sixp_nbr_get_gtx(nbr)); - if(((pkt.type == SIXP_PKT_TYPE_REQUEST || - pkt.type == SIXP_PKT_TYPE_CONFIRMATION) && - pkt.gab == sixp_nbr_get_grx(nbr) && - pkt.gba == sixp_nbr_get_gtx(nbr)) || - (pkt.type == SIXP_PKT_TYPE_RESPONSE && - pkt.gab == sixp_nbr_get_gtx(nbr) && - pkt.gba == sixp_nbr_get_grx(nbr))) { + if((gen = sixp_nbr_get_gen(nbr)) < 0) { + PRINTF("6P: unexpected error; cannot get our GEN\n"); + return; + } + PRINTF("6P: received GEN %u, our GEN: %u\n", + pkt.gen, sixp_nbr_get_gen(nbr)); + if(pkt.gen == gen) { invalid_schedule_generation = 0; /* valid combination */ } else { invalid_schedule_generation = 1; @@ -218,7 +215,7 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr) PRINTLLADDR((const uip_lladdr_t *)src_addr); PRINTF(" seqno:%u] is in process\n", sixp_trans_get_seqno(trans)); if(send_back_error(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR_BUSY, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_BUSY, pkt.sfid, pkt.seqno, src_addr) < 0) { PRINTF("6P: sixp_input() fails to return an error response"); } @@ -226,7 +223,7 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr) } else if((trans = sixp_trans_alloc(&pkt, src_addr)) == NULL) { PRINTF("6P: sixp_input() fails because of lack of memory\n"); if(send_back_error(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR_NORES, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_NORES, pkt.sfid, pkt.seqno, src_addr) < 0) { PRINTF("6P: sixp_input() fails to return an error response\n"); } @@ -291,7 +288,7 @@ sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid, sixp_trans_t *trans; sixp_nbr_t *nbr; sixp_pkt_cmd_t cmd; - int16_t seqno, gab, gba; + int16_t seqno, gen; sixp_pkt_t pkt; assert(dest_addr != NULL); @@ -378,31 +375,17 @@ sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid, } } - /* set GAB and GBA */ + /* set GEN */ if(nbr == NULL) { - gab = gba = 0; - } else { - if(type == SIXP_PKT_TYPE_REQUEST || - type == SIXP_PKT_TYPE_CONFIRMATION) { - gab = sixp_nbr_get_gtx(nbr); - gba = sixp_nbr_get_grx(nbr); - } else if(type == SIXP_PKT_TYPE_RESPONSE) { - gba = sixp_nbr_get_gtx(nbr); - gab = sixp_nbr_get_grx(nbr); - } else { - /* never come here */ - PRINTF("6P: sixp_output() fails because of an unexpected condition\n"); - return -1; - } - } - if(gab < 0 || gba < 0) { - PRINTF("6P: sixp_output() fails to get GAB or GBA\n"); + gen = 0; + } else if((gen = sixp_nbr_get_gen(nbr)) < 0) { + PRINTF("6P: sixp_output() fails to get GEN\n"); return -1; } /* create a 6P packet within packetbuf */ if(sixp_pkt_create(type, code, sfid, - (uint8_t)seqno, (uint8_t)gab, (uint8_t)gba, + (uint8_t)seqno, (uint8_t)gen, body, body_len, type == SIXP_PKT_TYPE_REQUEST ? &pkt : NULL) < 0) { PRINTF("6P: sixp_output() fails to create a 6P packet\n"); diff --git a/os/net/mac/tsch/sixtop/sixtop.c b/os/net/mac/tsch/sixtop/sixtop.c index a8f2375a5..c2d4f4aec 100644 --- a/os/net/mac/tsch/sixtop/sixtop.c +++ b/os/net/mac/tsch/sixtop/sixtop.c @@ -141,7 +141,7 @@ sixtop_output(const linkaddr_t *dest_addr, mac_callback_t callback, void *arg) return; } p = packetbuf_hdrptr(); - p[0] = SIXP_SUBIE_ID; + p[0] = SIXTOP_SUBIE_ID; /* * prepend Payload IE header; 2 octets @@ -234,6 +234,7 @@ sixtop_input(void) */ assert(frame.fcf.frame_version == FRAME802154_IEEE802154_2015); assert(frame.fcf.frame_type == FRAME802154_DATAFRAME); + memset(&ies, 0, sizeof(ies)); if(frame.fcf.ie_list_present && frame802154e_parse_information_elements(payload_ptr, payload_len, &ies) >= 0 && diff --git a/os/net/mac/tsch/sixtop/sixtop.h b/os/net/mac/tsch/sixtop/sixtop.h index 46946cbda..5ff0e6089 100644 --- a/os/net/mac/tsch/sixtop/sixtop.h +++ b/os/net/mac/tsch/sixtop/sixtop.h @@ -50,6 +50,8 @@ #include "sixp-pkt.h" +#define SIXTOP_SUBIE_ID 0xc9 + /** * \brief Input Handler of Scheduling Function * \param type 6P Message Type of an input packet diff --git a/tests/16-6tisch/code/test-sixp-nbr.c b/tests/16-6tisch/code/test-sixp-nbr.c index 172162d81..3bbd57a16 100644 --- a/tests/16-6tisch/code/test-sixp-nbr.c +++ b/tests/16-6tisch/code/test-sixp-nbr.c @@ -103,9 +103,9 @@ UNIT_TEST(test_alloc_and_free) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_gtx_management, - "test GTX Management"); -UNIT_TEST(test_gtx_management) +UNIT_TEST_REGISTER(test_gen_management, + "test GEN Management"); +UNIT_TEST(test_gen_management) { sixp_nbr_t *nbr; @@ -113,43 +113,37 @@ UNIT_TEST(test_gtx_management) test_setup(); UNIT_TEST_ASSERT((nbr = sixp_nbr_alloc(&peer_addr_1)) != NULL); - UNIT_TEST_ASSERT(sixp_nbr_get_gtx(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x00); - UNIT_TEST_ASSERT(sixp_nbr_advance_gtx(nbr) == 0); - UNIT_TEST_ASSERT(sixp_nbr_get_gtx(nbr) == 0x01); + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x01); - UNIT_TEST_ASSERT(sixp_nbr_advance_gtx(nbr) == 0); - UNIT_TEST_ASSERT(sixp_nbr_get_gtx(nbr) == 0x02); + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x02); - UNIT_TEST_ASSERT(sixp_nbr_advance_gtx(nbr) == 0); - UNIT_TEST_ASSERT(sixp_nbr_get_gtx(nbr) == 0x01); + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x03); - UNIT_TEST_ASSERT(sixp_nbr_advance_gtx(nbr) == 0); - UNIT_TEST_ASSERT(sixp_nbr_get_gtx(nbr) == 0x02); + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x04); - UNIT_TEST_END(); -} + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x05); -UNIT_TEST_REGISTER(test_grx_management, - "test GRX Management"); -UNIT_TEST(test_grx_management) -{ - sixp_nbr_t *nbr; + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x06); - UNIT_TEST_BEGIN(); - test_setup(); + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x07); - UNIT_TEST_ASSERT((nbr = sixp_nbr_alloc(&peer_addr_1)) != NULL); - UNIT_TEST_ASSERT(sixp_nbr_get_grx(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x08); - UNIT_TEST_ASSERT(sixp_nbr_advance_grx(nbr) == 0); - UNIT_TEST_ASSERT(sixp_nbr_get_grx(nbr) == 0x01); + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x09); - UNIT_TEST_ASSERT(sixp_nbr_advance_grx(nbr) == 0); - UNIT_TEST_ASSERT(sixp_nbr_get_grx(nbr) == 0x02); - - UNIT_TEST_ASSERT(sixp_nbr_advance_grx(nbr) == 0); - UNIT_TEST_ASSERT(sixp_nbr_get_grx(nbr) == 0x01); + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x01); UNIT_TEST_END(); } @@ -211,10 +205,8 @@ PROCESS_THREAD(test_process, ev, data) /* alloc / free */ UNIT_TEST_RUN(test_alloc_and_free); - /* GTX */ - UNIT_TEST_RUN(test_gtx_management); - /* GRX */ - UNIT_TEST_RUN(test_grx_management); + /* GEN */ + UNIT_TEST_RUN(test_gen_management); /* next sequence number */ UNIT_TEST_RUN(test_next_seqno); diff --git a/tests/16-6tisch/code/test-sixp-pkt.c b/tests/16-6tisch/code/test-sixp-pkt.c index 18e7e13f4..da73f71e8 100644 --- a/tests/16-6tisch/code/test-sixp-pkt.c +++ b/tests/16-6tisch/code/test-sixp-pkt.c @@ -125,9 +125,9 @@ UNIT_TEST(test_set_get_metadata_delete_req) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_metadata_status_req, - "test sixp_pkt_{set,get}_metadata(status_req)"); -UNIT_TEST(test_set_get_metadata_status_req) +UNIT_TEST_REGISTER(test_set_get_metadata_relocate_req, + "test sixp_pkt_{set,get}_metadata(relocate_req)"); +UNIT_TEST(test_set_get_metadata_relocate_req) { sixp_pkt_metadata_t testdata, result; uint8_t *ptr = (uint8_t *)&testdata; @@ -138,7 +138,7 @@ UNIT_TEST(test_set_get_metadata_status_req) UNIT_TEST_BEGIN(); - /* Status Request */ + /* Relocate Request */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -147,7 +147,7 @@ UNIT_TEST(test_set_get_metadata_status_req) UNIT_TEST_ASSERT(p_result[1] == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, testdata, buf, sizeof(buf)) == 0); ref_data[0] = 0xAB; @@ -155,7 +155,46 @@ UNIT_TEST(test_set_get_metadata_status_req) UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_metadata(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + &result, + buf, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(p_result[0] == 0xAB); + UNIT_TEST_ASSERT(p_result[1] == 0xCD); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_metadata_count_req, + "test sixp_pkt_{set,get}_metadata(count_req)"); +UNIT_TEST(test_set_get_metadata_count_req) +{ + sixp_pkt_metadata_t testdata, result; + uint8_t *ptr = (uint8_t *)&testdata; + uint8_t *p_result = (uint8_t *)&result; + + ptr[0] = 0xAB; + ptr[1] = 0xCD; + + UNIT_TEST_BEGIN(); + + /* Count Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + memset(&result, 0, sizeof(result)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(p_result[0] == 0x00); + UNIT_TEST_ASSERT(p_result[1] == 0x00); + UNIT_TEST_ASSERT( + sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + testdata, + buf, sizeof(buf)) == 0); + ref_data[0] = 0xAB; + ref_data[1] = 0xCD; + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_get_metadata(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, &result, buf, sizeof(buf)) == 0); UNIT_TEST_ASSERT(p_result[0] == 0xAB); @@ -316,9 +355,9 @@ UNIT_TEST(test_set_get_metadata_success_conf) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_metadata_err_res, +UNIT_TEST_REGISTER(test_set_get_metadata_error_res, "test sixp_pkt_{set,get}_metadata(err_res)"); -UNIT_TEST(test_set_get_metadata_err_res) +UNIT_TEST(test_set_get_metadata_error_res) { sixp_pkt_metadata_t testdata, result; uint8_t *ptr = (uint8_t *)&testdata; @@ -329,7 +368,7 @@ UNIT_TEST(test_set_get_metadata_err_res) UNIT_TEST_BEGIN(); - /* Err Response */ + /* Error Response */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -338,13 +377,13 @@ UNIT_TEST(test_set_get_metadata_err_res) UNIT_TEST_ASSERT(p_result[1] == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_metadata(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_metadata(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(p_result[0] == 0x00); @@ -353,9 +392,9 @@ UNIT_TEST(test_set_get_metadata_err_res) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_metadata_err_conf, +UNIT_TEST_REGISTER(test_set_get_metadata_error_conf, "test sixp_pkt_{set,get}_metadata(err_conf)"); -UNIT_TEST(test_set_get_metadata_err_conf) +UNIT_TEST(test_set_get_metadata_error_conf) { sixp_pkt_metadata_t testdata, result; uint8_t *ptr = (uint8_t *)&testdata; @@ -366,7 +405,7 @@ UNIT_TEST(test_set_get_metadata_err_conf) UNIT_TEST_BEGIN(); - /* Err Confirmation */ + /* Error Confirmation */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -375,13 +414,13 @@ UNIT_TEST(test_set_get_metadata_err_conf) UNIT_TEST_ASSERT(p_result[1] == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_metadata(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_metadata(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(p_result[0] == 0x00); @@ -417,7 +456,7 @@ UNIT_TEST(test_set_get_cell_options_add_req) (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, &result, buf, sizeof(buf)) == 0); - UNIT_TEST_ASSERT(result == 0x07); + UNIT_TEST_ASSERT(result == testdata); UNIT_TEST_END(); } @@ -449,21 +488,21 @@ UNIT_TEST(test_set_get_cell_options_delete_req) (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, &result, buf, sizeof(buf)) == 0); - UNIT_TEST_ASSERT(result == 0x07); + UNIT_TEST_ASSERT(result == testdata); UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_cell_options_status_req, - "test sixp_pkt_{set,get}_cell_options(status_req)"); -UNIT_TEST(test_set_get_cell_options_status_req) +UNIT_TEST_REGISTER(test_set_get_cell_options_relocate_req, + "test sixp_pkt_{set,get}_cell_options(relocate_req)"); +UNIT_TEST(test_set_get_cell_options_relocate_req) { sixp_pkt_cell_options_t testdata, result; testdata = 0x07; UNIT_TEST_BEGIN(); - /* Status Request */ + /* Relocate Request */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -471,17 +510,49 @@ UNIT_TEST(test_set_get_cell_options_status_req) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, testdata, buf, sizeof(buf)) == 0); ref_data[2] = 0x07; UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_cell_options(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, &result, buf, sizeof(buf)) == 0); - UNIT_TEST_ASSERT(result == 0x07); + UNIT_TEST_ASSERT(result == testdata); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cell_options_count_req, + "test sixp_pkt_{set,get}_cell_options(count_req)"); +UNIT_TEST(test_set_get_cell_options_count_req) +{ + sixp_pkt_cell_options_t testdata, result; + testdata = 0x07; + + UNIT_TEST_BEGIN(); + + /* Count Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + memset(&result, 0, sizeof(result)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(result == 0x00); + UNIT_TEST_ASSERT( + sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + testdata, + buf, sizeof(buf)) == 0); + ref_data[2] = 0x07; + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_get_cell_options(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + &result, + buf, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(result == testdata); UNIT_TEST_END(); } @@ -513,7 +584,7 @@ UNIT_TEST(test_set_get_cell_options_list_req) (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, &result, buf, sizeof(buf)) == 0); - UNIT_TEST_ASSERT(result == 0x07); + UNIT_TEST_ASSERT(result == testdata); UNIT_TEST_END(); } @@ -611,16 +682,16 @@ UNIT_TEST(test_set_get_cell_options_success_conf) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_cell_options_err_res, +UNIT_TEST_REGISTER(test_set_get_cell_options_error_res, "test sixp_pkt_{set,get}_cell_options(err_res)"); -UNIT_TEST(test_set_get_cell_options_err_res) +UNIT_TEST(test_set_get_cell_options_error_res) { sixp_pkt_cell_options_t testdata, result; testdata = 0x07; UNIT_TEST_BEGIN(); - /* Err Response */ + /* Error Response */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -628,13 +699,13 @@ UNIT_TEST(test_set_get_cell_options_err_res) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_cell_options(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_cell_options(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -642,16 +713,16 @@ UNIT_TEST(test_set_get_cell_options_err_res) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_cell_options_err_conf, +UNIT_TEST_REGISTER(test_set_get_cell_options_error_conf, "test sixp_pkt_{set,get}_cell_options(err_conf)"); -UNIT_TEST(test_set_get_cell_options_err_conf) +UNIT_TEST(test_set_get_cell_options_error_conf) { sixp_pkt_cell_options_t testdata, result; testdata = 0x07; UNIT_TEST_BEGIN(); - /* Err Confirmation */ + /* Error Confirmation */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -659,13 +730,13 @@ UNIT_TEST(test_set_get_cell_options_err_conf) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_cell_options(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_cell_options(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -700,7 +771,7 @@ UNIT_TEST(test_set_get_num_cells_add_req) (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, &result, buf, sizeof(buf)) == 0); - UNIT_TEST_ASSERT(result == 0x07); + UNIT_TEST_ASSERT(result == testdata); UNIT_TEST_END(); } @@ -732,21 +803,21 @@ UNIT_TEST(test_set_get_num_cells_delete_req) (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, &result, buf, sizeof(buf)) == 0); - UNIT_TEST_ASSERT(result == 0x07); + UNIT_TEST_ASSERT(result == testdata); UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_num_cells_status_req, - "test sixp_pkt_{set,get}_num_cells(status_req)"); -UNIT_TEST(test_set_get_num_cells_status_req) +UNIT_TEST_REGISTER(test_set_get_num_cells_relocate_req, + "test sixp_pkt_{set,get}_num_cells(relocate_req)"); +UNIT_TEST(test_set_get_num_cells_relocate_req) { sixp_pkt_num_cells_t testdata, result; testdata = 0x07; UNIT_TEST_BEGIN(); - /* Status Request */ + /* Relocate Request */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -754,13 +825,45 @@ UNIT_TEST(test_set_get_num_cells_status_req) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + testdata, + buf, sizeof(buf)) == 0); + ref_data[3] = 0x07; + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_get_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + &result, + buf, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(result == testdata); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_num_cells_count_req, + "test sixp_pkt_{set,get}_num_cells(count_req)"); +UNIT_TEST(test_set_get_num_cells_count_req) +{ + sixp_pkt_num_cells_t testdata, result; + testdata = 0x07; + + UNIT_TEST_BEGIN(); + + /* Count Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + memset(&result, 0, sizeof(result)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(result == 0x00); + UNIT_TEST_ASSERT( + sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_num_cells(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -835,29 +938,28 @@ UNIT_TEST_REGISTER(test_set_get_num_cells_success_res, UNIT_TEST(test_set_get_num_cells_success_res) { sixp_pkt_num_cells_t testdata, result; - testdata = 0x07; + testdata = 0xfe; UNIT_TEST_BEGIN(); /* Success Response */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); - memset(&result, 0, sizeof(result)); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); - UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_num_cells(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, testdata, - buf, sizeof(buf)) == 0); - ref_data[0] = 0x07; + buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = 0; UNIT_TEST_ASSERT( sixp_pkt_get_num_cells(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, &result, - buf, sizeof(buf)) == 0); - UNIT_TEST_ASSERT(result == 0x07); + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0); UNIT_TEST_END(); } @@ -892,16 +994,16 @@ UNIT_TEST(test_set_get_num_cells_success_conf) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_num_cells_err_res, +UNIT_TEST_REGISTER(test_set_get_num_cells_error_res, "test sixp_pkt_{set,get}_num_cells(err_res)"); -UNIT_TEST(test_set_get_num_cells_err_res) +UNIT_TEST(test_set_get_num_cells_error_res) { sixp_pkt_num_cells_t testdata, result; testdata = 0x07; UNIT_TEST_BEGIN(); - /* Err Response */ + /* Error Response */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -909,13 +1011,13 @@ UNIT_TEST(test_set_get_num_cells_err_res) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_num_cells(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_num_cells(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -923,16 +1025,16 @@ UNIT_TEST(test_set_get_num_cells_err_res) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_num_cells_err_conf, +UNIT_TEST_REGISTER(test_set_get_num_cells_error_conf, "test sixp_pkt_{set,get}_num_cells(err_conf)"); -UNIT_TEST(test_set_get_num_cells_err_conf) +UNIT_TEST(test_set_get_num_cells_error_conf) { sixp_pkt_num_cells_t testdata, result; testdata = 0x07; UNIT_TEST_BEGIN(); - /* Err Confirmation */ + /* Error Confirmation */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -940,13 +1042,13 @@ UNIT_TEST(test_set_get_num_cells_err_conf) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_num_cells(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_num_cells(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); @@ -1015,16 +1117,16 @@ UNIT_TEST(test_set_get_reserved_delete_req) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_reserved_status_req, - "test sixp_pkt_{set,get}_reserved(status_req)"); -UNIT_TEST(test_set_get_reserved_status_req) +UNIT_TEST_REGISTER(test_set_get_reserved_relocate_req, + "test sixp_pkt_{set,get}_reserved(relocate_req)"); +UNIT_TEST(test_set_get_reserved_relocate_req) { sixp_pkt_reserved_t testdata, result; testdata = 0x07; UNIT_TEST_BEGIN(); - /* Status Request */ + /* Relocate Request */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -1032,13 +1134,44 @@ UNIT_TEST(test_set_get_reserved_status_req) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_reserved(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_reserved(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0x00); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_reserved_count_req, + "test sixp_pkt_{set,get}_reserved(count_req)"); +UNIT_TEST(test_set_get_reserved_count_req) +{ + sixp_pkt_reserved_t testdata, result; + testdata = 0x07; + + UNIT_TEST_BEGIN(); + + /* Count Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + memset(&result, 0, sizeof(result)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(result == 0x00); + UNIT_TEST_ASSERT( + sixp_pkt_set_reserved(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_get_reserved(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -1073,7 +1206,7 @@ UNIT_TEST(test_set_get_reserved_list_req) (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, &result, buf, sizeof(buf)) == 0); - UNIT_TEST_ASSERT(result == 0x07); + UNIT_TEST_ASSERT(result == testdata); UNIT_TEST_END(); } @@ -1171,9 +1304,9 @@ UNIT_TEST(test_set_get_reserved_success_conf) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_reserved_err_res, +UNIT_TEST_REGISTER(test_set_get_reserved_error_res, "test sixp_pkt_{set,get}_reserved(err_res)"); -UNIT_TEST(test_set_get_reserved_err_res) +UNIT_TEST(test_set_get_reserved_error_res) { sixp_pkt_reserved_t testdata, result; testdata = 0x07; @@ -1188,13 +1321,13 @@ UNIT_TEST(test_set_get_reserved_err_res) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_reserved(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_reserved(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -1202,9 +1335,9 @@ UNIT_TEST(test_set_get_reserved_err_res) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_reserved_err_conf, +UNIT_TEST_REGISTER(test_set_get_reserved_error_conf, "test sixp_pkt_{set,get}_reserved(err_conf)"); -UNIT_TEST(test_set_get_reserved_err_conf) +UNIT_TEST(test_set_get_reserved_error_conf) { sixp_pkt_reserved_t testdata, result; testdata = 0x07; @@ -1219,13 +1352,13 @@ UNIT_TEST(test_set_get_reserved_err_conf) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_reserved(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_reserved(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -1295,16 +1428,16 @@ UNIT_TEST(test_set_get_offset_delete_req) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_offset_status_req, - "test sixp_pkt_{set,get}_offset(status_req)"); -UNIT_TEST(test_set_get_offset_status_req) +UNIT_TEST_REGISTER(test_set_get_offset_relocate_req, + "test sixp_pkt_{set,get}_offset(relocate_req)"); +UNIT_TEST(test_set_get_offset_relocate_req) { sixp_pkt_offset_t testdata, result; testdata = 0x07; UNIT_TEST_BEGIN(); - /* Status Request */ + /* Relocate Request */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -1312,13 +1445,44 @@ UNIT_TEST(test_set_get_offset_status_req) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_offset(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_offset(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0x00); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_offset_count_req, + "test sixp_pkt_{set,get}_offset(count_req)"); +UNIT_TEST(test_set_get_offset_count_req) +{ + sixp_pkt_offset_t testdata, result; + testdata = 0x07; + + UNIT_TEST_BEGIN(); + + /* Count Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + memset(&result, 0, sizeof(result)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(result == 0x00); + UNIT_TEST_ASSERT( + sixp_pkt_set_offset(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_get_offset(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -1452,9 +1616,9 @@ UNIT_TEST(test_set_get_offset_success_conf) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_offset_err_res, +UNIT_TEST_REGISTER(test_set_get_offset_error_res, "test sixp_pkt_{set,get}_offset(err_res)"); -UNIT_TEST(test_set_get_offset_err_res) +UNIT_TEST(test_set_get_offset_error_res) { sixp_pkt_offset_t testdata, result; testdata = 0x07; @@ -1469,13 +1633,13 @@ UNIT_TEST(test_set_get_offset_err_res) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_offset(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_offset(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -1483,9 +1647,9 @@ UNIT_TEST(test_set_get_offset_err_res) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_offset_err_conf, +UNIT_TEST_REGISTER(test_set_get_offset_error_conf, "test sixp_pkt_{set,get}_offset(err_conf)"); -UNIT_TEST(test_set_get_offset_err_conf) +UNIT_TEST(test_set_get_offset_error_conf) { sixp_pkt_offset_t testdata, result; testdata = 0x07; @@ -1500,13 +1664,13 @@ UNIT_TEST(test_set_get_offset_err_conf) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_offset(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_offset(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -1577,16 +1741,16 @@ UNIT_TEST(test_set_get_max_num_cells_delete_req) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_max_num_cells_status_req, - "test sixp_pkt_{set,get}_max_num_cells(status_req)"); -UNIT_TEST(test_set_get_max_num_cells_status_req) +UNIT_TEST_REGISTER(test_set_get_max_num_cells_relocate_req, + "test sixp_pkt_{set,get}_max_num_cells(relocate_req)"); +UNIT_TEST(test_set_get_max_num_cells_relocate_req) { sixp_pkt_max_num_cells_t testdata, result; testdata = 0x07; UNIT_TEST_BEGIN(); - /* Status Request */ + /* Relocate Request */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -1594,13 +1758,44 @@ UNIT_TEST(test_set_get_max_num_cells_status_req) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_max_num_cells(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_max_num_cells(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0x00); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_max_num_cells_count_req, + "test sixp_pkt_{set,get}_max_num_cells(count_req)"); +UNIT_TEST(test_set_get_max_num_cells_count_req) +{ + sixp_pkt_max_num_cells_t testdata, result; + testdata = 0x07; + + UNIT_TEST_BEGIN(); + + /* Count Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + memset(&result, 0, sizeof(result)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(result == 0x00); + UNIT_TEST_ASSERT( + sixp_pkt_set_max_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_get_max_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -1734,9 +1929,9 @@ UNIT_TEST(test_set_get_max_num_cells_success_conf) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_max_num_cells_err_res, +UNIT_TEST_REGISTER(test_set_get_max_num_cells_error_res, "test sixp_pkt_{set,get}_max_num_cells(err_res)"); -UNIT_TEST(test_set_get_max_num_cells_err_res) +UNIT_TEST(test_set_get_max_num_cells_error_res) { sixp_pkt_max_num_cells_t testdata, result; testdata = 0x07; @@ -1751,13 +1946,13 @@ UNIT_TEST(test_set_get_max_num_cells_err_res) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_max_num_cells(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_max_num_cells(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -1765,9 +1960,9 @@ UNIT_TEST(test_set_get_max_num_cells_err_res) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_max_num_cells_err_conf, - "test sixp_pkt_{set,get}_max_num_cells(err_conf)"); -UNIT_TEST(test_set_get_max_num_cells_err_conf) +UNIT_TEST_REGISTER(test_set_get_max_num_cells_error_conf, + "test sixp_pkt_{set,get}_max_num_cells(error_conf)"); +UNIT_TEST(test_set_get_max_num_cells_error_conf) { sixp_pkt_max_num_cells_t testdata, result; testdata = 0x07; @@ -1782,13 +1977,13 @@ UNIT_TEST(test_set_get_max_num_cells_err_conf) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_max_num_cells(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_max_num_cells(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result == 0x00); @@ -1826,7 +2021,7 @@ UNIT_TEST(test_set_get_cell_list_add_req) UNIT_TEST_ASSERT( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - testdata, sizeof(testdata), 4, + testdata, sizeof(testdata), sizeof(testdata), buf, sizeof(buf)) == 0); /* 4 of cell_offset means 16-octet offset */ memcpy(ref_data + 4 + 16, testdata, sizeof(testdata)); @@ -1873,7 +2068,7 @@ UNIT_TEST(test_set_get_cell_list_delete_req) UNIT_TEST_ASSERT( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - testdata, sizeof(testdata), 4, + testdata, sizeof(testdata), sizeof(testdata), buf, sizeof(buf)) == 0); /* 4 of cell_offset means 16-octet offset */ memcpy(ref_data + 4 + 16, testdata, sizeof(testdata)); @@ -1890,9 +2085,9 @@ UNIT_TEST(test_set_get_cell_list_delete_req) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_cell_list_status_req, - "test sixp_pkt_{set,get}_cell_list(status_req)"); -UNIT_TEST(test_set_get_cell_list_status_req) +UNIT_TEST_REGISTER(test_set_get_cell_list_relocate_req, + "test sixp_pkt_{set,get}_cell_list(relocate_req)"); +UNIT_TEST(test_set_get_cell_list_relocate_req) { /* make a cell list having four cells as test data */ const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, @@ -1904,7 +2099,7 @@ UNIT_TEST(test_set_get_cell_list_status_req) UNIT_TEST_BEGIN(); - /* Status Request */ + /* Relocate Request */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -1912,13 +2107,50 @@ UNIT_TEST(test_set_get_cell_list_status_req) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + testdata, sizeof(testdata), 0, // offset 0 + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_get_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + &result, &result_len, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result_len == 0); + UNIT_TEST_ASSERT(memcmp(result, testdata, result_len) == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cell_list_count_req, + "test sixp_pkt_{set,get}_cell_list(count_req)"); +UNIT_TEST(test_set_get_cell_list_count_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Count Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + memset(&result, 0, sizeof(result)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(result == 0x00); + UNIT_TEST_ASSERT( + sixp_pkt_set_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, testdata, sizeof(testdata), 0, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_cell_list(SIXP_PKT_TYPE_REQUEST, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_STATUS, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, &result, &result_len, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result_len == 0); @@ -2077,9 +2309,9 @@ UNIT_TEST(test_set_get_cell_list_success_conf) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_cell_list_err_res, - "test sixp_pkt_{set,get}_cell_list(err_res)"); -UNIT_TEST(test_set_get_cell_list_err_res) +UNIT_TEST_REGISTER(test_set_get_cell_list_error_res, + "test sixp_pkt_{set,get}_cell_list(error_res)"); +UNIT_TEST(test_set_get_cell_list_error_res) { /* make a cell list having four cells as test data */ const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, @@ -2091,7 +2323,7 @@ UNIT_TEST(test_set_get_cell_list_err_res) UNIT_TEST_BEGIN(); - /* Err Response */ + /* Error Response */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -2099,13 +2331,13 @@ UNIT_TEST(test_set_get_cell_list_err_res) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, sizeof(testdata), 0, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_cell_list(SIXP_PKT_TYPE_RESPONSE, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, &result_len, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(result_len == 0); @@ -2114,9 +2346,9 @@ UNIT_TEST(test_set_get_cell_list_err_res) UNIT_TEST_END(); } -UNIT_TEST_REGISTER(test_set_get_cell_list_err_conf, - "test sixp_pkt_{set,get}_cell_list(err_conf)"); -UNIT_TEST(test_set_get_cell_list_err_conf) +UNIT_TEST_REGISTER(test_set_get_cell_list_error_conf, + "test sixp_pkt_{set,get}_cell_list(error_conf)"); +UNIT_TEST(test_set_get_cell_list_error_conf) { /* make a cell list having four cells as test data */ const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, @@ -2128,7 +2360,7 @@ UNIT_TEST(test_set_get_cell_list_err_conf) UNIT_TEST_BEGIN(); - /* Err Confirmation */ + /* Error Confirmation */ memset(buf, 0, sizeof(buf)); memset(ref_data, 0, sizeof(ref_data)); memset(&result, 0, sizeof(result)); @@ -2136,13 +2368,13 @@ UNIT_TEST(test_set_get_cell_list_err_conf) UNIT_TEST_ASSERT(result == 0x00); UNIT_TEST_ASSERT( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, testdata, sizeof(testdata), 0, buf, sizeof(buf)) == -1); UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); UNIT_TEST_ASSERT( sixp_pkt_get_cell_list(SIXP_PKT_TYPE_CONFIRMATION, - (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERR, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, &result, &result_len, buf, sizeof(testdata)) == -1); UNIT_TEST_ASSERT(result_len == 0); @@ -2151,22 +2383,793 @@ UNIT_TEST(test_set_get_cell_list_err_conf) UNIT_TEST_END(); } +UNIT_TEST_REGISTER(test_set_get_rel_cell_list_add_req, + "test sixp_pkt_{set,get}_rel_cell_list(add_req)"); +UNIT_TEST(test_set_get_rel_cell_list_add_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Add Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, + 4, buf, sizeof(buf)) == 0); // NumCells == 4 + UNIT_TEST_ASSERT( + sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, + testdata, sizeof(testdata), 0, // offset 0 + buf, sizeof(buf)) == -1); + ref_data[3] = 4; // NumCells == 4 + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + result_len = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, + &result, &result_len, + buf, sizeof(testdata) + 4) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_rel_cell_list_delete_req, + "test sixp_pkt_{set,get}_rel_cell_list(delete_req)"); +UNIT_TEST(test_set_get_rel_cell_list_delete_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Delete Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, + 4, buf, sizeof(buf)) == 0); // NumCells == 4 + UNIT_TEST_ASSERT( + sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, + testdata, sizeof(testdata), 0, // offset 0 + buf, sizeof(buf)) == -1); + ref_data[3] = 4; // NumCells == 4 + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + result_len = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, + &result, &result_len, + buf, sizeof(testdata) + 4) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_rel_cell_list_relocate_req, + "test sixp_pkt_{set,get}_rel_cell_list(relocate_req)"); +UNIT_TEST(test_set_get_rel_cell_list_relocate_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Relocate Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + 4, buf, sizeof(buf)) == 0); // NumCells == 4 + UNIT_TEST_ASSERT( + sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + testdata, sizeof(testdata), 0, // offset 0 + buf, sizeof(buf)) == 0); + ref_data[3] = 4; // NumCells == 4 + memcpy(ref_data + 4, testdata, sizeof(testdata)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + result_len = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + &result, &result_len, + buf, sizeof(testdata) + 4) == 0); + UNIT_TEST_ASSERT(result == &buf[4]); + UNIT_TEST_ASSERT(result_len == sizeof(testdata)); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_rel_cell_list_count_req, + "test sixp_pkt_{set,get}_rel_cell_list(count_req)"); +UNIT_TEST(test_set_get_rel_cell_list_count_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Count Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + &result, &result_len, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_rel_cell_list_list_req, + "test sixp_pkt_{set,get}_rel_cell_list(list_req)"); +UNIT_TEST(test_set_get_rel_cell_list_list_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* List Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, + &result, &result_len, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_rel_cell_list_clear_req, + "test sixp_pkt_{set,get}_rel_cell_list(clear_req)"); +UNIT_TEST(test_set_get_rel_cell_list_clear_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Clear Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + memset(&result, 0, sizeof(result)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_rel_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR, + &result, &result_len, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_rel_cell_list_success_res, + "test sixp_pkt_{set,get}_rel_cell_list(success_res)"); +UNIT_TEST(test_set_get_rel_cell_list_success_res) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Success Response */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_rel_cell_list(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + &result, &result_len, + buf, sizeof(testdata)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_rel_cell_list_success_conf, + "test sixp_pkt_{set,get}_rel_cell_list(success_conf)"); +UNIT_TEST(test_set_get_rel_cell_list_success_conf) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Success Confirmation */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_rel_cell_list(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + &result, &result_len, + buf, sizeof(testdata)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_rel_cell_list_error_res, + "test sixp_pkt_{set,get}_rel_cell_list(error_res)"); +UNIT_TEST(test_set_get_rel_cell_list_error_res) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Error Response */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_rel_cell_list(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + &result, &result_len, + buf, sizeof(testdata)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_rel_cell_list_error_conf, + "test sixp_pkt_{set,get}_rel_cell_list(error_conf)"); +UNIT_TEST(test_set_get_rel_cell_list_error_conf) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Error Confirmation */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_rel_cell_list(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + &result, &result_len, + buf, sizeof(testdata)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cand_cell_list_add_req, + "test sixp_pkt_{set,get}_cand_cell_list(add_req)"); +UNIT_TEST(test_set_get_cand_cell_list_add_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Add Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, + 4, buf, sizeof(buf)) == 0); // NumCells == 4 + UNIT_TEST_ASSERT( + sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, + testdata, sizeof(testdata), 0, // offset 0 + buf, sizeof(buf)) == -1); + ref_data[3] = 4; // NumCells == 4 + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + result_len = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, + &result, &result_len, + buf, sizeof(testdata) + 4) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cand_cell_list_delete_req, + "test sixp_pkt_{set,get}_cand_cell_list(delete_req)"); +UNIT_TEST(test_set_get_cand_cell_list_delete_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Delete Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, + 4, buf, sizeof(buf)) == 0); // NumCells == 4 + UNIT_TEST_ASSERT( + sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, + testdata, sizeof(testdata), 0, // offset 0 + buf, sizeof(buf)) == -1); + ref_data[3] = 4; // NumCells == 4 + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + result_len = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, + &result, &result_len, + buf, sizeof(testdata) + 4) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cand_cell_list_relocate_req, + "test sixp_pkt_{set,get}_cand_cell_list(relocate_req)"); +UNIT_TEST(test_set_get_cand_cell_list_relocate_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Relocate Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + 4, buf, sizeof(buf)) == 0); // NumCells == 4 + UNIT_TEST_ASSERT( + sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + testdata, sizeof(testdata), 0, // offset 0 + buf, sizeof(buf)) == 0); + ref_data[3] = 4; // NumCells == 4 + memcpy(ref_data + 20, testdata, sizeof(testdata)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + result_len = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + &result, &result_len, + buf, 20 + sizeof(testdata)) == 0); + UNIT_TEST_ASSERT(result == &buf[20]); + UNIT_TEST_ASSERT(result_len == sizeof(testdata)); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cand_cell_list_count_req, + "test sixp_pkt_{set,get}_cand_cell_list(count_req)"); +UNIT_TEST(test_set_get_cand_cell_list_count_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Count Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + &result, &result_len, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cand_cell_list_list_req, + "test sixp_pkt_{set,get}_cand_cell_list(list_req)"); +UNIT_TEST(test_set_get_cand_cell_list_list_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* List Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, + &result, &result_len, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cand_cell_list_clear_req, + "test sixp_pkt_{set,get}_cand_cell_list(clear_req)"); +UNIT_TEST(test_set_get_cand_cell_list_clear_req) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Clear Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + memset(&result, 0, sizeof(result)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(result == 0x00); + UNIT_TEST_ASSERT( + sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_get_cand_cell_list(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR, + &result, &result_len, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result_len == 0); + UNIT_TEST_ASSERT(memcmp(result, testdata, result_len) == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cand_cell_list_success_res, + "test sixp_pkt_{set,get}_cand_cell_list(success_res)"); +UNIT_TEST(test_set_get_cand_cell_list_success_res) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Success Response */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_cand_cell_list(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + &result, &result_len, + buf, sizeof(testdata)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cand_cell_list_success_conf, + "test sixp_pkt_{set,get}_cand_cell_list(success_conf)"); +UNIT_TEST(test_set_get_cand_cell_list_success_conf) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Success Confirmation */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_cand_cell_list(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + &result, &result_len, + buf, sizeof(testdata)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cand_cell_list_error_res, + "test sixp_pkt_{set,get}_cand_cell_list(error_res)"); +UNIT_TEST(test_set_get_cand_cell_list_error_res) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Error Response */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_cand_cell_list(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + &result, &result_len, + buf, sizeof(testdata)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_cand_cell_list_error_conf, + "test sixp_pkt_{set,get}_cand_cell_list(error_conf)"); +UNIT_TEST(test_set_get_cand_cell_list_error_conf) +{ + /* make a cell list having four cells as test data */ + const uint8_t testdata[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0xde, 0xad, 0xbe, 0xef, + 0xca, 0xfe, 0xca, 0xfe}; + const uint8_t *result; + sixp_pkt_offset_t result_len; + + UNIT_TEST_BEGIN(); + + /* Error Confirmation */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + testdata, sizeof(testdata), 0, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + result = NULL; + UNIT_TEST_ASSERT( + sixp_pkt_get_cand_cell_list(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + &result, &result_len, + buf, sizeof(testdata)) == -1); + UNIT_TEST_ASSERT(result == NULL); + UNIT_TEST_ASSERT(result_len == 0); + + UNIT_TEST_END(); +} + UNIT_TEST_REGISTER(test_parse_valid_version, "test sixp_pkt_parse(valid_version)"); UNIT_TEST(test_parse_valid_version) { /* - * - Version (4-bit) : 1 (valid version) + * - Version (4-bit) : 0 (valid version) * - Type (2-bit) : 0 (request) * - Reserved (2-bit): 0 * - Code (8-bit) : 2 (delete) * - SFID (8-bit) : 0xfe * - SeqNum (4-bit) : 10 - * - GAB (2-bit) : 2 - * - GBA (1-bit) : 1 + * - GEN (4-bit) : 6 * - Other Field : (4-octet payload) */ - const uint8_t test_buf[] = {0x01, 0x02, 0xfe, 0x6a, + const uint8_t test_buf[] = {0x00, 0x02, 0xfe, 0x6a, 0xde, 0xad, 0xbe, 0xef}; sixp_pkt_t pkt; @@ -2177,8 +3180,7 @@ UNIT_TEST(test_parse_valid_version) UNIT_TEST_ASSERT(pkt.code.cmd == SIXP_PKT_CMD_DELETE); UNIT_TEST_ASSERT(pkt.sfid == 0xfe); UNIT_TEST_ASSERT(pkt.seqno == 10); - UNIT_TEST_ASSERT(pkt.gab == 2); - UNIT_TEST_ASSERT(pkt.gba == 1); + UNIT_TEST_ASSERT(pkt.gen == 6); UNIT_TEST_ASSERT(pkt.body == &test_buf[4]); UNIT_TEST_ASSERT(pkt.body_len == 4); @@ -2196,8 +3198,7 @@ UNIT_TEST(test_parse_invalid_version) * - Code (8-bit) : 2 (delete) * - SFID (8-bit) : 0xfe * - SeqNum (4-bit) : 10 - * - GAB (2-bit) : 2 - * - GBA (1-bit) : 1 + * - GEN (4-bit) : 6 * - Other Field : (4-octet payload) */ const uint8_t test_buf[] = {0x02, 0x08, 0xfe, 0x6a, @@ -2243,8 +3244,7 @@ UNIT_TEST(test_parse_invalid_cmd) * - Code (8-bit) : 10 (undefined) * - SFID (8-bit) : 0xfe * - SeqNum (4-bit) : 10 - * - GAB (2-bit) : 2 - * - GBA (1-bit) : 1 + * - GEN (4-bit) : 6 * - Other Field : (4-octet payload) */ const uint8_t test_buf[] = {0x01, 0x0a, 0xfe, 0x6a, @@ -2269,8 +3269,7 @@ UNIT_TEST(test_parse_invalid_rc) * - Code (8-bit) : 15 (undefined) * - SFID (8-bit) : 0xfe * - SeqNum (4-bit) : 10 - * - GAB (2-bit) : 2 - * - GBA (1-bit) : 1 + * - GEN (4-bit) : 6 * - Other Field : (4-octet payload) */ const uint8_t test_buf[] = {0x11, 0x0f, 0xfe, 0x6a}; @@ -2294,8 +3293,7 @@ UNIT_TEST(test_parse_invalid_type) * - Code (8-bit) : 0 (undefined) * - SFID (8-bit) : 0xfe * - SeqNum (4-bit) : 10 - * - GAB (2-bit) : 2 - * - GBA (1-bit) : 1 + * - GEN (4-bit) : 6 * - Other Field : (4-octet payload) */ const uint8_t test_buf[] = {0x31, 0x00, 0xfe, 0x6a}; @@ -2319,8 +3317,7 @@ UNIT_TEST(test_create_valid_packet) * - Code (8-bit) : 2 (delete) * - SFID (8-bit) : 0xfe * - SeqNum (4-bit) : 10 - * - GAB (2-bit) : 2 - * - GBA (1-bit) : 1 + * - GEN (4-bit) : 6 * - Other Field : (4-octet payload) */ const uint8_t test_body[] = {0xde, 0xad, 0xbe, 0xef}; @@ -2334,7 +3331,7 @@ UNIT_TEST(test_create_valid_packet) UNIT_TEST_ASSERT( sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, - 0xfe, 10, 2, 1, + 0xfe, 10, 6, test_body, sizeof(test_body), &pkt) == 0); hdr_ptr = packetbuf_hdrptr(); @@ -2346,7 +3343,7 @@ UNIT_TEST(test_create_valid_packet) UNIT_TEST_ASSERT(packetbuf_totlen() == 8); /* 6top IE Content */ - UNIT_TEST_ASSERT(hdr_ptr[0] == 0x01); + UNIT_TEST_ASSERT(hdr_ptr[0] == 0x00); UNIT_TEST_ASSERT(hdr_ptr[1] == 0x02); UNIT_TEST_ASSERT(hdr_ptr[2] == 0xfe); UNIT_TEST_ASSERT(hdr_ptr[3] == 0x6a); @@ -2360,8 +3357,7 @@ UNIT_TEST(test_create_valid_packet) UNIT_TEST_ASSERT(pkt.code.cmd == SIXP_PKT_CMD_DELETE); UNIT_TEST_ASSERT(pkt.sfid == 0xfe); UNIT_TEST_ASSERT(pkt.seqno == 10); - UNIT_TEST_ASSERT(pkt.gab == 2); - UNIT_TEST_ASSERT(pkt.gba == 1); + UNIT_TEST_ASSERT(pkt.gen == 6); UNIT_TEST_ASSERT(memcmp(pkt.body, test_body, pkt.body_len) == 0); UNIT_TEST_ASSERT(pkt.body_len == 4); @@ -2379,8 +3375,7 @@ UNIT_TEST(test_create_valid_packet_with_null_pkt) * - Code (8-bit) : 2 (delete) * - SFID (8-bit) : 0xfe * - SeqNum (4-bit) : 10 - * - GAB (2-bit) : 2 - * - GBA (1-bit) : 1 + * - GEN (4-bit) : 6 * - Other Field : (4-octet payload) */ const uint8_t test_body[] = {0xde, 0xad, 0xbe, 0xef}; @@ -2392,7 +3387,7 @@ UNIT_TEST(test_create_valid_packet_with_null_pkt) UNIT_TEST_ASSERT( sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, - 0xfe, 10, 2, 1, + 0xfe, 10, 6, test_body, sizeof(test_body), NULL) == 0); hdr_ptr = packetbuf_hdrptr(); @@ -2404,7 +3399,7 @@ UNIT_TEST(test_create_valid_packet_with_null_pkt) UNIT_TEST_ASSERT(packetbuf_totlen() == 8); /* 6top IE Content */ - UNIT_TEST_ASSERT(hdr_ptr[0] == 0x01); + UNIT_TEST_ASSERT(hdr_ptr[0] == 0x00); UNIT_TEST_ASSERT(hdr_ptr[1] == 0x02); UNIT_TEST_ASSERT(hdr_ptr[2] == 0xfe); UNIT_TEST_ASSERT(hdr_ptr[3] == 0x6a); @@ -2429,8 +3424,7 @@ UNIT_TEST(test_create_too_long_body) * - Code (8-bit) : 2 (delete) * - SFID (8-bit) : 0xfe * - SeqNum (4-bit) : 10 - * - GAB (2-bit) : 2 - * - GBA (1-bit) : 1 + * - GEN (4-bit) : 6 * - Other Field : (4-octet payload) */ const uint8_t test_body[PACKETBUF_SIZE + 1]; @@ -2441,7 +3435,7 @@ UNIT_TEST(test_create_too_long_body) UNIT_TEST_ASSERT( sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, - 0xfe, 10, 2, 1, + 0xfe, 10, 6, test_body, sizeof(test_body), NULL) == -1); UNIT_TEST_ASSERT(packetbuf_hdrlen() == 0); UNIT_TEST_ASSERT(packetbuf_datalen() == 0); @@ -2450,6 +3444,319 @@ UNIT_TEST(test_create_too_long_body) UNIT_TEST_END(); } +UNIT_TEST_REGISTER(test_set_get_total_num_cells_add_req, + "test sixp_pkt_{set,get}_total_num_cells(add_req)"); +UNIT_TEST(test_set_get_total_num_cells_add_req) +{ + sixp_pkt_total_num_cells_t testdata, result; + testdata = 0xcafe; + + UNIT_TEST_BEGIN(); + + /* Add Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_total_num_cells_delete_req, + "test sixp_pkt_{set,get}_total_num_cells(delete_req)"); +UNIT_TEST(test_set_get_total_num_cells_delete_req) +{ + sixp_pkt_total_num_cells_t testdata, result; + testdata = 0xcafe; + + UNIT_TEST_BEGIN(); + + /* Delete Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_total_num_cells_relocate_req, + "test sixp_pkt_{set,get}_total_num_cells(relocate_req)"); +UNIT_TEST(test_set_get_total_num_cells_relocate_req) +{ + sixp_pkt_total_num_cells_t testdata, result; + testdata = 0xcafe; + + UNIT_TEST_BEGIN(); + + /* Relocate Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + testdata, + buf, sizeof(buf)) == -1); + result = 0; + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_get_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_total_num_cells_count_req, + "test sixp_pkt_{set,get}_total_num_cells(count_req)"); +UNIT_TEST(test_set_get_total_num_cells_count_req) +{ + sixp_pkt_total_num_cells_t testdata, result; + testdata = 0xcafe; + + UNIT_TEST_BEGIN(); + + /* Count Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_total_num_cells_list_req, + "test sixp_pkt_{set,get}_total_num_cells(list_req)"); +UNIT_TEST(test_set_get_total_num_cells_list_req) +{ + sixp_pkt_total_num_cells_t testdata, result; + testdata = 0xcafe; + + UNIT_TEST_BEGIN(); + + /* List Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_total_num_cells_clear_req, + "test sixp_pkt_{set,get}_total_num_cells(clear_req)"); +UNIT_TEST(test_set_get_total_num_cells_clear_req) +{ + sixp_pkt_total_num_cells_t testdata, result; + testdata = 0xcafe; + + UNIT_TEST_BEGIN(); + + /* Clear Request */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_total_num_cells(SIXP_PKT_TYPE_REQUEST, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_total_num_cells_success_res, + "test sixp_pkt_{set,get}_total_num_cells(success_res)"); +UNIT_TEST(test_set_get_total_num_cells_success_res) +{ + sixp_pkt_total_num_cells_t testdata, result; + testdata = 0xcafe; + + UNIT_TEST_BEGIN(); + + /* Success Response */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + testdata, + buf, sizeof(buf)) == 0); + /* little endian */ + ref_data[0] = 0xfe; + ref_data[1] = 0xca; + printf("%x, %x\n", buf[0], buf[1]); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_total_num_cells(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + &result, + buf, sizeof(buf)) == 0); + UNIT_TEST_ASSERT(result == testdata); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_total_num_cells_success_conf, + "test sixp_pkt_{set,get}_total_num_cells(success_conf)"); +UNIT_TEST(test_set_get_total_num_cells_success_conf) +{ + sixp_pkt_total_num_cells_t testdata, result; + testdata = 0xcafe; + + UNIT_TEST_BEGIN(); + + /* Success Confirmation */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_total_num_cells(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_total_num_cells_error_res, + "test sixp_pkt_{set,get}_total_num_cells(err_res)"); +UNIT_TEST(test_set_get_total_num_cells_error_res) +{ + sixp_pkt_total_num_cells_t testdata, result; + testdata = 0xcafe; + + UNIT_TEST_BEGIN(); + + /* Error Response */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_total_num_cells(SIXP_PKT_TYPE_RESPONSE, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_set_get_total_num_cells_error_conf, + "test sixp_pkt_{set,get}_total_num_cells(err_conf)"); +UNIT_TEST(test_set_get_total_num_cells_error_conf) +{ + sixp_pkt_total_num_cells_t testdata, result; + testdata = 0xcafe; + + UNIT_TEST_BEGIN(); + + /* Error Confirmation */ + memset(buf, 0, sizeof(buf)); + memset(ref_data, 0, sizeof(ref_data)); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + UNIT_TEST_ASSERT( + sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + testdata, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(memcmp(buf, ref_data, sizeof(buf)) == 0); + + result = 0; + UNIT_TEST_ASSERT( + sixp_pkt_get_total_num_cells(SIXP_PKT_TYPE_CONFIRMATION, + (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_ERROR, + &result, + buf, sizeof(buf)) == -1); + UNIT_TEST_ASSERT(result == 0); + + UNIT_TEST_END(); +} + PROCESS_THREAD(test_process, ev, data) { PROCESS_BEGIN(); @@ -2461,79 +3768,122 @@ PROCESS_THREAD(test_process, ev, data) /* metadata */ UNIT_TEST_RUN(test_set_get_metadata_add_req); UNIT_TEST_RUN(test_set_get_metadata_delete_req); - UNIT_TEST_RUN(test_set_get_metadata_status_req); + UNIT_TEST_RUN(test_set_get_metadata_relocate_req); + UNIT_TEST_RUN(test_set_get_metadata_count_req); UNIT_TEST_RUN(test_set_get_metadata_list_req); UNIT_TEST_RUN(test_set_get_metadata_clear_req); UNIT_TEST_RUN(test_set_get_metadata_success_res); UNIT_TEST_RUN(test_set_get_metadata_success_conf); - UNIT_TEST_RUN(test_set_get_metadata_err_res); - UNIT_TEST_RUN(test_set_get_metadata_err_conf); + UNIT_TEST_RUN(test_set_get_metadata_error_res); + UNIT_TEST_RUN(test_set_get_metadata_error_conf); /* cell_options */ UNIT_TEST_RUN(test_set_get_cell_options_add_req); UNIT_TEST_RUN(test_set_get_cell_options_delete_req); - UNIT_TEST_RUN(test_set_get_cell_options_status_req); + UNIT_TEST_RUN(test_set_get_cell_options_relocate_req); + UNIT_TEST_RUN(test_set_get_cell_options_count_req); UNIT_TEST_RUN(test_set_get_cell_options_list_req); UNIT_TEST_RUN(test_set_get_cell_options_clear_req); UNIT_TEST_RUN(test_set_get_cell_options_success_res); UNIT_TEST_RUN(test_set_get_cell_options_success_conf); - UNIT_TEST_RUN(test_set_get_cell_options_err_res); - UNIT_TEST_RUN(test_set_get_cell_options_err_conf); + UNIT_TEST_RUN(test_set_get_cell_options_error_res); + UNIT_TEST_RUN(test_set_get_cell_options_error_conf); /* num_cells */ UNIT_TEST_RUN(test_set_get_num_cells_add_req); UNIT_TEST_RUN(test_set_get_num_cells_delete_req); - UNIT_TEST_RUN(test_set_get_num_cells_status_req); + UNIT_TEST_RUN(test_set_get_num_cells_relocate_req); + UNIT_TEST_RUN(test_set_get_num_cells_count_req); UNIT_TEST_RUN(test_set_get_num_cells_list_req); UNIT_TEST_RUN(test_set_get_num_cells_clear_req); UNIT_TEST_RUN(test_set_get_num_cells_success_res); UNIT_TEST_RUN(test_set_get_num_cells_success_conf); - UNIT_TEST_RUN(test_set_get_num_cells_err_res); - UNIT_TEST_RUN(test_set_get_num_cells_err_conf); + UNIT_TEST_RUN(test_set_get_num_cells_error_res); + UNIT_TEST_RUN(test_set_get_num_cells_error_conf); /* reserved */ UNIT_TEST_RUN(test_set_get_reserved_add_req); UNIT_TEST_RUN(test_set_get_reserved_delete_req); - UNIT_TEST_RUN(test_set_get_reserved_status_req); + UNIT_TEST_RUN(test_set_get_reserved_relocate_req); + UNIT_TEST_RUN(test_set_get_reserved_count_req); UNIT_TEST_RUN(test_set_get_reserved_list_req); UNIT_TEST_RUN(test_set_get_reserved_clear_req); UNIT_TEST_RUN(test_set_get_reserved_success_res); UNIT_TEST_RUN(test_set_get_reserved_success_conf); - UNIT_TEST_RUN(test_set_get_reserved_err_res); - UNIT_TEST_RUN(test_set_get_reserved_err_conf); + UNIT_TEST_RUN(test_set_get_reserved_error_res); + UNIT_TEST_RUN(test_set_get_reserved_error_conf); /* offset */ UNIT_TEST_RUN(test_set_get_offset_add_req); UNIT_TEST_RUN(test_set_get_offset_delete_req); - UNIT_TEST_RUN(test_set_get_offset_status_req); + UNIT_TEST_RUN(test_set_get_offset_relocate_req); + UNIT_TEST_RUN(test_set_get_offset_count_req); UNIT_TEST_RUN(test_set_get_offset_list_req); UNIT_TEST_RUN(test_set_get_offset_clear_req); UNIT_TEST_RUN(test_set_get_offset_success_res); UNIT_TEST_RUN(test_set_get_offset_success_conf); - UNIT_TEST_RUN(test_set_get_offset_err_res); - UNIT_TEST_RUN(test_set_get_offset_err_conf); + UNIT_TEST_RUN(test_set_get_offset_error_res); + UNIT_TEST_RUN(test_set_get_offset_error_conf); /* offset */ UNIT_TEST_RUN(test_set_get_max_num_cells_add_req); UNIT_TEST_RUN(test_set_get_max_num_cells_delete_req); - UNIT_TEST_RUN(test_set_get_max_num_cells_status_req); + UNIT_TEST_RUN(test_set_get_max_num_cells_relocate_req); + UNIT_TEST_RUN(test_set_get_max_num_cells_count_req); UNIT_TEST_RUN(test_set_get_max_num_cells_list_req); UNIT_TEST_RUN(test_set_get_max_num_cells_clear_req); UNIT_TEST_RUN(test_set_get_max_num_cells_success_res); UNIT_TEST_RUN(test_set_get_max_num_cells_success_conf); - UNIT_TEST_RUN(test_set_get_max_num_cells_err_res); - UNIT_TEST_RUN(test_set_get_max_num_cells_err_conf); + UNIT_TEST_RUN(test_set_get_max_num_cells_error_res); + UNIT_TEST_RUN(test_set_get_max_num_cells_error_conf); /* cell_list */ UNIT_TEST_RUN(test_set_get_cell_list_add_req); UNIT_TEST_RUN(test_set_get_cell_list_delete_req); - UNIT_TEST_RUN(test_set_get_cell_list_status_req); + UNIT_TEST_RUN(test_set_get_cell_list_relocate_req); + UNIT_TEST_RUN(test_set_get_cell_list_count_req); UNIT_TEST_RUN(test_set_get_cell_list_list_req); UNIT_TEST_RUN(test_set_get_cell_list_clear_req); UNIT_TEST_RUN(test_set_get_cell_list_success_res); UNIT_TEST_RUN(test_set_get_cell_list_success_conf); - UNIT_TEST_RUN(test_set_get_cell_list_err_res); - UNIT_TEST_RUN(test_set_get_cell_list_err_conf); + UNIT_TEST_RUN(test_set_get_cell_list_error_res); + UNIT_TEST_RUN(test_set_get_cell_list_error_conf); + + /* rel_cell_list */ + UNIT_TEST_RUN(test_set_get_rel_cell_list_add_req); + UNIT_TEST_RUN(test_set_get_rel_cell_list_delete_req); + UNIT_TEST_RUN(test_set_get_rel_cell_list_relocate_req); + UNIT_TEST_RUN(test_set_get_rel_cell_list_count_req); + UNIT_TEST_RUN(test_set_get_rel_cell_list_list_req); + UNIT_TEST_RUN(test_set_get_rel_cell_list_clear_req); + UNIT_TEST_RUN(test_set_get_rel_cell_list_success_res); + UNIT_TEST_RUN(test_set_get_rel_cell_list_success_conf); + UNIT_TEST_RUN(test_set_get_rel_cell_list_error_res); + UNIT_TEST_RUN(test_set_get_rel_cell_list_error_conf); + + /* cand_cell_list */ + UNIT_TEST_RUN(test_set_get_cand_cell_list_add_req); + UNIT_TEST_RUN(test_set_get_cand_cell_list_delete_req); + UNIT_TEST_RUN(test_set_get_cand_cell_list_relocate_req); + UNIT_TEST_RUN(test_set_get_cand_cell_list_count_req); + UNIT_TEST_RUN(test_set_get_cand_cell_list_list_req); + UNIT_TEST_RUN(test_set_get_cand_cell_list_clear_req); + UNIT_TEST_RUN(test_set_get_cand_cell_list_success_res); + UNIT_TEST_RUN(test_set_get_cand_cell_list_success_conf); + UNIT_TEST_RUN(test_set_get_cand_cell_list_error_res); + UNIT_TEST_RUN(test_set_get_cand_cell_list_error_conf); + + /* total_num_cells */ + UNIT_TEST_RUN(test_set_get_total_num_cells_add_req); + UNIT_TEST_RUN(test_set_get_total_num_cells_delete_req); + UNIT_TEST_RUN(test_set_get_total_num_cells_relocate_req); + UNIT_TEST_RUN(test_set_get_total_num_cells_count_req); + UNIT_TEST_RUN(test_set_get_total_num_cells_list_req); + UNIT_TEST_RUN(test_set_get_total_num_cells_clear_req); + UNIT_TEST_RUN(test_set_get_total_num_cells_success_res); + UNIT_TEST_RUN(test_set_get_total_num_cells_success_conf); + UNIT_TEST_RUN(test_set_get_total_num_cells_error_res); + UNIT_TEST_RUN(test_set_get_total_num_cells_error_conf); /* parse */ UNIT_TEST_RUN(test_parse_valid_version); diff --git a/tests/16-6tisch/code/test-sixp.c b/tests/16-6tisch/code/test-sixp.c index 2125b670a..2bf03a1e4 100644 --- a/tests/16-6tisch/code/test-sixp.c +++ b/tests/16-6tisch/code/test-sixp.c @@ -93,7 +93,7 @@ UNIT_TEST(test_input_no_sf) memset(&body, 0, sizeof(body)); UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - UNKNOWN_SF_SFID, 10, 0, 0, + UNKNOWN_SF_SFID, 10, 0, (const uint8_t *)&body, sizeof(body), NULL) == 0); UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0); @@ -113,9 +113,9 @@ UNIT_TEST(test_input_no_sf) UNIT_TEST_ASSERT(p[3] == 0xa8); /* 6top IE */ - UNIT_TEST_ASSERT(p[4] == 0x00); - UNIT_TEST_ASSERT(p[5] == 0x11); - UNIT_TEST_ASSERT(p[6] == 0x08); + UNIT_TEST_ASSERT(p[4] == 0xc9); + UNIT_TEST_ASSERT(p[5] == 0x10); + UNIT_TEST_ASSERT(p[6] == 0x05); UNIT_TEST_ASSERT(p[7] == UNKNOWN_SF_SFID); UNIT_TEST_ASSERT(p[8] == 0x0a); @@ -152,7 +152,7 @@ UNIT_TEST(test_input_busy) memset(&body, 0, sizeof(body)); UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - TEST_SF_SFID, 10, 0, 0, + TEST_SF_SFID, 10, 0, (const uint8_t *)&body, sizeof(body), NULL) == 0); UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0); @@ -172,9 +172,9 @@ UNIT_TEST(test_input_busy) UNIT_TEST_ASSERT(p[3] == 0xa8); /* 6top IE */ - UNIT_TEST_ASSERT(p[4] == 0x00); - UNIT_TEST_ASSERT(p[5] == 0x11); - UNIT_TEST_ASSERT(p[6] == 0x0a); + UNIT_TEST_ASSERT(p[4] == 0xc9); + UNIT_TEST_ASSERT(p[5] == 0x10); + UNIT_TEST_ASSERT(p[6] == 0x07); UNIT_TEST_ASSERT(p[7] == TEST_SF_SFID); UNIT_TEST_ASSERT(p[8] == 0x0a); @@ -201,7 +201,7 @@ UNIT_TEST(test_input_no_memory) memset(&body, 0, sizeof(body)); UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - TEST_SF_SFID, 10, 0, 0, + TEST_SF_SFID, 10, 0, (const uint8_t *)&body, sizeof(body), &pkt) == 0); memset(&addr, 0, sizeof(addr)); @@ -230,9 +230,9 @@ UNIT_TEST(test_input_no_memory) UNIT_TEST_ASSERT(p[3] == 0xa8); /* 6top IE */ - UNIT_TEST_ASSERT(p[4] == 0x00); - UNIT_TEST_ASSERT(p[5] == 0x11); - UNIT_TEST_ASSERT(p[6] == 0x0b); + UNIT_TEST_ASSERT(p[4] == 0xc9); + UNIT_TEST_ASSERT(p[5] == 0x10); + UNIT_TEST_ASSERT(p[6] == 0x08); UNIT_TEST_ASSERT(p[7] == TEST_SF_SFID); UNIT_TEST_ASSERT(p[8] == 0x0a); @@ -257,24 +257,21 @@ UNIT_TEST(test_input_schedule_generation) memset(&body, 0, sizeof(body)); UNIT_TEST_ASSERT((nbr = sixp_nbr_alloc(&peer_addr)) != NULL); - /* nbr has GTX 0 and GRX 0 now */ + /* nbr has GEN 0 now */ UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - TEST_SF_SFID, 10, 1, 1, + TEST_SF_SFID, 10, 1, (const uint8_t *)&body, sizeof(body), NULL) == 0); sixp_input(packetbuf_hdrptr(), packetbuf_totlen(), &peer_addr); UNIT_TEST_ASSERT(test_sf_input_is_called == 0); - UNIT_TEST_ASSERT(sixp_nbr_advance_gtx(nbr) == 0); - sixp_input(packetbuf_hdrptr(), packetbuf_totlen(), &peer_addr); - UNIT_TEST_ASSERT(test_sf_input_is_called == 0); - - UNIT_TEST_ASSERT(sixp_nbr_advance_grx(nbr) == 0); + UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0); sixp_input(packetbuf_hdrptr(), packetbuf_totlen(), &peer_addr); UNIT_TEST_ASSERT(test_sf_input_is_called == 1); + UNIT_TEST_ASSERT((trans = sixp_trans_find(&peer_addr)) != NULL); UNIT_TEST_ASSERT(sixp_trans_get_state(trans) == SIXP_TRANS_STATE_REQUEST_RECEIVED); @@ -297,7 +294,7 @@ UNIT_TEST(test_output_request_1) UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - TEST_SF_SFID, 10, 0, 0, + TEST_SF_SFID, 10, 0, (const uint8_t *)&body, sizeof(body), &pkt) == 0); UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL); @@ -363,7 +360,7 @@ UNIT_TEST(test_output_response_2) UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - TEST_SF_SFID, 10, 0, 0, + TEST_SF_SFID, 10, 0, (const uint8_t *)&body, sizeof(body), &pkt) == 0); UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL); @@ -391,7 +388,7 @@ UNIT_TEST(test_output_response_3) UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - TEST_SF_SFID, 10, 0, 0, + TEST_SF_SFID, 10, 0, (const uint8_t *)&body, sizeof(body), &pkt) == 0); UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL); @@ -421,7 +418,7 @@ UNIT_TEST(test_output_response_4) UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - TEST_SF_SFID, 10, 0, 0, + TEST_SF_SFID, 10, 0, (const uint8_t *)&body, sizeof(body), &pkt) == 0); UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL); @@ -470,7 +467,7 @@ UNIT_TEST(test_output_confirmation_2) UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - TEST_SF_SFID, 10, 0, 0, + TEST_SF_SFID, 10, 0, (const uint8_t *)&body, sizeof(body), &pkt) == 0); UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL); @@ -498,7 +495,7 @@ UNIT_TEST(test_output_confirmation_3) UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - TEST_SF_SFID, 10, 0, 0, + TEST_SF_SFID, 10, 0, (const uint8_t *)&body, sizeof(body), &pkt) == 0); UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL); @@ -530,7 +527,7 @@ UNIT_TEST(test_output_confirmation_4) UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, - TEST_SF_SFID, 10, 0, 0, + TEST_SF_SFID, 10, 0, (const uint8_t *)&body, sizeof(body), &pkt) == 0); UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL); diff --git a/tests/16-6tisch/code/test-sixtop.c b/tests/16-6tisch/code/test-sixtop.c index e62598c4e..686581212 100644 --- a/tests/16-6tisch/code/test-sixtop.c +++ b/tests/16-6tisch/code/test-sixtop.c @@ -206,7 +206,7 @@ UNIT_TEST(test_output) UNIT_TEST_ASSERT(p[3] == 0xa8); /* 6top IE Sub-ID */ - UNIT_TEST_ASSERT(p[4] == 0x00); + UNIT_TEST_ASSERT(p[4] == 0xc9); /* test data set above */ UNIT_TEST_ASSERT(p[5] == 0xca); UNIT_TEST_ASSERT(p[6] == 0xfe);