/**
* @file caipinterface.h
- * @brief This file provides APIs IP client/server/network monitor modules
+ * This file provides APIs IP client/server/network monitor modules.
*/
#ifndef CA_IP_INTERFACE_H_
#endif
/**
- * @enum CAAdapterServerType_t
- * @brief Enum for defining different server types.
+ * Enum for defining different server types.
*/
typedef enum
{
} CAAdapterServerType_t;
/**
- * @brief Callback to be notified on reception of any data from remote OIC devices.
+ * Callback to be notified on reception of any data from remote OIC devices.
*
- * @param endpoint [IN] network endpoint description
- * @param data [IN] Data received from remote OIC device.
- * @param dataLength [IN] Length of data in bytes.
- *
- * @return NONE
- * @pre Callback must be registered using CAIPSetPacketReceiveCallback()
+ * @param[in] sep network endpoint description.
+ * @param[in] data Data received from remote OIC device.
+ * @param[in] dataLength Length of data in bytes.
+ * @pre Callback must be registered using CAIPSetPacketReceiveCallback().
*/
-typedef void (*CAIPPacketReceivedCallback)(const CAEndpoint_t *endpoint,
+typedef void (*CAIPPacketReceivedCallback)(const CASecureEndpoint_t *sep,
const void *data,
uint32_t dataLength);
/**
- * @brief Callback to notify error in the IP adapter
+ * Callback to notify error in the IP adapter.
*
- * @param endpoint [IN] [IN] network endpoint description
- * @param data [IN] Data sent/received
- * @param dataLength [IN] Length of data in bytes.
- * @param result [IN] result of request from R.I
- * @return NONE
- * @pre Callback must be registered using CAIPSetPacketReceiveCallback()
+ * @param[in] endpoint network endpoint description.
+ * @param[in] data Data sent/received.
+ * @param[in] dataLength Length of data in bytes.
+ * @param[in] result result of request from R.I.
+ * @pre Callback must be registered using CAIPSetPacketReceiveCallback().
*/
typedef void (*CAIPErrorHandleCallback)(const CAEndpoint_t *endpoint, const void *data,
uint32_t dataLength, CAResult_t result);
/**
- * @brief Callback to be notified when exception occures on multicast/unicast server.
- * @param type [IN] Type of server(#CAAdapterServerType_t)
- * @return NONE
- * @pre Callback must be registered using CAIPSetExceptionCallback()
+ * Callback to be notified when exception occures on multicast/unicast server.
+ * @param type Type of server(#CAAdapterServerType_t).
+ * @pre Callback must be registered using CAIPSetExceptionCallback().
*/
typedef void (*CAIPExceptionCallback)(CAAdapterServerType_t type);
/**
- * @brief Start IP server
- *
- * @param threadPool [IN] Thread pool for managing Unicast/Multicast server threads.
+ * Start IP server.
*
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK Successful
- * @retval #CA_STATUS_INVALID_PARAM Invalid input data
- * @retval #CA_STATUS_FAILED Initialization failed
+ * @param threadPool Thread pool for managing Unicast/Multicast server threads.
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK Successful.
+ * @retval ::CA_STATUS_INVALID_PARAM Invalid input data.
+ * @retval ::CA_STATUS_FAILED Initialization failed.
*/
#ifdef SINGLE_THREAD
CAResult_t CAIPStartServer();
#endif
/**
- * @brief Stop IP server
- * @return NONE
+ * Stop IP server.
*/
void CAIPStopServer();
/**
- * @brief Set this callback for receiving data packets from peer devices.
+ * Starts receiving the multicast traffic.
*
- * @param callback [IN] Callback to be notified on reception of unicast/multicast data packets.
+ * This will be used in case sleepy device wants to start back receiving the multicast
+ * traffic.
+ */
+CAResult_t CAIPStartListenServer();
+
+/**
+ * Stops the multicast traffic.
*
- * @return NONE
+ * This is to be used by the sleeping device to stop receiving multicast traffic.
+ * Once this is set no multicast traffic will be received. Device can still receive
+ * the unicast traffic.
*/
-void CAIPSetPacketReceiveCallback(CAIPPacketReceivedCallback callback);
+CAResult_t CAIPStopListenServer();
/**
- * @brief Set this callback for receiving exception notifications.
+ * Set this callback for receiving data packets from peer devices.
*
- * @param callback [IN] Callback to be notified on occurance of exception on running servers.
+ * @param[in] callback Callback to be notified on reception of unicast/multicast data packets.
+ */
+void CAIPSetPacketReceiveCallback(CAIPPacketReceivedCallback callback);
+
+/**
+ * Set this callback for receiving exception notifications.
*
- * @return NONE
+ * @param[in] callback Callback to be notified on exception on running servers.
*/
void CAIPSetExceptionCallback(CAIPExceptionCallback callback);
/**
- * @brief Set socket description for sending unicast UDP data. Once the Unicast server is started,
- * the same socket descriptor is used for sending the Unicast UDP data.
+ * Set socket description for sending unicast UDP data.
+ * Once the Unicast server is started,
+ * the same socket descriptor is used for sending the Unicast UDP data.
*
- * @param socketFD [IN] Socket descriptor used for sending UDP data.
- * @return NONE
+ * @param[in] socketFD Socket descriptor used for sending UDP data.
*/
void CAIPSetUnicastSocket(int socketFD);
/**
- * @brief Set the port number for sending unicast UDP data
- * @param port [IN] Port number used for sending UDP data.
- * @return NONE
+ * Set the port number for sending unicast UDP data.
+ * @param[in] port Port number used for sending UDP data.
*/
void CAIPSetUnicastPort(uint16_t port);
/**
- * @brief API to send unicast UDP data
+ * API to send unicast UDP data.
*
- * @param endpoint [IN] complete network address to send to
- * @param data [IN] Data to be send.
- * @param dataLength [IN] Length of data in bytes
- * @param isMulticast [IN] Whether data needs to be sent to multicast ip
+ * @param[in] endpoint complete network address to send to.
+ * @param[in] data Data to be send.
+ * @param[in] dataLength Length of data in bytes.
+ * @param[in] isMulticast Whether data needs to be sent to multicast ip.
*/
void CAIPSendData(CAEndpoint_t *endpoint,
const void *data,
bool isMulticast);
/**
- * @brief Get IP adapter connection state.
+ * Get IP adapter connection state.
*
- * @return True if IP adapter is connected, otherwise false
+ * @return True if IP adapter is connected, otherwise false.
*/
bool CAIPIsConnected();
/**
- * @brief Pull the Received Data
- * @return NONE
+ * Pull the Received Data.
*/
void CAIPPullData();
uint32_t index;
uint32_t flags;
uint16_t family;
- uint32_t ipv4addr; // used for IPv4 only
+ uint32_t ipv4addr; /**< used for IPv4 only. */
} CAInterface_t;
/**
- * @brief Get a list of CAInterface_t items
+ * Get a list of CAInterface_t items.
*
- * @return List of CAInterface_t items
+ * @return List of CAInterface_t items.
*/
u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex);
/**
- * @brief Set callback for error handling
+ * @brief Find a new network interface.
+ *
+ * @return Description of interface (or NULL if no change)
+ */
+CAInterface_t *CAFindInterfaceChange();
+
+/**
+ * @brief Let the network monitor update the polling interval.
+ * @param [in] current polling interval
+ *
+ * @return desired polling interval
+ */
+int CAGetPollingInterval(int interval);
+
+/**
+ * @brief Tell the IP server an interface has been added.
+ */
+void CAWakeUpForChange();
+
+/**
+ * Start network monitor.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CAIPStartNetworkMonitor();
+
+/**
+ * Stops network monitor.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CAIPStopNetworkMonitor();
+
+/**
+ * @brief Set callback for error handling.
*
- * @param ipErrorCallback [IN] callback to notify error to the ipadapter
- * @return NONE
+ * @param[in] ipErrorCallback callback to notify error to the ipadapter.
*/
void CAIPSetErrorHandleCallback(CAIPErrorHandleCallback ipErrorCallback);