/* * neard - Near Field Communication manager * * Copyright (C) 2013 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef UNIT_TEST_UTILS_H #define UNIT_TEST_UTILS_H #include #include #include #include #include #include #include #include #include #include #include #include /* SNEP specific types */ struct snep_fragment { uint32_t len; uint8_t *data; }; struct p2p_snep_put_req_data { uint8_t fd; uint32_t adapter_idx; uint32_t target_idx; near_device_io_cb cb; guint watch; GSList *fragments; }; struct p2p_snep_req_frame { uint8_t version; uint8_t request; uint32_t length; uint8_t ndef[]; } __attribute__((packed)); struct p2p_snep_resp_frame { uint8_t version; uint8_t response; uint32_t length; uint8_t info[]; } __attribute__((packed)); /* NDEF specific types */ enum record_type { RECORD_TYPE_WKT_SMART_POSTER = 0x01, RECORD_TYPE_WKT_URI = 0x02, RECORD_TYPE_WKT_TEXT = 0x03, RECORD_TYPE_WKT_SIZE = 0x04, RECORD_TYPE_WKT_TYPE = 0x05, RECORD_TYPE_WKT_ACTION = 0x06, RECORD_TYPE_WKT_HANDOVER_REQUEST = 0x07, RECORD_TYPE_WKT_HANDOVER_SELECT = 0x08, RECORD_TYPE_WKT_HANDOVER_CARRIER = 0x09, RECORD_TYPE_WKT_ALTERNATIVE_CARRIER = 0x0a, RECORD_TYPE_WKT_COLLISION_RESOLUTION = 0x0b, RECORD_TYPE_WKT_ERROR = 0x0c, RECORD_TYPE_MIME_TYPE = 0x0d, RECORD_TYPE_UNKNOWN = 0xfe, RECORD_TYPE_ERROR = 0xff }; struct near_ndef_record_header { uint8_t mb; uint8_t me; uint8_t cf; uint8_t sr; uint8_t il; uint8_t tnf; uint8_t il_length; uint8_t *il_field; uint32_t payload_len; uint32_t offset; uint8_t type_len; enum record_type rec_type; char *type_name; uint32_t header_len; }; struct near_ndef_text_payload { char *encoding; char *language_code; char *data; }; struct near_ndef_uri_payload { uint8_t identifier; uint32_t field_length; uint8_t *field; }; struct near_ndef_sp_payload { struct near_ndef_uri_payload *uri; uint8_t number_of_title_records; struct near_ndef_text_payload **title_records; uint32_t size; /* from Size record*/ char *type; /* from Type record*/ char *action; }; struct near_ndef_record { char *path; struct near_ndef_record_header *header; /* specific payloads */ struct near_ndef_text_payload *text; struct near_ndef_uri_payload *uri; struct near_ndef_sp_payload *sp; struct near_ndef_mime_payload *mime; struct near_ndef_ho_payload *ho; /* handover payload */ char *type; uint8_t *data; size_t data_len; }; void test_ndef_free_record(struct near_ndef_record *record); struct near_ndef_message *test_ndef_create_test_record(const char *str); #endif