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

Added guards around Lwm2mCore_DebugPrintSockAddr which is not supported by CONTIKI #146

Merged
merged 1 commit into from May 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions core/src/client/lwm2m_client_xml_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ static int xmlif_HandlerConnectRequest(RequestInfoType * request, TreeNode conte
(IPCSession_New(request->SessionID) == 0) &&
(IPCSession_AddRequestChannel(request->SessionID, request->Sockfd, &request->FromAddr, request->AddrLen) == 0))
{
#ifndef CONTIKI
Lwm2m_Info("IPC connected from %s - allocated session ID %d\n", Lwm2mCore_DebugPrintSockAddr(&request->FromAddr), request->SessionID);
#endif
IPC_SendResponse(response, request->Sockfd, &request->FromAddr, request->AddrLen);
Tree_Delete(response);
}
Expand All @@ -540,8 +542,9 @@ static int xmlif_HandlerEstablishNotifyRequest(RequestInfoType * request, TreeNo
{
if (IPCSession_AddNotifyChannel(request->SessionID, request->Sockfd, &request->FromAddr, request->AddrLen) == 0)
{
#ifndef CONTIKI
Lwm2m_Info("IPC Notify session %d connected from %s\n", request->SessionID, Lwm2mCore_DebugPrintSockAddr(&request->FromAddr));

#endif
TreeNode response = IPC_NewResponseNode(IPC_MESSAGE_SUB_TYPE_ESTABLISH_NOTIFY, AwaResult_Success, request->SessionID);
IPC_SendResponse(response, request->Sockfd, &request->FromAddr, request->AddrLen);
Tree_Delete(response);
Expand All @@ -561,8 +564,9 @@ static int xmlif_HandlerEstablishNotifyRequest(RequestInfoType * request, TreeNo
static int xmlif_HandlerDisconnectRequest(RequestInfoType * request, TreeNode content)
{
// No check for known client - proceed regardless.
#ifndef CONTIKI
Lwm2m_Info("IPC disconnected from %s\n", Lwm2mCore_DebugPrintSockAddr(&request->FromAddr));

#endif
//TODO: cleanup for notify channel

TreeNode response = IPC_NewResponseNode(IPC_MESSAGE_SUB_TYPE_DISCONNECT, AwaResult_Success, request->SessionID);
Expand Down
2 changes: 2 additions & 0 deletions core/src/common/ipc_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,10 @@ void IPCSession_Dump(void)
if (session != NULL)
{
printf("Session ID %d:\n", session->SessionID);
#ifndef CONTIKI
printf(" Request Channel: Sockfd %d, FromAddr %s, AddrLen %d\n", session->RequestChannel.Sockfd, Lwm2mCore_DebugPrintSockAddr(&session->RequestChannel.FromAddr), session->RequestChannel.AddrLen);
printf(" Notify Channel: Sockfd %d, FromAddr %s, AddrLen %d\n", session->NotifyChannel.Sockfd, Lwm2mCore_DebugPrintSockAddr(&session->NotifyChannel.FromAddr), session->NotifyChannel.AddrLen);
#endif
}
}
}
2 changes: 1 addition & 1 deletion core/src/common/lwm2m_bootstrap_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const BootstrapInfo * BootstrapInformation_ReadConfigFile(const char * configFil
FILE * f = fopen(configFile, "rt");
if (f == NULL)
{
Lwm2m_Error("Configuration file not found\n");
Lwm2m_Error("Configuration file not found: %s\n", configFile);
free(bootstrapInfo);
bootstrapInfo = NULL;
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/common/lwm2m_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void Lwm2mCore_AddressTypeToPath(char * path, size_t pathSize, AddressType * add
#endif
}

#ifndef CONTIKI
const char * Lwm2mCore_DebugPrintSockAddr(const struct sockaddr * sa)
{
static char out[255];
Expand All @@ -180,6 +181,7 @@ const char * Lwm2mCore_DebugPrintSockAddr(const struct sockaddr * sa)
}
return out;
}
#endif

const char * Lwm2mCore_DebugPrintAddress(AddressType * addr)
{
Expand Down
4 changes: 4 additions & 0 deletions core/src/common/lwm2m_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ int32_t ptrToInt32(void * ptr);
int64_t ptrToInt64(void * ptr);

void Lwm2mCore_AddressTypeToPath(char * path, size_t pathSize, AddressType * addr);

#ifndef CONTIKI
const char * Lwm2mCore_DebugPrintSockAddr(const struct sockaddr * sa);
#endif
const char * Lwm2mCore_DebugPrintAddress(AddressType * addr);

int Lwm2mCore_ResolveAddressByName(unsigned char * address, int addressLength, AddressType * addr);
int Lwm2mCore_CompareAddresses(AddressType * addr1, AddressType * addr2);
int Lwm2mCore_ComparePorts(AddressType * addr1, AddressType * addr2);
Expand Down
8 changes: 6 additions & 2 deletions core/src/server/lwm2m_server_xml_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,9 @@ static int xmlif_HandlerConnectRequest(RequestInfoType * request, TreeNode conte
(IPCSession_New(request->SessionID) == 0) &&
(IPCSession_AddRequestChannel(request->SessionID, request->Sockfd, &request->FromAddr, request->AddrLen) == 0))
{
#ifndef CONTIKI
Lwm2m_Info("IPC connected from %s - allocated session ID %d\n", Lwm2mCore_DebugPrintSockAddr(&request->FromAddr), request->SessionID);
#endif
IPC_SendResponse(response, request->Sockfd, &request->FromAddr, request->AddrLen);
Tree_Delete(response);
}
Expand All @@ -656,8 +658,9 @@ static int xmlif_HandlerEstablishNotifyRequest(RequestInfoType * request, TreeNo
{
if (IPCSession_AddNotifyChannel(request->SessionID, request->Sockfd, &request->FromAddr, request->AddrLen) == 0)
{
#ifndef CONTIKI
Lwm2m_Info("IPC Notify session %d connected from %s\n", request->SessionID, Lwm2mCore_DebugPrintSockAddr(&request->FromAddr));

#endif
// Set up registration callbacks for Events
EventContext * eventContext = EventContext_New(request);
Lwm2m_AddRegistrationEventCallback(request->Context, request->SessionID, xmlif_HandleRegistrationEvent, eventContext);
Expand All @@ -680,8 +683,9 @@ static int xmlif_HandlerEstablishNotifyRequest(RequestInfoType * request, TreeNo

static int xmlif_HandlerDisconnectRequest(RequestInfoType * request, TreeNode content)
{
#ifndef CONTIKI
Lwm2m_Info("IPC disconnected from %s\n", Lwm2mCore_DebugPrintSockAddr(&request->FromAddr));

#endif
TreeNode response = IPC_NewResponseNode(IPC_MESSAGE_SUB_TYPE_DISCONNECT, AwaResult_Success, request->SessionID);
IPC_SendResponse(response, request->Sockfd, &request->FromAddr, request->AddrLen);
Lwm2m_DeleteRegistrationEventCallback(request->Context, request->SessionID);
Expand Down