Lines Matching refs:lg_xmit
470 if (pdu->lg_xmit) in coap_cancel_observe()
471 pdu->lg_xmit->b.b1.state_token = lg_crcv->state_token; in coap_cancel_observe()
557 coap_lg_xmit_t *lg_xmit; in coap_find_lg_xmit_response() local
565 LL_FOREACH(session->lg_xmit, lg_xmit) { in coap_find_lg_xmit_response()
568 if (COAP_PDU_IS_REQUEST(&lg_xmit->pdu) || in coap_find_lg_xmit_response()
569 resource != lg_xmit->b.b2.resource || in coap_find_lg_xmit_response()
570 request->code != lg_xmit->b.b2.request_method || in coap_find_lg_xmit_response()
572 lg_xmit->b.b2.query ? in coap_find_lg_xmit_response()
573 lg_xmit->b.b2.query : &empty)) { in coap_find_lg_xmit_response()
578 if (rtag_opt || lg_xmit->b.b2.rtag_set == 1) { in coap_find_lg_xmit_response()
579 if (!(rtag_opt && lg_xmit->b.b2.rtag_set == 1)) in coap_find_lg_xmit_response()
581 if (lg_xmit->b.b2.rtag_length != rtag_length || in coap_find_lg_xmit_response()
582 memcmp(lg_xmit->b.b2.rtag, rtag, rtag_length) != 0) in coap_find_lg_xmit_response()
585 return lg_xmit; in coap_find_lg_xmit_response()
611 coap_lg_xmit_t *lg_xmit = NULL; in coap_add_data_large_internal() local
673 LL_FOREACH_SAFE(session->lg_xmit, lg_xmit, q) { in coap_add_data_large_internal()
674 if (coap_binary_equal(&pdu->actual_token, lg_xmit->b.b1.app_token)) { in coap_add_data_large_internal()
676 LL_DELETE(session->lg_xmit, lg_xmit); in coap_add_data_large_internal()
677 coap_block_delete_lg_xmit(session, lg_xmit); in coap_add_data_large_internal()
678 lg_xmit = NULL; in coap_add_data_large_internal()
705 lg_xmit = coap_find_lg_xmit_response(session, request, resource, query); in coap_add_data_large_internal()
706 if (lg_xmit) { in coap_add_data_large_internal()
708 LL_DELETE(session->lg_xmit, lg_xmit); in coap_add_data_large_internal()
709 coap_block_delete_lg_xmit(session, lg_xmit); in coap_add_data_large_internal()
710 lg_xmit = NULL; in coap_add_data_large_internal()
784 lg_xmit = coap_malloc_type(COAP_LG_XMIT, sizeof(coap_lg_xmit_t)); in coap_add_data_large_internal()
785 if (!lg_xmit) in coap_add_data_large_internal()
797 coap_session_str(session), (void *)lg_xmit); in coap_add_data_large_internal()
799 memset(lg_xmit, 0, sizeof(coap_lg_xmit_t)); in coap_add_data_large_internal()
800 lg_xmit->blk_size = blk_size; in coap_add_data_large_internal()
801 lg_xmit->option = option; in coap_add_data_large_internal()
802 lg_xmit->data = data; in coap_add_data_large_internal()
803 lg_xmit->length = length; in coap_add_data_large_internal()
805 lg_xmit->non_timeout_random_ticks = in coap_add_data_large_internal()
808 lg_xmit->release_func = release_func; in coap_add_data_large_internal()
809 lg_xmit->app_ptr = app_ptr; in coap_add_data_large_internal()
810 pdu->lg_xmit = lg_xmit; in coap_add_data_large_internal()
811 coap_ticks(&lg_xmit->last_obs); in coap_add_data_large_internal()
812 coap_ticks(&lg_xmit->last_sent); in coap_add_data_large_internal()
815 lg_xmit->b.b1.app_token = coap_new_binary(pdu->actual_token.length); in coap_add_data_large_internal()
816 if (!lg_xmit->b.b1.app_token) in coap_add_data_large_internal()
818 memcpy(lg_xmit->b.b1.app_token->s, pdu->actual_token.s, in coap_add_data_large_internal()
824 lg_xmit->b.b1.count = 1; in coap_add_data_large_internal()
825 lg_xmit->b.b1.state_token = STATE_TOKEN_FULL(++session->tx_token, in coap_add_data_large_internal()
826 lg_xmit->b.b1.count); in coap_add_data_large_internal()
847 lg_xmit->b.b2.resource = resource; in coap_add_data_large_internal()
849 lg_xmit->b.b2.query = coap_new_string(query->length); in coap_add_data_large_internal()
850 if (lg_xmit->b.b2.query) { in coap_add_data_large_internal()
851 memcpy(lg_xmit->b.b2.query->s, query->s, query->length); in coap_add_data_large_internal()
854 lg_xmit->b.b2.query = NULL; in coap_add_data_large_internal()
858 lg_xmit->b.b2.rtag_length = (uint8_t)min(coap_opt_length(opt), in coap_add_data_large_internal()
859 sizeof(lg_xmit->b.b2.rtag)); in coap_add_data_large_internal()
860 memcpy(lg_xmit->b.b2.rtag, coap_opt_value(opt), coap_opt_length(opt)); in coap_add_data_large_internal()
861 lg_xmit->b.b2.rtag_set = 1; in coap_add_data_large_internal()
863 lg_xmit->b.b2.rtag_set = 0; in coap_add_data_large_internal()
865 lg_xmit->b.b2.etag = etag; in coap_add_data_large_internal()
866 lg_xmit->b.b2.request_method = request_method; in coap_add_data_large_internal()
871 lg_xmit->b.b2.maxage_expire = coap_ticks_to_rt(now) + maxage; in coap_add_data_large_internal()
873 lg_xmit->b.b2.maxage_expire = 0; in coap_add_data_large_internal()
892 blk_size, lg_xmit->length)) in coap_add_data_large_internal()
897 lg_xmit->option, in coap_add_data_large_internal()
903 memcpy(&lg_xmit->pdu, pdu, sizeof(lg_xmit->pdu)); in coap_add_data_large_internal()
904 lg_xmit->pdu.token = coap_malloc_type(COAP_PDU_BUF, in coap_add_data_large_internal()
905 lg_xmit->pdu.used_size + lg_xmit->pdu.max_hdr_size); in coap_add_data_large_internal()
906 if (!lg_xmit->pdu.token) in coap_add_data_large_internal()
909 lg_xmit->pdu.alloc_size = lg_xmit->pdu.used_size; in coap_add_data_large_internal()
910 lg_xmit->pdu.token += lg_xmit->pdu.max_hdr_size; in coap_add_data_large_internal()
911 memcpy(lg_xmit->pdu.token, pdu->token, lg_xmit->pdu.used_size); in coap_add_data_large_internal()
913 lg_xmit->pdu.data = lg_xmit->pdu.token + (pdu->data - pdu->token); in coap_add_data_large_internal()
914 lg_xmit->pdu.actual_token.s = lg_xmit->pdu.token + pdu->e_token_length - in coap_add_data_large_internal()
916 lg_xmit->pdu.actual_token.length = pdu->actual_token.length; in coap_add_data_large_internal()
935 block.num = block.num << (lg_xmit->blk_size - blk_size); in coap_add_data_large_internal()
936 lg_xmit->blk_size = blk_size; in coap_add_data_large_internal()
937 chunk = (size_t)1 << (lg_xmit->blk_size + 4); in coap_add_data_large_internal()
941 lg_xmit->option, in coap_add_data_large_internal()
943 … (block.num << 4) | (block.m << 3) | lg_xmit->blk_size), in coap_add_data_large_internal()
948 if (rem > lg_xmit->length - block.num * chunk) in coap_add_data_large_internal()
949 rem = lg_xmit->length - block.num * chunk; in coap_add_data_large_internal()
954 lg_xmit->b.b1.bert_size = rem; in coap_add_data_large_internal()
956 lg_xmit->last_block = -1; in coap_add_data_large_internal()
959 LL_PREPEND(session->lg_xmit,lg_xmit); in coap_add_data_large_internal()
984 if (lg_xmit) { in coap_add_data_large_internal()
985 coap_block_delete_lg_xmit(session, lg_xmit); in coap_add_data_large_internal()
1152 LL_FOREACH_SAFE(session->lg_xmit, p, q) { in coap_block_check_lg_xmit_timeouts()
1156 LL_DELETE(session->lg_xmit, p); in coap_block_check_lg_xmit_timeouts()
1168 LL_DELETE(session->lg_xmit, p); in coap_block_check_lg_xmit_timeouts()
1639 coap_lg_xmit_t *lg_xmit, in coap_send_q_blocks() argument
1653 if (!lg_xmit) { in coap_send_q_blocks()
1668 pdu->lg_xmit = lg_xmit; in coap_send_q_blocks()
1674 lg_xmit->option == COAP_OPTION_Q_BLOCK2) || in coap_send_q_blocks()
1683 token = STATE_TOKEN_FULL(lg_xmit->b.b1.state_token,++lg_xmit->b.b1.count); in coap_send_q_blocks()
1689 coap_option_filter_set(&drop_options, lg_xmit->option); in coap_send_q_blocks()
1708 size_t chunk = ((size_t)1 << (lg_xmit->blk_size + 4)); in coap_send_q_blocks()
1711 lg_xmit->offset = block.num * chunk; in coap_send_q_blocks()
1712 block.m = lg_xmit->offset + chunk < lg_xmit->length; in coap_send_q_blocks()
1729 token = STATE_TOKEN_FULL(lg_xmit->b.b1.state_token,++lg_xmit->b.b1.count); in coap_send_q_blocks()
1736 if (!coap_update_option(block_pdu, lg_xmit->option, in coap_send_q_blocks()
1750 lg_xmit->length, in coap_send_q_blocks()
1751 lg_xmit->data, in coap_send_q_blocks()
1760 lg_xmit->last_block = block.num; in coap_send_q_blocks()
1771 lg_xmit->last_payload = 0; in coap_send_q_blocks()
1772 coap_ticks(&lg_xmit->last_all_sent); in coap_send_q_blocks()
1774 coap_ticks(&lg_xmit->last_payload); in coap_send_q_blocks()
1781 coap_lg_xmit_t *lg_xmit; in coap_block_check_q_block1_xmit() local
1786 LL_FOREACH_SAFE(session->lg_xmit, lg_xmit, q) { in coap_block_check_q_block1_xmit()
1787 coap_tick_t non_timeout = lg_xmit->non_timeout_random_ticks; in coap_block_check_q_block1_xmit()
1793 if (lg_xmit->last_payload) { in coap_block_check_q_block1_xmit()
1794 if (lg_xmit->last_payload <= timed_out) { in coap_block_check_q_block1_xmit()
1797 size_t chunk = (size_t)1 << (lg_xmit->blk_size + 4); in coap_block_check_q_block1_xmit()
1800 block.num = (uint32_t)(lg_xmit->offset / chunk); in coap_block_check_q_block1_xmit()
1801 block.m = lg_xmit->offset + chunk < lg_xmit->length; in coap_block_check_q_block1_xmit()
1802 block.szx = lg_xmit->blk_size; in coap_block_check_q_block1_xmit()
1803 coap_send_q_blocks(session, lg_xmit, block, &lg_xmit->pdu, COAP_SEND_SKIP_PDU); in coap_block_check_q_block1_xmit()
1808 if (tim_rem > lg_xmit->last_payload - timed_out) in coap_block_check_q_block1_xmit()
1809 tim_rem = lg_xmit->last_payload - timed_out; in coap_block_check_q_block1_xmit()
1811 } else if (lg_xmit->last_all_sent) { in coap_block_check_q_block1_xmit()
1813 if (lg_xmit->last_all_sent + 4 * non_timeout <= now) { in coap_block_check_q_block1_xmit()
1815 LL_DELETE(session->lg_xmit, lg_xmit); in coap_block_check_q_block1_xmit()
1816 coap_block_delete_lg_xmit(session, lg_xmit); in coap_block_check_q_block1_xmit()
1819 if (tim_rem > lg_xmit->last_all_sent + 4 * non_timeout - now) in coap_block_check_q_block1_xmit()
1820 tim_rem = lg_xmit->last_all_sent + 4 * non_timeout - now; in coap_block_check_q_block1_xmit()
1831 coap_lg_xmit_t *lg_xmit; in coap_block_check_q_block2_xmit() local
1836 LL_FOREACH_SAFE(session->lg_xmit, lg_xmit, q) { in coap_block_check_q_block2_xmit()
1837 coap_tick_t non_timeout = lg_xmit->non_timeout_random_ticks; in coap_block_check_q_block2_xmit()
1843 if (lg_xmit->last_payload) { in coap_block_check_q_block2_xmit()
1844 if (lg_xmit->last_payload <= timed_out) { in coap_block_check_q_block2_xmit()
1847 size_t chunk = (size_t)1 << (lg_xmit->blk_size + 4); in coap_block_check_q_block2_xmit()
1850 block.num = (uint32_t)(lg_xmit->offset / chunk); in coap_block_check_q_block2_xmit()
1851 block.m = lg_xmit->offset + chunk < lg_xmit->length; in coap_block_check_q_block2_xmit()
1852 block.szx = lg_xmit->blk_size; in coap_block_check_q_block2_xmit()
1853 if (block.num == (uint32_t)lg_xmit->last_block) in coap_block_check_q_block2_xmit()
1854 coap_send_q_blocks(session, lg_xmit, block, &lg_xmit->pdu, COAP_SEND_SKIP_PDU); in coap_block_check_q_block2_xmit()
1859 if (tim_rem > lg_xmit->last_payload - timed_out) in coap_block_check_q_block2_xmit()
1860 tim_rem = lg_xmit->last_payload - timed_out; in coap_block_check_q_block2_xmit()
1862 } else if (lg_xmit->last_all_sent) { in coap_block_check_q_block2_xmit()
1864 if (lg_xmit->last_all_sent + 4 * non_timeout <= now) { in coap_block_check_q_block2_xmit()
1866 LL_DELETE(session->lg_xmit, lg_xmit); in coap_block_check_q_block2_xmit()
1867 coap_block_delete_lg_xmit(session, lg_xmit); in coap_block_check_q_block2_xmit()
1870 if (tim_rem > lg_xmit->last_all_sent + 4 * non_timeout - now) in coap_block_check_q_block2_xmit()
1871 tim_rem = lg_xmit->last_all_sent + 4 * non_timeout - now; in coap_block_check_q_block2_xmit()
1934 coap_lg_xmit_t *lg_xmit; in coap_send_q_block1() local
1939 LL_FOREACH(session->lg_xmit, lg_xmit) { in coap_send_q_block1()
1940 if (lg_xmit->option == COAP_OPTION_Q_BLOCK1 && in coap_send_q_block1()
1941 (token_match == STATE_TOKEN_BASE(lg_xmit->b.b1.state_token) || in coap_send_q_block1()
1943 STATE_TOKEN_BASE(coap_decode_var_bytes8(lg_xmit->b.b1.app_token->s, in coap_send_q_block1()
1944 lg_xmit->b.b1.app_token->length)))) in coap_send_q_block1()
1948 return coap_send_q_blocks(session, lg_xmit, block, request, send_request); in coap_send_q_block1()
1967 coap_lg_xmit_t *lg_xmit; in coap_send_q_block2() local
1970 LL_FOREACH(session->lg_xmit, lg_xmit) { in coap_send_q_block2()
1971 if (lg_xmit->option == COAP_OPTION_Q_BLOCK2 && in coap_send_q_block2()
1972 resource == lg_xmit->b.b2.resource && in coap_send_q_block2()
1973 request_method == lg_xmit->b.b2.request_method && in coap_send_q_block2()
1975 lg_xmit->b.b2.query ? lg_xmit->b.b2.query : &empty)) in coap_send_q_block2()
1978 return coap_send_q_blocks(session, lg_xmit, block, response, send_response); in coap_send_q_block2()
2030 coap_lg_xmit_t *lg_xmit) { in coap_block_new_lg_crcv() argument
2035 size_t data_len = lg_xmit ? lg_xmit->length : in coap_block_new_lg_crcv()
2065 memcpy(lg_crcv->pdu.data, lg_xmit ? lg_xmit->data : pdu->data, data_len); in coap_block_new_lg_crcv()
2143 coap_lg_xmit_t *lg_xmit) { in coap_block_delete_lg_xmit() argument
2144 if (lg_xmit == NULL) in coap_block_delete_lg_xmit()
2147 if (lg_xmit->release_func) { in coap_block_delete_lg_xmit()
2148 lg_xmit->release_func(session, lg_xmit->app_ptr); in coap_block_delete_lg_xmit()
2150 if (lg_xmit->pdu.token) { in coap_block_delete_lg_xmit()
2151 coap_free_type(COAP_PDU_BUF, lg_xmit->pdu.token - lg_xmit->pdu.max_hdr_size); in coap_block_delete_lg_xmit()
2153 if (COAP_PDU_IS_REQUEST(&lg_xmit->pdu)) in coap_block_delete_lg_xmit()
2154 coap_delete_binary(lg_xmit->b.b1.app_token); in coap_block_delete_lg_xmit()
2156 coap_delete_string(lg_xmit->b.b2.query); in coap_block_delete_lg_xmit()
2159 coap_session_str(session), (void *)lg_xmit); in coap_block_delete_lg_xmit()
2160 coap_free_type(COAP_LG_XMIT, lg_xmit); in coap_block_delete_lg_xmit()
2914 coap_lg_xmit_t *lg_xmit, coap_lg_crcv_t *lg_crcv) { in check_freshness() argument
2920 if (sent || lg_xmit || lg_crcv) { in check_freshness()
2934 } else if (lg_xmit) { in check_freshness()
2935 sent = &lg_xmit->pdu; in check_freshness()
2936 if (lg_xmit->length) { in check_freshness()
2937 size_t blk_size = (size_t)1 << (lg_xmit->blk_size + 4); in check_freshness()
2938 size_t offset = (lg_xmit->last_block + 1) * blk_size; in check_freshness()
2940 data = &lg_xmit->data[offset]; in check_freshness()
2941 data_len = (lg_xmit->length - offset) > blk_size ? blk_size : in check_freshness()
2942 lg_xmit->length - offset; in check_freshness()
2949 if (lg_xmit) { in check_freshness()
2950 token = STATE_TOKEN_FULL(lg_xmit->b.b1.state_token, in check_freshness()
2951 ++lg_xmit->b.b1.count); in check_freshness()
2973 if (lg_xmit) { in check_freshness()
2974 lg_xmit->b.b1.state_token = token; in check_freshness()
3031 LL_FOREACH_SAFE(session->lg_xmit, p, q) { in coap_handle_response_send_block()
3275 LL_DELETE(session->lg_xmit, p); in coap_handle_response_send_block()
3855 coap_lg_xmit_t *lg_xmit; in coap_check_code_lg_xmit() local
3859 lg_xmit = coap_find_lg_xmit_response(session, request, resource, query); in coap_check_code_lg_xmit()
3860 if (lg_xmit && lg_xmit->pdu.code == 0) { in coap_check_code_lg_xmit()
3861 lg_xmit->pdu.code = response->code; in coap_check_code_lg_xmit()
3873 coap_lg_xmit_t *lg_xmit; in coap_check_update_token() local
3889 if (COAP_PDU_IS_REQUEST(pdu) && session->lg_xmit) { in coap_check_update_token()
3890 LL_FOREACH(session->lg_xmit, lg_xmit) { in coap_check_update_token()
3891 if (coap_binary_equal(&pdu->actual_token, lg_xmit->b.b1.app_token)) in coap_check_update_token()
3893 if (token_match == STATE_TOKEN_BASE(lg_xmit->b.b1.state_token)) { in coap_check_update_token()
3894 coap_update_token(pdu, lg_xmit->b.b1.app_token->length, in coap_check_update_token()
3895 lg_xmit->b.b1.app_token->s); in coap_check_update_token()