1 /******************************************************************
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
22 * @file caipnwmonitor.h
23 * This file provides APIs IP network monitor modules.
26 #ifndef CA_IP_NW_INTERFACE_H_
27 #define CA_IP_NW_INTERFACE_H_
30 #include "cathreadpool.h"
31 #include "uarraylist.h"
38 #define INTERFACE_NAME_MAX 16
41 * Callback to be notified when IP adapter network state changes.
43 * @param[in] adapter Transport adapter.
44 * @param[in] status Connection status either ::CA_INTERFACE_UP or ::CA_INTERFACE_DOWN.
45 * @see CAIPSetConnectionStateChangeCallback() for registration.
47 typedef void (*CAIPAdapterStateChangeCallback)(CATransportAdapter_t adapter,
48 CANetworkStatus_t status);
51 * Structure for IP address information, to be used to construct a CAEndpoint_t. The
52 * structure name is a misnomer, as there is one entry per address not one per interface.
53 * An interface with 4 addresses should result in 4 instances of CAInterface_t.
57 char name[INTERFACE_NAME_MAX];
61 char addr[MAX_ADDR_STR_SIZE_CA];
64 typedef struct CAIPCBData_t
66 struct CAIPCBData_t *next;
67 CATransportAdapter_t adapter;
68 CAIPAdapterStateChangeCallback callback;
72 * Set callback for receiving local IP/TCP adapter connection status.
74 * @param[in] callback Callback to be notified when IP/TCP adapter connection state changes.
75 * @param[in] adapter Transport adapter.
76 * @return ::CA_STATUS_OK or Appropriate error code.
78 CAResult_t CAIPSetNetworkMonitorCallback(CAIPAdapterStateChangeCallback callback,
79 CATransportAdapter_t adapter);
82 * Unset callback for receiving local IP/TCP adapter connection status.
84 * @param[in] adapter Transport adapter.
85 * @return ::CA_STATUS_OK or Appropriate error code.
87 CAResult_t CAIPUnSetNetworkMonitorCallback(CATransportAdapter_t adapter);
90 * Get a list of CAInterface_t items.
92 * @param[in] desiredIndex Network interface index.
93 * @return List of CAInterface_t items.
95 u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex);
98 * Find network interface changes.
100 * @return List of CAInterface_t items.
102 u_arraylist_t *CAFindInterfaceChange();
105 * Start network monitor.
107 * @param[in] callback Callback to be notified when IP/TCP adapter connection state changes.
108 * @param[in] adapter Transport adapter.
109 * @return ::CA_STATUS_OK or Appropriate error code.
111 CAResult_t CAIPStartNetworkMonitor(CAIPAdapterStateChangeCallback callback,
112 CATransportAdapter_t adapter);
115 * Stops network monitor.
117 * @param[in] adapter Transport adapter.
118 * @return ::CA_STATUS_OK or Appropriate error code.
120 CAResult_t CAIPStopNetworkMonitor(CATransportAdapter_t adapter);
126 #endif /* CA_IP_NW_INTERFACE_H_ */