omr-publisher.h revision 1.1 1 /* omr-publisher.h
2 *
3 * Copyright (c) 2023 Apple Inc. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * This file contains general support definitions for the Off-Mesh Routable
18 * (OMR) prefix publisher state machine.
19 */
20
21 #ifndef __OMR_PUBLISHER_H__
22 #define __OMR_PUBLISHER_H__ 1
23
24 typedef struct dhcpv6_client dhcpv6_client_t;
25 typedef struct br_event br_event_t;
26 typedef struct omr_publisher omr_publisher_t;
27
28 #define OMR_PUBLISHER_START_WAIT 15 * 1000 // Start wait interval is random(0..15) seconds
29 #define OMR_PUBLISHER_DHCP_SUCCESS_WAIT 1500 // one and a half seconds (no need for jitter since we already jittered)
30 #define OMR_PUBLISHER_MIN_START 3000 // three seconds (minimum, for new router coming to existing network)
31
32 RELEASE_RETAIN_DECLS(omr_publisher);
33 #define omr_publisher_retain(publisher) omr_publisher_retain_(publisher, __FILE__, __LINE__)
34 #define omr_publisher_release(publisher) omr_publisher_release_(publisher, __FILE__, __LINE__)
35 void omr_publisher_cancel(omr_publisher_t *NONNULL publisher);
36 omr_publisher_t *NULLABLE omr_publisher_create(route_state_t *NONNULL route_state, const char *NONNULL name);
37 void omr_publisher_set_omr_watcher(omr_publisher_t *NONNULL omr_publisher, omr_watcher_t *NONNULL omr_watcher);
38 void omr_publisher_set_reconnect_callback(omr_publisher_t *NONNULL omr_publisher,
39 void (*NULLABLE reconnect_callback)(void *NULLABLE context));
40 void omr_publisher_start(omr_publisher_t *NONNULL publisher);
41 omr_prefix_t *NULLABLE omr_publisher_published_prefix_get(omr_publisher_t *NONNULL publisher);
42 void omr_publisher_force_publication(omr_publisher_t *NONNULL publisher, omr_prefix_priority_t priority);
43 void omr_publisher_interface_configuration_changed(omr_publisher_t *NONNULL publisher);
44 bool omr_publisher_publishing_dhcp(omr_publisher_t *NONNULL publisher);
45 bool omr_publisher_publishing_ula(omr_publisher_t *NONNULL publisher);
46 bool omr_publisher_publishing_prefix(omr_publisher_t *NONNULL publisher);
47
48 // The OMR publisher knows whether the prefix being published can be used for routing, even if it's not publishing it itself.
49 // If there is a medium- or high-priority prefix published by some other router, that prefix can be assumed to be routable.
50 // If the OMR publisher is publishing a DHCP route, that prefix can be assumed to be routable. If another router is publishing
51 // a low-priority prefix, or OMR publisher is, that prefix can't be used for routing off of the adjacent infrastructure link.
52 // Of course it still works for routing between Thread and the adjacent infrastructure link--what it can't be used for is
53 // routing across a multi-link infrastructure network or to the internet.
54 bool omr_publisher_have_routable_prefix(omr_publisher_t *NONNULL publisher);
55
56 // Check that the prefix that we saw in an RA is not also the one we are publishing on Thread. This can happen with broken DHCP
57 // PD servers, and we have seen it in some home routers.
58 void omr_publisher_check_prefix(omr_publisher_t *NULLABLE publisher, struct in6_addr *NONNULL prefix, int len);
59
60 void omr_publisher_unpublish_prefix(omr_publisher_t *NONNULL publisher);
61 #endif // __OMR_PUBLISHER_H__
62
63 // Local Variables:
64 // mode: C
65 // tab-width: 4
66 // c-file-style: "bsd"
67 // c-basic-offset: 4
68 // fill-column: 120
69 // indent-tabs-mode: nil
70 // End:
71