3 dial, hangup, announce, listen, accept, reject, netmkaddr, setnetmtpt, getnetconninfo, freenetconninfo \- make and break network connections
10 int dial(char *addr, char *local, char *dir, int *cfdp)
16 int announce(char *addr, char *dir)
19 int listen(char *dir, char *newdir)
22 int accept(int ctl, char *dir)
25 int reject(int ctl, char *dir, char *cause)
28 char* netmkaddr(char *addr, char *defnet, char *defservice)
31 void setnetmtpt(char *to, int tolen, char *from)
34 NetConnInfo* getnetconninfo(char *conndir, int fd)
37 void freenetconninfo(NetConnINfo*)
41 is a network address of the form
42 .IB network ! netaddr ! service\f1,
43 .IB network ! netaddr\f1,
47 is any directory listed in
52 is a free variable that stands for any network in common
53 between the source and the host
56 can be a host name, a domain name, a network address,
57 or a meta-name of the form
62 from the value-attribute pair
64 most closely associated with the source host in the
65 network data base (see
68 If a connection attempt is successful and
73 that has files for accessing the connection
76 The path name is guaranteed to be less than 40
78 One line directory exists for each possible connection.
81 file in the line directory should be used to communicate with the destination.
84 file in the line directory can be used to send commands to the line.
87 for messages that can be written to the
94 file will close the connection.
97 makes a call to destination
99 on a multiplexed network.
105 will try in succession all
106 networks in common between source and destination
107 until a call succeeds.
108 It returns a file descriptor open for reading and writing the
110 file in the line directory.
113 file in the line directory contains the address called.
114 If the network allows the local address to be set,
115 as is the case with UDP and TCP port numbers, and
117 is non-zero, the local address will be set to
123 is set to a file descriptor open for reading and
124 writing the control file.
127 is a means of forcing a connection to hang up without
137 are the complements of
140 establishes a network
141 name to which calls can be made.
150 used in announce may be a local address or an asterisk,
151 to indicate all local addresses, e.g.
155 routine takes as its first argument the
159 When a call is received,
163 file for the line the call was received on.
166 to the path name of the new line directory.
168 accepts a call received by
172 refuses the call because of
175 returns a file descriptor for the data file opened
179 makes an address suitable for dialing or announcing.
180 It takes an address along with a default network and service to use
181 if they are not specified in the address.
182 It returns a pointer to static data holding the actual address to use.
185 returns a structure containing information about a
186 network connection. The structure is:
188 typedef struct NetConnInfo NetConnInfo;
191 char *dir; /* connection directory */
192 char *root; /* network root */
193 char *spec; /* binding spec */
194 char *lsys; /* local system */
195 char *lserv; /* local service */
196 char *rsys; /* remote system */
197 char *rserv; /* remote service */
201 The information is obtained from the connection directory,
205 is nil, the directory is obtained by performing
210 returns either a completely specified structure, or
211 nil if either the structure can't be allocated or the
212 network directory can't be determined.
215 .IR freenetconninfo .
218 copies the name of the network mount point into
223 It exists to merge two pre-existing conventions for specifying
225 Commands that take a network mount point as a parameter
239 the mount point is set to the default,
243 points to a string starting with a slash,
244 the mount point is that path.
245 Otherwise, the mount point is the string pointed to by
247 appended to the string
249 The last form is obsolete and is should be avoided.
250 It exists only to aid in conversion.
252 Make a call and return an open file descriptor to
253 use for communications:
256 int callkremvax(void)
258 return dial("kremvax", 0, 0, 0);
262 Call the local authentication server:
265 int dialauth(char *service)
267 return dial(netmkaddr("$auth", 0, service), 0, 0, 0);
274 loop forever receiving calls and echoing back
275 to the caller anything sent:
282 char adir[40], ldir[40];
286 acfd = announce("tcp!*!7", adir);
290 /* listen for a call */
291 lcfd = listen(adir, ldir);
294 /* fork a process to echo */
301 /* accept the call and open the data file */
302 dfd = accept(lcfd, ldir);
307 while((n = read(dfd, buf, sizeof(buf))) > 0)
318 .BR /usr/local/plan9/src/libc/9sys ,
319 .B /usr/local/plan9/src/libc/port
329 return \-1 if they fail.
331 returns nonzero if it fails.