Bjoern Johansson | df74cb4 | 2018-08-23 16:43:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018, The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <stddef.h> |
| 20 | |
| 21 | #ifdef __cplusplus |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | struct ifMonitor; |
| 26 | |
| 27 | struct ifAddress { |
| 28 | int family; |
| 29 | int prefix; |
| 30 | unsigned char addr[16]; |
| 31 | }; |
| 32 | |
| 33 | // A callback for when the addresses on an interface changes |
| 34 | typedef void (*ifMonitorCallback)(unsigned int /*interface index*/, |
| 35 | const struct ifAddress* /*addresses*/, |
| 36 | size_t /*number of addresses */); |
| 37 | |
| 38 | struct ifMonitor* ifMonitorCreate(); |
| 39 | void ifMonitorFree(struct ifMonitor* monitor); |
| 40 | |
| 41 | void ifMonitorSetCallback(struct ifMonitor* monitor, |
| 42 | ifMonitorCallback callback); |
| 43 | void ifMonitorRunAsync(struct ifMonitor* monitor); |
| 44 | void ifMonitorStop(struct ifMonitor* monitor); |
| 45 | |
| 46 | #ifdef __cplusplus |
| 47 | } // extern "C" |
| 48 | #endif |
| 49 | |