summaryrefslogtreecommitdiff
path: root/src/ndef.c
AgeCommit message (Collapse)AuthorFilesLines
2013-11-13ndef: Implement record payload getterSamuel Ortiz1-0/+8
2013-11-10ndef: ObjectManager conversionSamuel Ortiz1-158/+263
ndef.c handles the Record interface. With the ObjectManager interface, GetProperties is no longer needed.
2013-10-18ndef: Simplify the exported MIME type D-Bus type furtherSamuel Ortiz1-1/+1
And make it less confusable with the MIMEType property.
2013-10-18ndef: Simplify D-Bus exported record type stringsSamuel Ortiz1-2/+2
"Android Application Record (AAR)" is not really D-Bus clients friendly.
2013-08-20core: Do not compare expression against NULLDaniel Wagner1-163/+163
This patch generate via coccinelle with: @ disable is_null,isnt_null1 @ expression E; @@ ( - E == NULL + !E | - E != NULL + E )
2013-08-20core: Use stdbool instead gboolean or near_bool_tDaniel Wagner1-57/+58
This patch has been created via coccinelle: // Rule set 1 f(es, ( - FALSE + false | - TRUE + true ) ,...) @r2@ type T; identifier f; parameter list[n] ps; identifier i; @@ T f(ps, near_bool_t i, ...); @@ identifier r2.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) @@ typedef bool; @@ - near_bool_t + bool // Rule set 2 // This is not a beautiful script but it does the job. // Improvemtents are welcome. // Fix all assigments but do not convert yet the type @@ gboolean x; @@ x = ( - TRUE + true | - FALSE + false ) // Figure out which function signature will to be fixed... // when we have the defitition @r@ identifier f; parameter list[n] ps; identifier i; @@ f(ps, gboolean i, ...) { ... } // ... and now convert all call sites @@ identifier r.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) // Figure out which function signature will to be fixed... // when we have the declaration only @r2@ type T; identifier f; parameter list[n] ps; identifier i; @@ T f(ps, gboolean i, ...); // ... and now convert all call sites @@ identifier r2.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) // A handfull of the GLib hooks we can't change. Let's remember // all ther positions. // 1. timeouts @k1@ identifier f; position p; typedef gpointer; identifier ptr; @@ static gboolean@p f(gpointer ptr); @k2@ identifier f; position p; identifier ptr; @@ static gboolean@p f(gpointer ptr) { ... } // hash map iterator functions @k3@ identifier f; position p; identifier p1, p2, p3; @@ static gboolean@p f(gpointer p1, gpointer p2, gpointer p3) { ... } // 2. GIOChannel @k4@ identifier f; position p; typedef GIOChannel, GIOCondition; identifier ptr; identifier ch, cn; @@ static gboolean@p f(GIOChannel *ch, GIOCondition cn, gpointer ptr); @k5@ identifier f; position p; identifier ptr; identifier ch, cn; @@ static gboolean@p f(GIOChannel *ch, GIOCondition cn, gpointer ptr) { ... } // 3. GSourceFuncs @k6@ identifier f; position p; typedef GSource; identifier src; @@ static gboolean@p f(GSource *src, ...) { ... } // gdbus functions @k7@ identifier f; position p; typedef DBusConnection; identifier con; @@ static gboolean@p f(DBusConnection *con, ...) { ... } // Now convert all gboolean which are are not used for interactin // with GLib // Note here happens the magic! @@ typedef bool; position p != {k1.p,k2.p,k3.p,k4.p,k5.p,k6.p,k7.p}; @@ - gboolean@p + bool // Update all return types @@ identifier f; @@ bool f(...) { <... - return TRUE; + return true; ...> } @@ identifier f; @@ bool f(...) { <... - return FALSE; + return false; ...> } // Rule set 3 @@ expression E; symbol TRUE; symbol FALSE; @@ ( E - == TRUE | - TRUE == E + E | - E != TRUE + !E | - TRUE != E + !E | - E == FALSE + !E | - FALSE == E + !E | E - != FALSE | - FALSE != E + E )
2013-07-18ndef: Make near_ndef_prepare_ac_message ready for multibyte cdrSzymon Janc1-14/+21
This allows to acctually create multibye cdr if needed. Currently neard always use one byte cdr but let us be in match with spec and a bit more future proof.
2013-07-18ndef: Make near_ndef_prepare_cfg_message accept cdr as pointerSzymon Janc1-4/+6
This allows to acctually create multibye cdr if needed. Currently neard always use one byte cdr but let us be in match with spec and a bit more future proof.
2013-07-18ndef: Remove unused struct near_ndef_carrier_dataSzymon Janc1-10/+0
This is not used anywhere in the code.
2013-07-18ndef: Make cdr in near_ndef_ac_payload multibyteSzymon Janc1-3/+11
cdr is a multibyte field. This removes assumption in code that cdr is one byte only.
2013-07-02ndef: Add raw MIME payload supportLouis Yung-Chieh Lo1-1/+77
Additional to wifi_wsc MIME type, raw parameter is provided for sending raw MIME payload as NDEF. See test/push-device for usage.
2013-07-02ndef: Display AAR package name as a debug stringSamuel Ortiz1-0/+2
2013-06-27ndef: Parse AAR payloadSamuel Ortiz1-2/+67
Android Application Record payload simply contains the Android Market package name.
2013-06-27ndef: Initial support for Android Application RecordsSamuel Ortiz1-0/+15
AAR are Android external NDEF records that contain an Android package name.
2013-06-21ndef: Support receiving empty Handover select framesSamuel Ortiz1-0/+7
Empty handover select frames are received when the peer notifies us about not supporting any of the carrier sent in the handover request frame. In that case there is nothing to do but disconnecting from the handover service.
2013-06-20ndef: Send empty WiFi carrier in Hr message when running as a STARavi kumar Veeramally1-3/+43
When running as a 802.11 STA, the Hr should contain an empty WiFi carrier as we're just asking for WiFi availability from the peer. Also when running in AP mode, an Hr is not a valid frame to send as an AP will not be able to initiate the association.
2013-06-20ndef: Implement static handoverSamuel Ortiz1-0/+4
static handover is going through a different D-Bus path as it would not make sense to handle both static and dynamic handover from the same code path. Static handover means an application explicitely requires to send a handover select without having previously received a handover request. This could typically be used for handling WiFi handover through configuration token from the registrar perspective. The registrar (a.k.a. the Access Point) would send a configuration token via Handover and expects the Enrolle (a.k.a. the WiFi STA) to initiate the WiFi association.
2013-06-20ndef: Generalize near_ndef_prepare_hr_message()Samuel Ortiz1-34/+68
near_ndef_prepare_hr_message can be used for building Hr frames but also Hs ones for static handover. So generalize and factorize it and also rename it to near_ndef_prepare_ho_message().
2013-06-19ndef: Rename near_ndef_prepare_hs_messageSamuel Ortiz1-2/+2
near_ndef_prepare_hs_message() does not prepare a generic handover select message but rather a reply to a handover request. Those 2 have to be differentiated in order to implement static handover where a handover select frame is sent without having first seen a handover request.
2013-06-19ndef: Rename build_ho_recordSamuel Ortiz1-5/+5
build_ho_record is used for initiating negotiated handover, so it will only send handover requests. As such, rename build_ho_record to build_hr_record.
2013-06-18ndef: Fallback to the WiFi agent when missing an SSIDSamuel Ortiz1-2/+34
When the D-Bus message does not contain an SSID (and optionalyy a passphrase) then we fallback to the WiFi WSC agent. If it's running in tethering mode then it will reply with an already built WSC TLV array. This is needed to push WiFi WSC configuration token over SNEP. Android is going to support that as a simplified WiFi Handover.
2013-06-12ndef: Do not fail if NDEF record MIME type is not a handover oneSamuel Ortiz1-5/+6
NDEFs with MIME type records that are not WSC or Bluetooth ones are not wrong. Their payload won't be processed but the record is kept and linked to the discovered tag. NDEF agents will get the binary payload. Fixes #NFC-45
2013-04-05ndef: Add api to prepare mime type wsc recordRavi kumar Veeramally1-13/+15
Added api to prepare MIME type WSC record for unit tests.
2013-04-05ndef: Remove unnecessary debug statementRavi kumar Veeramally1-3/+0
Removed unnecessary debug statement which is added with 56a275c8841352a9c8a60bdcb3e63ba69fe783c6 commit.
2013-04-04ndef: Add support to build wifi_wsc mime type ndef recordRavi kumar Veeramally1-0/+163
Implemented mime type record building upon dbus request. Currently it supports application/vnd.wfa.wsc.
2013-03-28ndef: Remove not used Doxygen annotationsSzymon Janc1-174/+11
As previous commit shows doxygen annotation are not really used. Those annotations require also more focus when reading (and mostly describe obvious parts of the code) comparing to simple comments. Also not used doxygen annotations tend to drift away from actual code and simply confuse developer. Simply remove doxygen annotations as functions and params names are self-explanatory anyway. Some comments where left to document non-obvious behaviour.
2013-03-28ndef: Remove bogus text from near_ndef_parse_msg commentSzymon Janc1-2/+0
This was accidentally pasted in commit 8a141753.
2013-03-28ndef: Use sizeof instead of strlen to get BT_MIME_STRING_2_0 lenSzymon Janc1-1/+1
This is a constant string and there is no need to calculate its length in runtime.
2013-03-28ndef: Fix some typos in comments and debug messagesSzymon Janc1-7/+7
2013-03-28ndef: Simplify near_ndef_prepare_ac_and_cfg_records functionSzymon Janc1-27/+10
Make error path a bit cleaner and easier to understand. This also makes code less confusing to some GCC version (eg. 4.6.3 on Debian ARM) about variables mime_type and cdr being used without initialization. make --no-print-directory all-am CC src/ndef.o src/ndef.c: In function ‘near_ndef_prepare_ac_and_cfg_records’: src/ndef.c:1758:6: error: ‘mime_type’ may be used uninitialized in this function [-Werror=uninitialized] src/ndef.c:1781:8: note: ‘mime_type’ was declared here src/ndef.c:1835:36: error: ‘cdr’ may be used uninitialized in this function [-Werror=uninitialized] cc1: all warnings being treated as errors make[1]: *** [src/ndef.o] Error 1 make: *** [all] Error 2
2013-03-22ndef: Fix typo in unknown carrier stringGuillem Jover1-1/+1
2013-03-11ndef: Fix local carrier data fetching error messageSamuel Ortiz1-2/+6
2013-02-28ndef: Add support for multiple carriersRavi kumar Veeramally1-344/+115
Support for mutliple carrier handling for tag and p2p device. In case of tag (tag with simple mime type or with static handover data): First detects number of carriers in a tag and try to connect/associate with carrier. If connection or association failed then go for next carrier otherwise return success. In case of p2p device (either neard receiving Hr and sending Hr): If neard receives Hr message with multiple carriers (e.g. bt and wifi), first extracts multiple carriers data and reply back with neard's alternative carrier capacity (e.g. It could be 'bt' or 'wifi' or both or empty). If neard wants to negotiate handover with other p2p device it sends Hr with available carriers (e.g. bt ot wifi or both, if there are no carriers replies error to dbus request). After receiving Hs from other p2p device, it tries to connect/associate with carriers (ho agents).
2013-02-28ndef: Add support for multiple carriers in Hr messageRavi kumar Veeramally1-42/+26
Added support for multiple carrriers request for Hr message. For multiple carriers dbus request has to be comma separated strings (e.g. bluetooth,wifi).
2013-02-28ndef: Implement Hr message preparation routineRavi kumar Veeramally1-0/+114
To support multiple carriers in handover request message, implemented seperate function for handover request message.
2013-02-28ndef: Implement Hs message preparation routineRavi kumar Veeramally1-7/+122
To support multiple carriers in handover select message, implemented seperate function for handover select message.
2013-02-28ndef: Add helper funtions to create handover messagesRavi kumar Veeramally1-1/+186
Providing helper functions to create Hanodver select and request messages.
2013-02-28ndef: Return empty Hs in case of unsupported Hr versionRavi kumar Veeramally1-1/+65
Return empty handover select message for unsupported versions of handover request message. Implementing separate functions for empty Hs, Hs with carriers and Hr messages. Next patches contain these functionality. Separating them because each message requires different input parameters and preparation conditions. Handover message preparation is bit different and bigger than other ndef message types. Also handover messages contain multiple alterative carriers, configuration messages, collision and error records.
2013-02-28ndef: Add helper function to free ndef messagesRavi kumar Veeramally1-58/+23
Added helper funtion to free ndef message structure data. It is quite helpful to reduce code redundancy.
2013-02-12ndef: Send empty Hs when an Hr carries a single unknow type carrierOlivier Guiter1-1/+13
This fixes handover validation test #6. Check that the remote handover server returns a select message without alternative carriers if a single carrier of unknown type was sent with the handover request.
2013-02-12ndef: Send empty Hs frame when the Hr version check failsOlivier Guiter1-1/+16
This fixes handover validation test #3. Verify that the remote handover server handles historic and future handover request version numbers. The test failed on step 4 (Check version 15.0).
2013-02-12ndef: Do not build a reply to handover select messagesOlivier Guiter1-1/+1
Handover select frames must not be replied to. This fixes the following bt-handover error: "ERROR:dbus.connection:Exception in handler for D-Bus signal"
2013-02-11agent: Add an extra parameter to the handover registration agent apiRavi kumar Veeramally1-4/+6
Current handover registration apis does not support for carrier specific registration. Added an extra parameter (carrier type) to RegisterHandoverAgent and UnregisterHandoverAgent. This is an initial patch for wifi handover agent registration. WiFi NDEF message handling will be supported soon.
2013-02-11near: Rename struct name bt_data to carrier_dataRavi kumar Veeramally1-4/+4
To be more generic, renaming structure name from bt_data to carrier_data.
2013-01-31ndef: Fix error message in near_ndef_prepare_handover_recordSzymon Janc1-1/+1
This function is used to create both Hs and Hr records.
2013-01-31ndef: Fix checking for error in parse_mime_typeSzymon Janc1-7/+9
Upper layer don't know if action will be held or not when providing ndef_message for reply. It is possible that reply was provided but not used and this is not always an error
2013-01-31ndef: Remove not needed AC payload creation in build_ho_recordSzymon Janc1-34/+0
It was not used to create ndef message as AC recors is created inside near_ndef_prepare_handover_record based on response from HO agent.
2013-01-31ndef: Use stack variable for record in build_ho_recordSzymon Janc1-17/+14
There is no need to dynamically allocate record as it is not used after build_ho_record returns.
2013-01-31ndef: Fix memory leak in build_ho_recordSzymon Janc1-2/+3
record data needs to be freed before returning ndef. 144 (80 direct, 64 indirect) bytes in 1 blocks are definitely lost in loss record 142 of 190 at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4E7FBFD: g_try_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) by 0x424477: __ndef_build_from_message (ndef.c:2950) by 0x41CEE3: push_ndef (device.c:276) by 0x40B850: process_message.isra.4 (object.c:285) by 0x5143C40: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8) by 0x5135B0F: dbus_connection_dispatch (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8) by 0x409247: message_dispatch (mainloop.c:76) by 0x4E7A91A: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) by 0x4E79D52: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) by 0x4E7A09F: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) by 0x4E7A499: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
2013-01-31ndef: Prepare ac record with proper BT power stateSzymon Janc1-8/+9
When adding AC record for BT handover user state provided in bt_data to properly indicate BT carrier power state.