Lines Matching refs:oi
117 coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_iterator_t *oi,
121 assert(oi);
123 memset(oi, 0, sizeof(coap_opt_iterator_t));
125 oi->next_option = pdu->token + pdu->e_token_length;
126 if (pdu->token + pdu->used_size <= oi->next_option) {
127 oi->bad = 1;
131 oi->length = pdu->used_size - pdu->e_token_length;
134 memcpy(&oi->filter, filter, sizeof(coap_opt_filter_t));
135 oi->filtered = 1;
137 return oi;
141 opt_finished(coap_opt_iterator_t *oi) {
142 assert(oi);
144 if (oi->bad || oi->length == 0 ||
145 !oi->next_option || *oi->next_option == COAP_PAYLOAD_START) {
146 oi->bad = 1;
149 return oi->bad;
153 coap_option_next(coap_opt_iterator_t *oi) {
158 assert(oi);
160 if (opt_finished(oi))
164 /* oi->next_option always points to the next option to deliver; as
166 * oi->next_option is valid. */
167 current_opt = oi->next_option;
173 optsize = coap_opt_parse(oi->next_option, oi->length, &option);
175 assert(optsize <= oi->length);
177 oi->next_option += optsize;
178 oi->length -= optsize;
180 oi->number += option.delta;
182 oi->bad = 1;
190 if (!oi->filtered ||
191 coap_option_filter_get(&oi->filter, oi->number) > 0)
200 coap_opt_iterator_t *oi) {
206 coap_option_iterator_init(pdu, oi, &f);
208 return coap_option_next(oi);