obex_iterator.c (e501bae08349e058caa4648e0af3dd01cbd89d20) obex_iterator.c (c1ab6cc1beb14b16b46e74a3723644016d8c3cc7)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 61 unchanged lines hidden (view full) ---

70}
71
72void obex_iterator_init_with_request_packet(obex_iterator_t *context, const uint8_t * packet_data, uint16_t packet_len){
73 int header_offset = obex_packet_header_offset_for_opcode(packet_data[0]);
74 obex_iterator_init(context, header_offset, packet_data, packet_len);
75}
76
77void obex_iterator_init_with_response_packet(obex_iterator_t *context, uint8_t request_opcode, const uint8_t * packet_data, uint16_t packet_len){
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 61 unchanged lines hidden (view full) ---

70}
71
72void obex_iterator_init_with_request_packet(obex_iterator_t *context, const uint8_t * packet_data, uint16_t packet_len){
73 int header_offset = obex_packet_header_offset_for_opcode(packet_data[0]);
74 obex_iterator_init(context, header_offset, packet_data, packet_len);
75}
76
77void obex_iterator_init_with_response_packet(obex_iterator_t *context, uint8_t request_opcode, const uint8_t * packet_data, uint16_t packet_len){
78 int header_offset = request_opcode == OBEX_OPCODE_CONNECT ? 7 : 3;
78 int header_offset = (request_opcode == OBEX_OPCODE_CONNECT) ? 7 : 3;
79 obex_iterator_init(context, header_offset, packet_data, packet_len);
80}
81
82int obex_iterator_has_more(const obex_iterator_t * context){
83 return context->offset < context->length;
84}
85
86void obex_iterator_next(obex_iterator_t * context){

--- 66 unchanged lines hidden (view full) ---

153 // 32-bit value
154 return &data[1];
155 }
156}
157
158void obex_dump_packet(uint8_t request_opcode, uint8_t * packet, uint16_t size){
159 obex_iterator_t it;
160 printf("OBEX Opcode: 0x%02x\n", request_opcode);
79 obex_iterator_init(context, header_offset, packet_data, packet_len);
80}
81
82int obex_iterator_has_more(const obex_iterator_t * context){
83 return context->offset < context->length;
84}
85
86void obex_iterator_next(obex_iterator_t * context){

--- 66 unchanged lines hidden (view full) ---

153 // 32-bit value
154 return &data[1];
155 }
156}
157
158void obex_dump_packet(uint8_t request_opcode, uint8_t * packet, uint16_t size){
159 obex_iterator_t it;
160 printf("OBEX Opcode: 0x%02x\n", request_opcode);
161 int header_offset = request_opcode == OBEX_OPCODE_CONNECT ? 7 : 3;
161 int header_offset = (request_opcode == OBEX_OPCODE_CONNECT) ? 7 : 3;
162 printf("OBEX Header: ");
163 printf_hexdump(packet, header_offset);
164 for (obex_iterator_init_with_response_packet(&it, request_opcode, packet, size); obex_iterator_has_more(&it) ; obex_iterator_next(&it)){
165 uint8_t hi = obex_iterator_get_hi(&it);
166 printf("HI: %x - ", hi);
167 uint8_t encoding = hi >> 6;
168 uint16_t len;
169 switch (encoding){

--- 15 unchanged lines hidden ---
162 printf("OBEX Header: ");
163 printf_hexdump(packet, header_offset);
164 for (obex_iterator_init_with_response_packet(&it, request_opcode, packet, size); obex_iterator_has_more(&it) ; obex_iterator_next(&it)){
165 uint8_t hi = obex_iterator_get_hi(&it);
166 printf("HI: %x - ", hi);
167 uint8_t encoding = hi >> 6;
168 uint16_t len;
169 switch (encoding){

--- 15 unchanged lines hidden ---