|
|
|
|
@ -30,6 +30,7 @@ struct PKTNORM* pn_init(struct ETCP_CONN* etcp) {
|
|
|
|
|
|
|
|
|
|
struct PKTNORM* pn = u_calloc(1, sizeof(struct PKTNORM)); |
|
|
|
|
if (!pn) { |
|
|
|
|
pn->alloc_errors++; |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_NORMALIZER, "pn_init: calloc failed"); |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
@ -185,6 +186,7 @@ void pn_packer_send(struct PKTNORM* pn, uint8_t* data, uint16_t len) {
|
|
|
|
|
|
|
|
|
|
struct ll_entry* entry = ll_alloc_lldgram(len); |
|
|
|
|
if (!entry) { |
|
|
|
|
pn->alloc_errors++; |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_NORMALIZER, "pn_packer_send: ll_alloc_lldgram failed"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -253,6 +255,7 @@ static void pn_buf_renew(struct PKTNORM* pn) {
|
|
|
|
|
if (!pn->data) { |
|
|
|
|
pn->data = memory_pool_alloc(pn->etcp->instance->data_pool); |
|
|
|
|
if (!pn->data) { |
|
|
|
|
pn->alloc_errors++; |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_NORMALIZER, "pn_buf_renew: memory_pool_alloc failed"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -349,6 +352,7 @@ static void pn_unpacker_cb(struct ll_queue* q, void* arg) {
|
|
|
|
|
if (!pn->recvpart) { |
|
|
|
|
// Need length header for new packet
|
|
|
|
|
if (len - ptr < 2) { |
|
|
|
|
pn->logic_errors++; |
|
|
|
|
// Incomplete header, reset
|
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_NORMALIZER, "reset state"); |
|
|
|
|
// pn_unpacker_reset_state(pn);
|
|
|
|
|
@ -360,6 +364,7 @@ static void pn_unpacker_cb(struct ll_queue* q, void* arg) {
|
|
|
|
|
ptr += 2; |
|
|
|
|
|
|
|
|
|
if (part_size<1 || part_size>16384) { |
|
|
|
|
pn->logic_errors++; |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_NORMALIZER, "PART_SIZE ERROR!!! %d", part_size); |
|
|
|
|
etcp_conn_reinit(pn->etcp); |
|
|
|
|
break; |
|
|
|
|
@ -367,6 +372,7 @@ static void pn_unpacker_cb(struct ll_queue* q, void* arg) {
|
|
|
|
|
|
|
|
|
|
pn->recvpart = ll_alloc_lldgram(part_size); |
|
|
|
|
if (!pn->recvpart) { |
|
|
|
|
pn->alloc_errors++; |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_NORMALIZER, "ll_alloc_lldgram failed"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|