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