summaryrefslogtreecommitdiff
path: root/man/8/cs
blob: 4f7e1b4e2f3bcccc7682491dd3e1431e41d3cdf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
.TH CS 8
.SH NAME
cs, csquery \- connection server
.SH SYNOPSYS
.B ndb/cs
[
.BI -f " database"
] [
.B -v
] [
.BI -x " net"
]
.PP
.B ndb/csquery
[
.B -x
.I net
] [
.B -s
.I server
] [
.I address
\&... ]
.SH DESCRIPTION
.I Cs
spawns a process that
serves a single file
.BR /net/cs ,
in the current name space,
answering requests by client processes
to translate symbolic network and service names into
instructions for connecting to the given service.
It is normally accessed indirectly by calls to
.IR dial (2).
.PP
The network data is taken from the network database files,
described in
.IR ndb (6).
By default, it is
.B /lib/ndb/local
but the
.B -f
option can specify a different one.
.PP
Each write to
.B /net/cs
makes a query, expressed in one of two forms.
The first form is a network address of the same form
as the
.I addr
parameter to
.IR dial :
.IB network ! netaddr ! service
where
.I service
and
.I network
are optional for some networks.
The write returns an error if the address cannot be translated.
Otherwise, the file offset should be reset to 0 using
.IR sys-seek (2)
and each subsequent read will return either
end-of-file (if there are no further translations),
or a single line containing a translation of the form:
.IP
.BI /net/ proto /clone " address" ! port
.PP
The first field is the name of the
.I clone
file for a network protocol or interface.
To make a connection or announce a service, open that file, and write the
text in the second field
preceded by
.B connect
or
.B announce
as required.
(All this activity is normally encapsulated in a call to
.IR dial (2).)
.I Cs
produces a translation for each network and for each network address on which a symbolic
.I netaddr
is found.
When announcing a service,
.I netaddr
can be
.B *
to represent any local interface, and the resulting recipes read
from
.B /net/cs
will not include an
.IB address !
part.
.PP
.I Cs
interprets a
.I netaddr
of the form
.BI $ server
specially: it looks for an attribute
.I server
in the database in the entry for the current host, then in the entry for
each network that contains it (if specified), and finally in a site-wide
entry labelled with the attribute
.BR infernosite .
If found, the value of the attribute replaces the
.I netaddr
before further translation.
.PP
In the second form of query, the text written contains space-separated attribute/value pairs following
an initial
.LR ! :
.IP
.B !
.IB attr1 = val1
[
.IB attr2 = val2
\& ...
]
.PP
.I Cs
looks for an
.IR ndb (6)
entry that contains attribute/value pairs matching those in the query.
Any value but
.I val1
may be
.RB ` * ',
to signify that the entry must contain the given attribute but with any value.
As before, the write returns an error if no entry matches.
Otherwise, each subsequent read returns the whole of the next matching entry, in
.IR ndb (6)
form.
.PP
The file
.B /net/cs
persists until it is removed or unmounted from
.BR /net ,
or the
.I cs
process is killed
(see
.IR kill (1)).
The
.B \-v
option causes
.I cs
to print each translation request and results (if any) on standard error.
The
.B -x
option gives an alternative mount point for
.IR cs ,
when there is more than one network stack
(see
.IR ip (3)).
It causes it
.I cs
to serve
.IB net /cs
instead of
.BR /net/cs .
.PP
.I Cs
is normally started  once,
after
.IR dns (8)
if used, but
before most other applications including
the various listeners described in
.IR svc (8).
If another instance of
.IR cs (8)
is started on the same mount point, the file it serves replaces the
earlier one if permissions allow.
(On Plan 9, Plan 9's native connection service will be used by default if Inferno's
.I cs
is not started.)
.PP
.I Csquery
queries the given
.I server
(default:
.BR /net/cs )
for a translation of each
.I address
and prints the results, one per line.
If no
.I address
is given,
.I csquery
prompts for address(es) to translate which it reads from the standard input,
printing the results of each translation on the standard output.
The
.B -x
option gives an alternative mount point for
.IR cs ,
when there is more than one network stack
(see
.IR ip (3)).
.PP
.I Cs
uses
.IR ndb (6)
to map protocol and service names to Internet port numbers.
When running hosted,
if entries are not in
.IR ndb (6),
.I cs
applies the built-in
.IR srv (2),
if available,
to have the host system try the translation.
Consequently, entries in
.IR ndb (6)
take precedence over the host's system-wide configuration.
(This is helpful for adding symbolic names for Inferno services
without requiring administrative privileges on the host system.)
.SH EXAMPLE
Check the translation of the symbolic name
.BR $signer :
.IP
.EX
ndb/csquery
> net!$signer!inflogin
/net/tcp/clone 200.1.1.67!6673
.EE
.SH FILES
.TF /lib/ndb/inferno
.TP
.B #scs*
service directory
.TP
.B /net/cs
connection service
.TP
.B /net/dns
domain name service
.TP
.B /lib/ndb/local
map from symbolic service names to servers
.SH SOURCE
.B /appl/cmd/ndb/cs.b
.br
.B /appl/cmd/ndb/csquery.b
.SH "SEE ALSO"
.IR dial (2),
.IR ndb (6),
.IR dns (8)