1f1b34e8dSMatthias Ringwald /* 2f1b34e8dSMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 3f1b34e8dSMatthias Ringwald * 4f1b34e8dSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5f1b34e8dSMatthias Ringwald * modification, are permitted provided that the following conditions 6f1b34e8dSMatthias Ringwald * are met: 7f1b34e8dSMatthias Ringwald * 8f1b34e8dSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9f1b34e8dSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10f1b34e8dSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11f1b34e8dSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12f1b34e8dSMatthias Ringwald * documentation and/or other materials provided with the distribution. 13f1b34e8dSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14f1b34e8dSMatthias Ringwald * contributors may be used to endorse or promote products derived 15f1b34e8dSMatthias Ringwald * from this software without specific prior written permission. 16f1b34e8dSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17f1b34e8dSMatthias Ringwald * personal benefit and not for any commercial purpose or for 18f1b34e8dSMatthias Ringwald * monetary gain. 19f1b34e8dSMatthias Ringwald * 20f1b34e8dSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21f1b34e8dSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22f1b34e8dSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23f1b34e8dSMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24f1b34e8dSMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25f1b34e8dSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26f1b34e8dSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27f1b34e8dSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28f1b34e8dSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29f1b34e8dSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30f1b34e8dSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31f1b34e8dSMatthias Ringwald * SUCH DAMAGE. 32f1b34e8dSMatthias Ringwald * 33f1b34e8dSMatthias Ringwald * Please inquire about commercial licensing options at 34f1b34e8dSMatthias Ringwald * [email protected] 35f1b34e8dSMatthias Ringwald * 36f1b34e8dSMatthias Ringwald */ 37f1b34e8dSMatthias Ringwald 38*80e33422SMatthias Ringwald #ifndef OBEX_ITERATOR_H 39*80e33422SMatthias Ringwald #define OBEX_ITERATOR_H 40f1b34e8dSMatthias Ringwald 41f1b34e8dSMatthias Ringwald #if defined __cplusplus 42f1b34e8dSMatthias Ringwald extern "C" { 43f1b34e8dSMatthias Ringwald #endif 44f1b34e8dSMatthias Ringwald 45f1b34e8dSMatthias Ringwald #include <stdint.h> 46f1b34e8dSMatthias Ringwald 47f1b34e8dSMatthias Ringwald /* API_START */ 48f1b34e8dSMatthias Ringwald 49f1b34e8dSMatthias Ringwald typedef struct obex_iterator { 50f1b34e8dSMatthias Ringwald const uint8_t * data; 51820092f9SMatthias Ringwald uint16_t offset; 52820092f9SMatthias Ringwald uint16_t length; 53f1b34e8dSMatthias Ringwald } obex_iterator_t; 54f1b34e8dSMatthias Ringwald 55f1b34e8dSMatthias Ringwald // OBEX packet header iterator 56f1b34e8dSMatthias Ringwald void obex_iterator_init_with_request_packet(obex_iterator_t *context, const uint8_t * packet_data, uint16_t packet_len); 57f1b34e8dSMatthias Ringwald void obex_iterator_init_with_response_packet(obex_iterator_t *context, uint8_t request_opcode, const uint8_t * packet_data, uint16_t packet_len); 58f1b34e8dSMatthias Ringwald int obex_iterator_has_more(const obex_iterator_t * context); 59f1b34e8dSMatthias Ringwald void obex_iterator_next(obex_iterator_t * context); 60f1b34e8dSMatthias Ringwald 61f1b34e8dSMatthias Ringwald // OBEX packet header access functions 62f1b34e8dSMatthias Ringwald // @note BODY/END-OF-BODY headers might be incomplete 63f1b34e8dSMatthias Ringwald uint8_t obex_iterator_get_hi(const obex_iterator_t * context); 64f1b34e8dSMatthias Ringwald uint8_t obex_iterator_get_data_8(const obex_iterator_t * context); 65f1b34e8dSMatthias Ringwald uint32_t obex_iterator_get_data_32(const obex_iterator_t * context); 66f1b34e8dSMatthias Ringwald uint32_t obex_iterator_get_data_len(const obex_iterator_t * context); 67f1b34e8dSMatthias Ringwald const uint8_t * obex_iterator_get_data(const obex_iterator_t * context); 68f1b34e8dSMatthias Ringwald 69f1b34e8dSMatthias Ringwald /* API_END */ 70f1b34e8dSMatthias Ringwald 71f1b34e8dSMatthias Ringwald // debug 72f1b34e8dSMatthias Ringwald void obex_dump_packet(uint8_t request_opcode, uint8_t * packet, uint16_t size); 73f1b34e8dSMatthias Ringwald 74f1b34e8dSMatthias Ringwald #if defined __cplusplus 75f1b34e8dSMatthias Ringwald } 76f1b34e8dSMatthias Ringwald #endif 77f1b34e8dSMatthias Ringwald #endif 78