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