#endif
#ifdef RA_ADAPTER_IBB
+#define SET_BUT_NOT_USED(x) (void) x
/**
* Logging tag for module name.
*/
{
xmpp_t *xmpp;
int port;
- char hostname[RA_MAX_HOSTNAME_LENGTH];
+ char hostName[RA_MAX_HOSTNAME_LENGTH];
char password[RA_MAX_PASSWORD_LENGTH];
char jid[CA_RAJABBERID_SIZE];
- CANetworkStatus_t connection_status;
+ CANetworkStatus_t connectionStatus;
+ CAJidBoundCallback jidBoundCallback;
} CARAXmppData_t;
static ca_mutex g_raadapterMutex = NULL;
-static CARAXmppData_t g_xmppData = {.xmpp = NULL, .port = 5222, .hostname = {0},
- .password = {0}, .jid = {0}, .connection_status = CA_INTERFACE_DOWN};
+static CARAXmppData_t g_xmppData = {.xmpp = NULL, .port = 5222, .hostName = {0},
+ .password = {0}, .jid = {0}, .connectionStatus = CA_INTERFACE_DOWN,
+ .jidBoundCallback = NULL};
static void CARANotifyNetworkChange(const char *address, CANetworkStatus_t status);
{
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CARANotifyNetworkChange IN");
- g_xmppData.connection_status = status;
+ g_xmppData.connectionStatus = status;
CAEndpoint_t *localEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
CA_ADAPTER_REMOTE_ACCESS,
}
else if (option == OBSERVE_DEREGISTER)
{
- obs_item_t *item = ilist_finditem_func(g_observerList, CARAFindSessID, sid);
+ obs_item_t *item = ilist_finditem_func(g_observerList, (find_fp) CARAFindSessID, sid);
if (item != NULL)
{
item->option = OBSERVE_DEREGISTER;
static int CARAErrorCB(xmpp_ibb_session_t *sess, xmpperror_t *xerr)
{
- OIC_LOG_V(DEBUG, RA_ADAPTER_TAG, "%s(): code(%d) tyep'%s' mesg'%s'",
+ OIC_LOG_V(ERROR, RA_ADAPTER_TAG, "%s(): code(%d) tyep'%s' mesg'%s'",
__FUNCTION__, xerr->code, xerr->type, xerr->mesg);
+ SET_BUT_NOT_USED(sess);
+ SET_BUT_NOT_USED(xerr);
return 0;
}
static int CARAOpenCB(xmpp_ibb_session_t *sess, char *type)
{
OIC_LOG_V(DEBUG, RA_ADAPTER_TAG, "%s(): set type '%s'", __FUNCTION__, type);
+ SET_BUT_NOT_USED(sess);
+ SET_BUT_NOT_USED(type);
return 0;
}
{
OIC_LOG_V(DEBUG, RA_ADAPTER_TAG, "%s(): set type '%s'", __FUNCTION__, type);
char *sid = xmpp_ibb_get_sid(sess);
- obs_item_t *item = ilist_finditem_func(g_observerList, CARAFindSessID, sid);
+ obs_item_t *item = ilist_finditem_func(g_observerList, (find_fp) CARAFindSessID, sid);
if (item != NULL)
{
ilist_remove(g_observerList, item);
OICFree(item);
}
+ SET_BUT_NOT_USED(type);
return 0;
}
else
{
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "this is a response data");
- obs_item_t *item = ilist_finditem_func(g_observerList, CARAFindSessID, sid);
+ obs_item_t *item = ilist_finditem_func(g_observerList, (find_fp) CARAFindSessID, sid);
if (item != NULL)
{
if (item->option == OBSERVE_DEREGISTER)
return -1;
}
memcpy(buf, xdata->data, xdata->size);
- g_networkPacketCallback(endPoint, buf, xdata->size);
+ CASecureEndpoint_t sep =
+ {.endpoint = {.adapter = CA_ADAPTER_IP, .flags = CA_DEFAULT_FLAGS}};
+ memcpy(&sep.endpoint, endPoint, sizeof(sep.endpoint));
+ g_networkPacketCallback(&sep, buf, xdata->size);
CAFreeEndpoint (endPoint);
}
{
if (conninfo->connevent != 0)
{
- OIC_LOG_V(DEBUG, RA_ADAPTER_TAG, " status(%d) error(%d) errorType(%d) errorText '%s'\n",
+ OIC_LOG_V(ERROR, RA_ADAPTER_TAG, " status(%d) error(%d) errorType(%d) errorText '%s'\n",
conninfo->connevent, conninfo->error, conninfo->errortype,
conninfo->errortext);
CARANotifyNetworkChange(g_xmppData.jid, CA_INTERFACE_DOWN);
return -1;
}
- OIC_LOG_V(DEBUG, RA_ADAPTER_TAG, "\n\n Bound JID: '%s'\n\n\n", xmpphelper_get_bound_jid(xmpp));
+ OIC_LOG_V(DEBUG, RA_ADAPTER_TAG, "Bound JID: '%s'", xmpphelper_get_bound_jid(xmpp));
+ if (g_xmppData.jidBoundCallback != NULL)
+ {
+ g_xmppData.jidBoundCallback((char *) xmpphelper_get_bound_jid(xmpp));
+ }
CARANotifyNetworkChange(xmpphelper_get_bound_jid(xmpp), CA_INTERFACE_UP);
+ VERIFY_NON_NULL_RET(udata, RA_ADAPTER_TAG, "Invalid parameter!", 0);
return 0;
}
.stopAdapter = CAStopRA,
.terminate = CATerminateRA};
registerCallback(raHandler, CA_ADAPTER_REMOTE_ACCESS);
-
- g_xmppData.xmpp = xmpphelper_new(CARAConnHandler, NULL);
+#ifdef NDEBUG
+ xmpp_log_t *log = xmpp_get_default_logger(XMPP_LEVEL_ERROR);
+#else
+ xmpp_log_t *log = xmpp_get_default_logger(XMPP_LEVEL_DEBUG);
+#endif
+ g_xmppData.xmpp = xmpphelper_new(CARAConnHandler, NULL, log, NULL);
xmpphelper_force_tls(g_xmppData.xmpp);
g_observerList = ilist_new();
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Invalid parameter!");
return CA_STATUS_INVALID_PARAM;
}
- if (caraInfo->hostname != NULL)
+ if (caraInfo->hostName != NULL)
{
- OICStrcpy(g_xmppData.hostname, sizeof(g_xmppData.hostname), caraInfo->hostname);
+ OICStrcpy(g_xmppData.hostName, sizeof(g_xmppData.hostName), caraInfo->hostName);
}
else
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Invalid parameter!");
return CA_STATUS_INVALID_PARAM;
}
- if (caraInfo->username != NULL && strlen(caraInfo->username) != 0)
+ if (caraInfo->userName != NULL && strlen(caraInfo->userName) != 0)
{
- OICStrcpy(g_xmppData.jid, sizeof(g_xmppData.jid), caraInfo->username);
+ OICStrcpy(g_xmppData.jid, sizeof(g_xmppData.jid), caraInfo->userName);
}
else
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Invalid parameter!");
return CA_STATUS_INVALID_PARAM;
}
- if (caraInfo->xmpp_domain != NULL && strlen(caraInfo->xmpp_domain) != 0)
+ if (caraInfo->xmppDomain != NULL && strlen(caraInfo->xmppDomain) != 0)
{
OICStrcat(g_xmppData.jid, sizeof(g_xmppData.jid), "@");
- OICStrcat(g_xmppData.jid, sizeof(g_xmppData.jid), caraInfo->xmpp_domain);
+ OICStrcat(g_xmppData.jid, sizeof(g_xmppData.jid), caraInfo->xmppDomain);
if (caraInfo->resource != NULL && strlen(caraInfo->resource) != 0)
{
OICStrcat(g_xmppData.jid, sizeof(g_xmppData.jid), "/");
OICStrcpy(g_xmppData.password, sizeof(g_xmppData.password), caraInfo->password);
}
g_xmppData.port = caraInfo->port;
+ g_xmppData.jidBoundCallback = caraInfo->jidBoundCallback;
return CA_STATUS_OK;
}
ca_mutex_lock (g_raadapterMutex);
- xmpphelper_connect(g_xmppData.xmpp, g_xmppData.hostname, g_xmppData.port,
+ xmpphelper_connect(g_xmppData.xmpp, g_xmppData.hostName, g_xmppData.port,
g_xmppData.jid, g_xmppData.password);
xmpp_ibb_reg_funcs_t regfuncs;
regfuncs.open_cb = CARAOpenCB;
coap_delete_pdu(pdu);
ca_mutex_lock (g_raadapterMutex);
- if (CA_INTERFACE_UP != g_xmppData.connection_status)
+ if (CA_INTERFACE_UP != g_xmppData.connectionStatus)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Unable to send XMPP message, RA not connected");
ca_mutex_unlock (g_raadapterMutex);
xmpp_ibb_session_t *sess = xmpp_ibb_get_session_by_sid(sid);
if (sess == NULL)
{
- sess = xmpp_ibb_open(xmpphelper_get_conn(g_xmppData.xmpp), remoteEndpoint->addr, sid);
+ sess = xmpp_ibb_open(xmpphelper_get_conn(g_xmppData.xmpp), (char * const) remoteEndpoint->addr, sid);
if (sess == NULL)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "IBB session establish failed!");
CARAUpdateObsList(obsopt, sid);
}
}
- xmppdata_t xdata = {.data = data, .size = dataLength};
+ xmppdata_t xdata = {.data = (char *) data, .size = dataLength};
int rc = xmpp_ibb_send_data(sess, &xdata);
ca_mutex_unlock (g_raadapterMutex);
if (rc < 0)
const void *data, uint32_t dataLength)
{
OIC_LOG(INFO, RA_ADAPTER_TAG, "RA adapter does not support sending multicast data");
+ SET_BUT_NOT_USED(endpoint);
+ SET_BUT_NOT_USED(data);
+ SET_BUT_NOT_USED(dataLength);
return 0;
}
#include "payload_logging.h"
#include "ocremoteaccessclient.h"
+#define SET_BUT_NOT_USED(x) (void) x
// Tracking user input
static int TEST_CASE = 0;
-static const char * MULTICAST_DEVICE_DISCOVERY_QUERY = "/oic/d";
-static const char * MULTICAST_PLATFORM_DISCOVERY_QUERY = "/oic/p";
static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res";
static std::string coapServerIP = "255.255.255.255";
{
OC_LOG (INFO, TAG, "Received vendor specific options. Ignoring");
}
+ SET_BUT_NOT_USED(handle);
return OC_STACK_DELETE_TRANSACTION;
}
return OC_STACK_DELETE_TRANSACTION;
}
+ SET_BUT_NOT_USED(handle);
return OC_STACK_KEEP_TRANSACTION;
}
#ifdef WITH_PRESENCE
{
OC_LOG_V(INFO, TAG, "presenceCB received Null clientResponse");
}
+ SET_BUT_NOT_USED(handle);
return OC_STACK_KEEP_TRANSACTION;
}
#endif
PrintUsage();
break;
}
+ SET_BUT_NOT_USED(handle);
return OC_STACK_KEEP_TRANSACTION;
}
OC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
}
+ SET_BUT_NOT_USED(handle);
return OC_STACK_DELETE_TRANSACTION;
}
OC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
}
+ SET_BUT_NOT_USED(handle);
return OC_STACK_DELETE_TRANSACTION;
}
return ret;
}
+static void jidbound(char *jid)
+{
+ OC_LOG_V(INFO, TAG, "\n\n Bound JID: %s\n\n", jid);
+}
+
int main(int argc, char* argv[])
{
- OCRAInfo_t rainfo = {.hostname = "localhost", .port = 5222,
- .xmpp_domain = "localhost", .username = "test1", .password = "intel123",
- .resource = "", .user_jid = ""};
+ char host[] = "localhost";
+ char user[] = "test1";
+ char pass[] = "intel123";
+ char empstr[] = "";
+ OCRAInfo_t rainfo = {.hostname = host, .port = 5222,
+ .xmpp_domain = host, .username = user, .password = pass,
+ .resource = empstr, .user_jid = empstr, .jidbound = jidbound};
int opt = 0;
while ((opt = getopt(argc, argv, "t:s:p:d:u:w:r:j:")) != -1)