]> git.saurik.com Git - apple/mdnsresponder.git/blob - ServiceRegistration/srp-gw.h
mDNSResponder-1310.40.42.tar.gz
[apple/mdnsresponder.git] / ServiceRegistration / srp-gw.h
1 /* srp-gw.c
2 *
3 * Copyright (c) 2019 Apple Computer, 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 * http://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 * Structure definitions for the Service Registration Protocol gateway.
18 */
19
20 typedef struct subnet subnet_t;
21 struct subnet {
22 subnet_t *NULLABLE next;
23 uint8_t preflen;
24 uint8_t family;
25 char bytes[8];
26 };
27
28 typedef struct udp_validator udp_validator_t;
29 struct udp_validator {
30 udp_validator_t *NULLABLE next;
31 char *NONNULL ifname;
32 int ifindex;
33 subnet_t *NONNULL subnets;
34 };
35
36 typedef struct delete delete_t;
37 struct delete {
38 delete_t *NULLABLE next;
39 dns_name_t *NONNULL name;
40 dns_name_t *NONNULL zone;
41 bool consumed;
42 };
43
44 typedef struct host_addr host_addr_t;
45 struct host_addr {
46 host_addr_t *NULLABLE next;
47 dns_rr_t rr;
48 };
49 typedef struct dns_host_description dns_host_description_t;
50 struct dns_host_description {
51 dns_name_t *NONNULL name;
52 host_addr_t *NULLABLE addrs;
53 dns_rr_t *NULLABLE key;
54 delete_t *NULLABLE delete;
55 int num_instances;
56 };
57
58 typedef struct service service_t;
59 struct service {
60 service_t *NULLABLE next;
61 dns_rr_t *NONNULL rr; // The service name is rr->name.
62 dns_name_t *NONNULL zone;
63 };
64
65 typedef struct service_instance service_instance_t;
66 struct service_instance {
67 service_instance_t *NULLABLE next;
68 dns_host_description_t *NULLABLE host;
69 dns_name_t *NONNULL name;
70 delete_t *NULLABLE delete;
71 service_t *NONNULL service;
72 int num_instances;
73 dns_rr_t *NULLABLE srv, *NULLABLE txt;
74 };
75
76 // The update_t structure is used to maintain the ongoing state of a particular DNS Update.
77
78 typedef enum update_state update_state_t;
79 enum update_state {
80 connect_to_server, // Establish a connection with the auth server.
81 create_nonexistent, // Update service instance assuming it's not already there (case 1).
82 refresh_existing, // Update service instance assuming it's already there and the same (case 2).
83 create_nonexistent_instance, // Update service instance assuming it's not there
84 refresh_existing_instance, // Update host assuming it's there and the same
85 create_nonexistent_host, // Update a host that's not present (and also the services)
86 refresh_existing_host, // Update a host that's present (and also the services)
87 delete_failed_instance, // The update failed, so delete service instances that were successfully added.
88 };
89
90 typedef enum update_event update_event_t;
91 enum update_event {
92 update_event_connected,
93 update_event_disconnected,
94 update_event_response_received
95 };
96
97 typedef struct update update_t;
98 struct update {
99 comm_t *NONNULL server; // Connection to authoritative server
100 comm_t *NONNULL client; // Connection to SRP client (which might just be a UDP socket).
101 update_state_t state;
102 dns_host_description_t *NONNULL host;
103 service_instance_t *NONNULL instances;
104 service_instance_t *NULLABLE instance; // If we are updating instances one at a time.
105 service_instance_t *NULLABLE added_instances; // Instances we have successfully added.
106 service_t *NONNULL services;
107 dns_name_t *NULLABLE zone_name; // If NULL, we are processing an update for services.arpa.
108 message_t *NONNULL message;
109 dns_message_t *NONNULL parsed_message;
110 dns_wire_t *NONNULL update; // The current update...
111 size_t update_length;
112 size_t update_max;
113 uint8_t fail_rcode; // rcode to return after deleting added service instances.
114 };
115
116 // Local Variables:
117 // mode: C
118 // tab-width: 4
119 // c-file-style: "bsd"
120 // c-basic-offset: 4
121 // fill-column: 108
122 // indent-tabs-mode: nil
123 // End: