]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/dnssd_ipc.h
mDNSResponder-58.8.1.tar.gz
[apple/mdnsresponder.git] / mDNSMacOSX / dnssd_ipc.h
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22
23 Change History (most recent first):
24
25 $Log: dnssd_ipc.h,v $
26 Revision 1.6 2003/08/12 19:56:25 cheshire
27 Update to APSL 2.0
28
29 */
30
31 #ifndef DNSSD_IPC_H
32 #define DNSSD_IPC_H
33
34 #include "dns_sd.h"
35 #include <sys/types.h>
36 #include <unistd.h>
37 #include <sys/un.h>
38 #include <string.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <sys/stat.h>
42
43 //#define UDSDEBUG // verbose debug output
44
45 // General UDS constants
46 #define MDNS_UDS_SERVERPATH "/var/run/mDNSResponder"
47 #define LISTENQ 100
48 #define TXT_RECORD_INDEX -1 // record index for default text record
49 #define MAX_CTLPATH 256 // longest legal control path length
50
51 // IPC data encoding constants and types
52 #define VERSION 1
53 #define IPC_FLAGS_NOREPLY 1 // set flag if no asynchronous replies are to be sent to client
54 #define IPC_FLAGS_REUSE_SOCKET 2 // set flag if synchronous errors are to be sent via the primary socket
55 // (if not set, first string in message buffer must be path to error socket
56
57
58 typedef enum
59 {
60 connection = 1, // connected socket via DNSServiceConnect()
61 reg_record_request, // reg/remove record only valid for connected sockets
62 remove_record_request,
63 enumeration_request,
64 reg_service_request,
65 browse_request,
66 resolve_request,
67 query_request,
68 reconfirm_record_request,
69 add_record_request,
70 update_record_request
71 } request_op_t;
72
73 typedef enum
74 {
75 enumeration_reply = 64,
76 reg_service_reply,
77 browse_reply,
78 resolve_reply,
79 query_reply,
80 reg_record_reply
81 } reply_op_t;
82
83
84 typedef struct ipc_msg_hdr_struct ipc_msg_hdr;
85
86
87 // client stub callback to process message from server and deliver results to
88 // client application
89
90 typedef void (*process_reply_callback)
91 (
92 DNSServiceRef sdr,
93 ipc_msg_hdr *hdr,
94 char *msg
95 );
96
97 // allow 64-bit client to interoperate w/ 32-bit daemon
98 typedef union
99 {
100 void *context;
101 uint32_t ptr64[2];
102 } client_context_t;
103
104
105 typedef struct ipc_msg_hdr_struct
106 {
107 uint32_t version;
108 uint32_t datalen;
109 uint32_t flags;
110 union
111 {
112 request_op_t request_op;
113 reply_op_t reply_op;
114 } op;
115 client_context_t client_context; // context passed from client, returned by server in corresponding reply
116 int reg_index; // identifier for a record registered via DNSServiceRegisterRecord() on a
117 // socket connected by DNSServiceConnect(). Must be unique in the scope of the connection, such that and
118 // index/socket pair uniquely identifies a record. (Used to select records for removal by DNSServiceRemoveRecord())
119 } ipc_msg_hdr_struct;
120
121
122
123
124 // routines to write to and extract data from message buffers.
125 // caller responsible for bounds checking.
126 // ptr is the address of the pointer to the start of the field.
127 // it is advanced to point to the next field, or the end of the message
128
129
130 void put_flags(const DNSServiceFlags flags, char **ptr);
131 DNSServiceFlags get_flags(char **ptr);
132
133 void put_long(const uint32_t l, char **ptr);
134 uint32_t get_long(char **ptr);
135
136 void put_error_code(const DNSServiceErrorType, char **ptr);
137 DNSServiceErrorType get_error_code(char **ptr);
138
139 int put_string(const char *str, char **ptr);
140 int get_string(char **ptr, char *buffer, int buflen);
141
142 void put_rdata(const int rdlen, const char *rdata, char **ptr);
143 char *get_rdata(char **ptr, int rdlen); // return value is rdata pointed to by *ptr -
144 // rdata is not copied from buffer.
145
146 void put_short(uint16_t s, char **ptr);
147 uint16_t get_short(char **ptr);
148
149
150
151 #endif // DNSSD_IPC_H
152
153
154
155
156
157
158
159
160
161
162