Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frank eitt fix #742

Merged
merged 9 commits into from
Nov 30, 2023
Merged
2 changes: 1 addition & 1 deletion api/oc_discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <inttypes.h>

int basic_resources[] = {
OC_DEV, OC_KNX_DOT_KNX, OC_KNX_SWU, OC_KNX_SUB, OC_KNX_AUTH
OC_DEV, OC_KNX_K, OC_KNX_SWU, OC_KNX_SUB, OC_KNX_AUTH
}; // must be in response if implemented and passed filtering

bool
Expand Down
24 changes: 3 additions & 21 deletions api/oc_knx.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,24 +906,7 @@ oc_core_knx_k_post_handler(oc_request_t *request,
oc_send_response_no_format(request, OC_STATUS_OK);
}

OC_CORE_CREATE_CONST_RESOURCE_LINKED(knx_dot_knx, knx_g, 0, "/.knx",
OC_IF_LI | OC_IF_G, APPLICATION_CBOR,
OC_DISCOVERABLE, oc_core_knx_k_get_handler,
0, oc_core_knx_k_post_handler, 0, NULL,
OC_SIZE_MANY(1), "urn:knx:g.s");

void
oc_create_knx_knx_resource(int resource_idx, size_t device)
{
OC_DBG("oc_create_knx_knx_resource (.knx)\n");

oc_core_populate_resource(resource_idx, device, "/.knx", OC_IF_LI | OC_IF_G,
APPLICATION_CBOR, OC_DISCOVERABLE,
oc_core_knx_k_get_handler, 0,
oc_core_knx_k_post_handler, 0, 1, "urn:knx:g.s");
}

OC_CORE_CREATE_CONST_RESOURCE_LINKED(knx_g, knx_fingerprint, 0, "/k",
OC_CORE_CREATE_CONST_RESOURCE_LINKED(knx_k, knx_fingerprint, 0, "/k",
OC_IF_LI | OC_IF_G, APPLICATION_CBOR,
OC_DISCOVERABLE, oc_core_knx_k_get_handler,
0, oc_core_knx_k_post_handler, 0, NULL,
Expand Down Expand Up @@ -1142,7 +1125,7 @@ oc_core_knx_ldevid_get_handler(oc_request_t *request,
PRINT("oc_core_knx_ldevid_get_handler- done\n");
}

OC_CORE_CREATE_CONST_RESOURCE_LINKED(knx_ldevid, knx_dot_knx, 0,
OC_CORE_CREATE_CONST_RESOURCE_LINKED(knx_ldevid, knx_k, 0,
"/.well-known/knx/ldevid", OC_IF_D,
APPLICATION_PKCS7_CMC_REQUEST,
OC_DISCOVERABLE,
Expand Down Expand Up @@ -1677,8 +1660,7 @@ oc_create_knx_resources(size_t device_index)
}

oc_create_a_lsm_resource(OC_A_LSM, device_index);
oc_create_knx_knx_resource(OC_KNX_DOT_KNX, device_index);
oc_create_knx_knx_resource(OC_KNX_G, device_index);
oc_create_knx_k_resource(OC_KNX_K, device_index);
oc_create_knx_fingerprint_resource(OC_KNX_FINGERPRINT, device_index);
oc_create_knx_ia(OC_KNX_IA, device_index);
oc_create_knx_osn_resource(OC_KNX_OSN, device_index);
Expand Down
29 changes: 21 additions & 8 deletions api/oc_knx_gm.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ oc_core_fp_gm_post_handler(oc_request_t *request,
oc_rep_t *sec_object = NULL;
oc_status_t return_status = OC_STATUS_BAD_REQUEST;
int id = -1;
bool do_save = true;

PRINT("oc_core_fp_gm_post_handler\n");

Expand Down Expand Up @@ -570,9 +571,11 @@ oc_core_fp_gm_post_handler(oc_request_t *request,
g_gm_entries[index].id = id;

// parse the response
bool id_only = true;
object = rep->value.object;
while (object != NULL) {
if (object->type == OC_REP_INT_ARRAY) {
id_only = false;
// ga
if (object->iname == 7) {
int64_t *array = 0;
Expand Down Expand Up @@ -604,12 +607,16 @@ oc_core_fp_gm_post_handler(oc_request_t *request,
}
}
} else if (object->type == OC_REP_INT) {
if (object->iname != 0) {
id_only = false;
}
if (object->iname == 116) {
// dataType (116)
PRINT(" dataType %d\n", (int)object->value.integer);
g_gm_entries[index].dataType = (int)object->value.integer;
}
} else if (object->type == OC_REP_OBJECT) {
id_only = false;
// level of s
s_object = object->value.object;
int s_object_nr = object->iname;
Expand Down Expand Up @@ -655,20 +662,26 @@ oc_core_fp_gm_post_handler(oc_request_t *request,
}
object = object->next;
} // while (inner object)
} // case
} // switch (over all objects)
if (id_only) {
PRINT(" only found id in request, deleting entry at index: %d\n",
index);
oc_delete_group_mapping_table_entry(index);
do_save = false;
}
} // case
} // switch (over all objects)
rep = rep->next;
}

for (int i = 0; i < oc_core_get_group_mapping_table_size(); i++) {
if (g_gm_entries[i].ga_len != 0) {
oc_dump_group_mapping_table_entry(i);
if (do_save) {
for (int i = 0; i < oc_core_get_group_mapping_table_size(); i++) {
if (g_gm_entries[i].ga_len != 0) {
oc_dump_group_mapping_table_entry(i);
}
}
}

request->response->response_buffer->content_format = APPLICATION_CBOR;
request->response->response_buffer->code = oc_status_code(return_status);
request->response->response_buffer->response_length = response_length;
oc_send_response_no_format(request, return_status);
}

OC_CORE_CREATE_CONST_RESOURCE_LINKED(knx_fp_gm, knx_fp_gm_x, 0, "/fp/gm",
Expand Down
6 changes: 3 additions & 3 deletions api/oc_knx_sec.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "oc_knx_helpers.h"

uint64_t g_oscore_replaywindow = 32;
uint64_t g_oscore_osndelay = 0;
uint64_t g_oscore_osndelay = 1000;

/** the list of connections */
//#define G_OCM_MAX_ENTRIES 20
Expand Down Expand Up @@ -138,7 +138,7 @@ oc_core_knx_auth_o_osndelay_put_handler(oc_request_t *request,
}

OC_CORE_CREATE_CONST_RESOURCE_LINKED(knx_auth_o_osndelay, knx_auth_o, 0,
"/auth/o/osndelay", OC_IF_D,
"/auth/o/osndelay", OC_IF_P,
APPLICATION_CBOR, OC_DISCOVERABLE,
oc_core_knx_auth_o_osndelay_get_handler,
oc_core_knx_auth_o_osndelay_put_handler, 0,
Expand Down Expand Up @@ -212,7 +212,7 @@ oc_core_knx_auth_o_replwdo_put_handler(oc_request_t *request,
}

OC_CORE_CREATE_CONST_RESOURCE_LINKED(knx_auth_o_replwdo, knx_auth_o_osndelay, 0,
"/auth/o/replwdo", OC_IF_D,
"/auth/o/replwdo", OC_IF_P,
APPLICATION_CBOR, OC_DISCOVERABLE,
oc_core_knx_auth_o_replwdo_get_handler,
oc_core_knx_auth_o_replwdo_put_handler, 0,
Expand Down
13 changes: 8 additions & 5 deletions api/oc_server_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,18 @@ void
oc_send_cbor_response(oc_request_t *request, oc_status_t response_code)
{
if (request && request->response && request->response->response_buffer) {
request->response->response_buffer->content_format = APPLICATION_CBOR;
int length = 0;
if ((response_code == OC_STATUS_OK) ||
(response_code == OC_STATUS_CHANGED)) {
request->response->response_buffer->response_length = response_length();
length = response_length();
}
if (length > 0) {
request->response->response_buffer->content_format = APPLICATION_CBOR;
request->response->response_buffer->response_length = length;
request->response->response_buffer->code = oc_status_code(response_code);
} else {
request->response->response_buffer->response_length = 0;
oc_send_response_no_format(request, response_code);
}

request->response->response_buffer->code = oc_status_code(response_code);
}
}

Expand Down
3 changes: 1 addition & 2 deletions include/oc_ri.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ typedef enum {
OC_KNX_SPAKE, /**< spake */
OC_KNX_IDEVID, /**< IDevID */
OC_KNX_LDEVID, /**< LDevID */
OC_KNX_DOT_KNX, /**< .knx resource */
OC_KNX_G, /**< g (renamed) .knx resource */
OC_KNX_K, /**< k (renamed) .knx resource */
OC_KNX_FINGERPRINT, /**< FINGERPRINT value of loaded contents */
OC_KNX_IA, /**< .well-known / knx / ia */
OC_KNX_OSN, /**< .well-known / knx / osn */
Expand Down
2 changes: 1 addition & 1 deletion messaging/coap/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ oc_coap_check_if_duplicate(uint16_t mid, uint8_t device)
for (i = 0; i < OC_REQUEST_HISTORY_SIZE; i++) {
if (history[i] == mid && history_dev[i] == device) {
OC_DBG("dropping duplicate request");
OC_DBG("message ID: %d, history[%d]: %d", mid, i, history[i]);
OC_DBG("message ID: %d, history[%d]: %d", mid, (int)i, history[i]);
return true;
}
}
Expand Down