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);
52 char name[INTERFACE_NAME_MAX];
56 char addr[MAX_ADDR_STR_SIZE_CA];
59 typedef struct CAIPCBData_t
61 struct CAIPCBData_t *next;
62 CATransportAdapter_t adapter;
63 CAIPAdapterStateChangeCallback callback;
67 * Set callback for receiving local IP/TCP adapter connection status.
69 * @param[in] callback Callback to be notified when IP/TCP adapter connection state changes.
70 * @param[in] adapter Transport adapter.
71 * @return ::CA_STATUS_OK or Appropriate error code.
73 CAResult_t CAIPSetNetworkMonitorCallback(CAIPAdapterStateChangeCallback callback,
74 CATransportAdapter_t adapter);
77 * Unset callback for receiving local IP/TCP adapter connection status.
79 * @param[in] adapter Transport adapter.
80 * @return ::CA_STATUS_OK or Appropriate error code.
82 CAResult_t CAIPUnSetNetworkMonitorCallback(CATransportAdapter_t adapter);
85 * Get a list of CAInterface_t items.
87 * @param[in] desiredIndex Network interface index.
88 * @return List of CAInterface_t items.
90 u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex);
93 * Find network interface changes.
95 * @return List of CAInterface_t items.
97 u_arraylist_t *CAFindInterfaceChange();
100 * Start network monitor.
102 * @param[in] callback Callback to be notified when IP/TCP adapter connection state changes.
103 * @param[in] adapter Transport adapter.
104 * @return ::CA_STATUS_OK or Appropriate error code.
106 CAResult_t CAIPStartNetworkMonitor(CAIPAdapterStateChangeCallback callback,
107 CATransportAdapter_t adapter);
110 * Stops network monitor.
112 * @param[in] adapter Transport adapter.
113 * @return ::CA_STATUS_OK or Appropriate error code.
115 CAResult_t CAIPStopNetworkMonitor(CATransportAdapter_t adapter);
118 * Apply network interface changes.
120 * @param[in] ifchanged Changed interface.
122 void CAProcessNewInterface(CAInterface_t *ifchanged);
128 #endif /* CA_IP_NW_INTERFACE_H_ */