|
|
1.1 root 1: .TH IPC 3X
2: .CT 2 comm_proc
3: .SH NAME
4: ipccreat, ipcopen, ipclisten, ipcaccept, ipcreject, ipcexec, ipcpath , ipclogin, ipcrogin
5: \(mi set up connections between processes or machines
6: .SH SYNOPSIS
7: .B #include <ipc.h>
8: .PP
9: .B char *ipcpath(name, network, service)
10: .br
11: .B char *name;
12: .br
13: .B char *network;
14: .br
15: .B char *service;
16: .PP
17: .B int ipcopen(name, param)
18: .br
19: .B char *name;
20: .br
21: .B char *param;
22: .PP
23: .B int ipccreat(name, param)
24: .br
25: .B char *name;
26: .br
27: .B char *param;
28: .PP
29: .B ipcinfo *ipclisten(fd)
30: .br
31: .B int fd;
32: .PP
33: .B int ipcaccept(ip)
34: .br
35: .B ipcinfo *ip;
36: .PP
37: .B int ipcreject(ip, no, str)
38: .br
39: .B ipcinfo *ip;
40: .br
41: .B int no;
42: .br
43: .B char *str;
44: .PP
45: .B int ipcexec(name, param, cmd)
46: .br
47: .B char *name;
48: .br
49: .B char *param;
50: .br
51: .B char *cmd;
52: .PP
53: .B int ipclogin(fd)
54: .br
55: .B int fd;
56: .PP
57: .B int ipcrogin(fd, opt)
58: .br
59: .B int fd;
60: .br
61: .B char *opt;
62: .PP
63: .B extern char *errstr;
64: .SH DESCRIPTION
65: These routines establish communication between unrelated
66: processes, often for networking purposes.
67: They are loaded by the
68: .B -lipc
69: option of
70: .IR ld (1).
71: .PP
72: End points in the network are identified by names of the form:
73: .BR element [ !element "]... " .
74: The name is translated element by element relative to the name space
75: selected by the previous element.
76: The first element is always a name in the local file system.
77: By convention, all network interfaces and services
78: mount themselves in
79: .FR /cs .
80: For example:
81: .TP
82: .B /cs/exec
83: refers to a local process which has mounted itself (via
84: .I ipccreat )
85: on
86: .FR /cs/exec .
87: .TP
88: .B /cs/dk!nj/astro/voice
89: refers to a voice synthesizer attached
90: to Datakit; process
91: .F /cs/dk
92: is the Datakit interface.
93: .TP
94: .B /cs/dk!dutoit!exec
95: is the process that has mounted itself on
96: .F /cs/exec
97: in machine `dutoit'.
98: .PP
99: .I Ipcpath,
100: forms a network name from its arguments and returns a pointer to it.
101: It takes three arguments: the destination
102: .I name,
103: the default
104: .I network,
105: and the default
106: .I service.
107: It assumes that
108: .I name
109: is a three part name of the form: network!host!service.
110: If either network or service is missing from
111: .I name, ipcpath
112: supplies them
113: from the default arguments.
114: It then tacks a
115: .F /cs
116: on the front and returns a pointer to that.
117: Thus,
118: .IP
119: .EX
120: ipcpath("dutoit", "dk", "dcon")
121: .EE
122: .LP
123: returns a pointer to the string
124: .LR /cs/dk!dutoit!dcon .
125: .PP
126: .I Ipcopen
127: places a call to a named network end point and returns
128: a file descriptor for the resulting connection.
129: .I Param,
130: a whitespace-delimited string of values, specifies
131: properties which the connection must have.
132: At present four parameter values are defined:
133: .TF heavy
134: .TP
135: .B heavy
136: .br
137: .ns
138: .TP
139: .B light
140: Heavy (usually computer-to-computer) or light (computer-to-terminal)
141: traffic is expected.
142: .TP
143: .B delim
144: The connection must support delimiters; see
145: .IR stream (4).
146: .TP
147: .B hup
148: .B SIGHUP
149: must be generated at end of file; see
150: .IR signal (2).
151: .PD
152: .PP
153: .I Ipccreat
154: attaches a process to a name space.
155: It returns a file descriptor representing the attachment.
156: .I Name
157: and
158: .I param
159: mean the same as for
160: .I ipcopen.
161: .PP
162: .I Ipclisten
163: waits for calls (from
164: .I ipcopen
165: in other processes) appearing on file descriptor
166: .I fd
167: (obtained from
168: .IR ipccreat ).
169: When a call arrives, it returns an
170: .B ipcinfo
171: structure, defined in
172: .FR <ipc.h> :
173: .IP
174: .EX
175: .ta \w'typedef\ 'u +\w'char\ 'u +\w'reserved[5];\ 'u
176: typedef struct {
177: int reserved[5];
178: char *name; that being dialed
179: char *param; parameters used to set up call
180: char *machine; machine id of caller
181: char *user; user name of caller
182: int uid, gid; uid, gid of caller
183: } ipcinfo;
184: .EE
185: .PP
186: The call may be accepted by
187: .I ipcaccept
188: or rejected by
189: .I ipcreject.
190: .I Ipcaccept
191: returns a file descriptor for the connection.
192: .I Ipcreject
193: takes an integer error number and an error message string,
194: which will be passed back to the caller as
195: .I errno
196: and
197: .I errstr.
198: .PP
199: A higher-level routine,
200: .I ipcexec,
201: executes the command,
202: .I cmd,
203: on a named machine.
204: The file descriptor returned by
205: .I ipcexec
206: is the standard input, standard output, and
207: standard error of the command.
208: As in
209: .I ipcopen,
210: .I param
211: lists properties required of the channel.
212: .PP
213: Once a connection is established using
214: .I ipcopen
215: it is often necessary to authenticate yourself
216: to the destination.
217: This is done using
218: .I ipclogin
219: and
220: .I ipcrogin.
221: .I Ipclogin
222: runs the client side of the authentication protocol
223: described in
224: .IR svcmgr (8)
225: for the
226: .I v9auth
227: action.
228: The supplied
229: .I fd
230: is the descriptor returned by
231: .I ipcopen.
232: Until the authentication is accepted,
233: .I ipclogin
234: will prompt the user (using
235: .F /dev/tty )
236: for a login id and password to be sent over
237: .I fd.
238: .PP
239: .I Ipcrogin
240: runs the client side of the authentication protocol
241: used by BSD's
242: .I rlogin
243: and
244: .I rsh
245: services.
246: Unlike
247: .I ipclogin,
248: it will not prompt the user if the authentication
249: fails.
250: .I Ipcrogin
251: takes a second argument that is written to
252: .I fd
253: after the authentication is accepted.
254: .SH EXAMPLES
255: To connect to the voice synthesizer attached to the Datakit:
256: .EX
257: .ta \w'12345678'u +\w'12345678'u +\w'12345678'u
258: #include <ipc.h>
259: main() {
260: int fd;
261: fd = ipcopen(ipcpath("voice", "dk", 0), "light");
262: if(fd<0){
263: printf("can't connect: %s\en", errstr);
264: exit(1);
265: }
266: ...
267: close(fd);
268: }
269: .EE
270: .PP
271: To place a Dataphone call via Datakit; the service name is
272: derived in an obvious way from the ACU service class; see
273: .IR dialout (3).
274: .EX
275: fd = ipcopen(ipcpath("9-1-201-582-0000", "dk", "dial1200"), "light");
276: .EE
277: .PP
278: To announce as a local service and wait for incoming calls:
279: .EX
280: .ta \w'12345678'u +\w'12345678'u +\w'12345678'u
281: #include <ipc.h>
282: main() {
283: int fd;
284: ipcinfo *ip;
285: fd = ipccreat("/tmp/service", 0);
286: if(fd<0){
287: printf("can't announce: %s\en", errstr);
288: exit(1);
289: }
290: while(ip = ipclisten(fd)){
291: int nfd;
292: if(i_hate_this_user(ip->machine, ip->user)) {
293: ipcreject(ip, EACCES, "i hate you");
294: continue;
295: }
296: nfd = ipcaccept(ip);
297: ...
298: close(nfd);
299: }
300: printf("lost the announced connection somehow\en");
301: exit(1);
302: }
303: .EE
304: .SH FILES
305: .TF /cs/tpc
306: .TP
307: .F /cs/dk
308: the announce point for the Datakit dialer
309: .TP
310: .F /cs/tcp
311: the announce point for the internet dialer
312: .SH SEE ALSO
313: .IR dialout (3),
314: .IR connld (4),
315: .IR dkmgr (8),
316: .IR svcmgr (8),
317: .IR tcpmgr (8)
318: .br
319: D. L. Presotto,
320: `Interprocess Communication in the Eighth Edition
321: .SM UNIX
322: System',
323: this manual, Volume 2
324: .SH DIAGNOSTICS
325: Integer return values of \-1 and pointer return
326: values of 0 denote error.
327: .I Errno
328: contains an error code (see
329: .IR intro (2))
330: and
331: .I errstr
332: points to an explanatory string.
333: .SH BUGS
334: Files created by
335: .I ipccreat
336: in the local name space are not removed when
337: the file descriptor returned by
338: .I ipccreat
339: is closed.
340: .br
341: Information in
342: .B ipcinfo
343: is no more trustworthy than its origin.
344: Information, such as user name, sent by foreign
345: machines may be suspect.
346: On Ethernet or dialup connections (but not on Datakit)
347: machine names can be forged.
348: Let's not even think about wire-swappers and wiretappers.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.