]> git.saurik.com Git - apple/mdnsresponder.git/blob - ServiceRegistration/ra-tester/ra-tester.c
mDNSResponder-1310.40.42.tar.gz
[apple/mdnsresponder.git] / ServiceRegistration / ra-tester / ra-tester.c
1 /* ra-tester.c
2 *
3 * Copyright (c) 2020 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 * This file contains the SRP Advertising Proxy, which is an SRP Server
18 * that offers registered addresses using mDNS.
19 */
20
21 #include <stdlib.h>
22 #include <string.h>
23 #include <stdio.h>
24 #include <unistd.h>
25 #include <errno.h>
26 #include <sys/socket.h>
27 #include <netinet/in.h>
28 #include <arpa/inet.h>
29 #include <fcntl.h>
30 #include <sys/time.h>
31 #include <dns_sd.h>
32 #include <net/if.h>
33
34 #include "srp.h"
35 #include "dns-msg.h"
36 #include "ioloop.h"
37 #include "srp-crypto.h"
38 #include "ioloop.h"
39 #include "dnssd-proxy.h"
40 #include "srp-gw.h"
41 #include "srp-proxy.h"
42 #include "srp-mdns-proxy.h"
43 #include "config-parse.h"
44 #include "route.h"
45
46 static void
47 usage(void)
48 {
49 ERROR("ra-tester -t <thread interface name> --h <home interface name>");
50 exit(1);
51 }
52
53 int
54 main(int argc, char **argv)
55 {
56 int i;
57 extern char *thread_interface_name;
58 extern char *home_interface_name;
59 extern bool advertise_default_route_on_thread;
60
61 for (i = 1; i < argc; i++) {
62 if (!strcmp(argv[i], "-t")) {
63 if (i + 1 == argc) {
64 usage();
65 }
66 thread_interface_name = argv[i + 1];
67 i++;
68 } else if (!strcmp(argv[i], "-h")) {
69 if (i + 1 == argc) {
70 usage();
71 }
72 home_interface_name = argv[i + 1];
73 i++;
74 } else {
75 usage();
76 }
77 }
78
79 if (thread_interface_name == NULL) {
80 INFO("thread interface name required.");
81 usage();
82 }
83 if (home_interface_name == NULL) {
84 INFO("home interface name required.");
85 usage();
86 }
87 OPENLOG(log_stderr);
88
89 if (!ioloop_init()) {
90 return 1;
91 }
92
93 if (!start_icmp_listener()) {
94 return 1;
95 }
96
97 thread_network_startup();
98
99 do {
100 int something = 0;
101 ioloop();
102 INFO("dispatched %d events.", something);
103 } while (1);
104 }
105
106 // Local Variables:
107 // mode: C
108 // tab-width: 4
109 // c-file-style: "bsd"
110 // c-basic-offset: 4
111 // fill-column: 108
112 // indent-tabs-mode: nil
113 // End: