3 ndbopen, ndbcat, ndbchanged, ndbclose, ndbreopen, ndbsearch, ndbsnext, ndbgetvalue, ndbfree, ipattr, ndbgetipaddr, ndbipinfo, csipinfo, ndbhash, ndbparse, csgetvalue, ndbfindattr, dnsquery, ndbdiscard, ndbconcatenate, ndbreorder, ndbsubstitute, ndbgetval, csgetval, ndblookval \- network database
12 .ta \w'\fLNdbtuplexx 'u
15 Ndb* ndbopen(char *file)
18 Ndb* ndbcat(Ndb *db1, Ndb *db2)
21 int ndbchanged(Ndb *db)
24 int ndbreopen(Ndb *db)
27 void ndbclose(Ndb *db)
30 Ndbtuple* ndbsearch(Ndb *db, Ndbs *s, char *attr, char *val)
33 Ndbtuple* ndbsnext(Ndbs *s, char *attr, char *val)
36 char* ndbgetvalue(Ndb *db, Ndbs *s, char *attr, char *val,
39 char *rattr, Ndbtuple **tp)
42 char* csgetvalue(char *netroot, char *attr, char *val,
44 char *rattr, Ndbtuple **tp)
47 char* ipattr(char *name)
50 Ndbtuple* ndbgetipaddr(Ndb *db, char *sys);
53 Ndbtuple* ndbipinfo(Ndb *db, char *attr, char *val, char **attrs,
58 Ndbtuple* csipinfo(char *netroot, char *attr, char *val,
60 .B char **attrs, int nattr)
63 ulong ndbhash(char *val, int hlen)
66 Ndbtuple* ndbparse(Ndb *db)
69 Ndbtuple* dnsquery(char *netroot, char *domainname, char *type)
72 Ndbtuple* ndbfindattr(Ndbtuple *entry, Ndbtuple *line, char *attr)
75 void ndbfree(Ndbtuple *db)
78 Ndbtuple* ndbdiscard(Ndbtuple *t, Ndbtuple *a)
81 Ndbtuple* ndbconcatenate(Ndbtuple *a, Ndbtuple *b)
84 Ndbtuple* ndbreorder(Ndbtuple *t, Ndbtuple *a)
87 Ndbtuple* ndbsubstitute(Ndbtuple *t, Ndbtuple *from, Ndbtuple *to)
90 void ndbsetmalloctag(Ndbtuple *t, uintptr tag)
92 These routines are used by network administrative programs to search
94 They operate on the database files described in
102 to allocate a buffer for it.
105 is zero, all network database files are opened.
108 concatenates two open databases. Either argument may be nil.
111 throws out any cached information
112 for the database files associated with
114 and reopens the files.
117 closes any database files associated with
119 and frees all storage associated with them.
124 search a database for an entry containing the
125 attribute/value pair,
128 is used to find the first match and
130 is used to find each successive match.
131 On a successful search both return a linked list of
133 structures acquired by
135 that represent the attribute/value pairs in the
137 On failure they return zero.
140 typedef struct Ndbtuple Ndbtuple;
146 ulong ptr; /* for the application; starts 0 */
147 char valbuf[Ndbvlen]; /* initial allocation for val */
153 pointers chain together all pairs in the entry in a null-terminated list.
156 pointers chain together all pairs on the same line
158 Thus, a program can implement 2 levels of binding for
160 In general, pairs on the same line are bound tighter
161 than pairs on different lines.
169 and should be pointed to valid storage before calling
171 which will fill it with information used by
173 to link successive searches.
179 typedef struct Ndbs Ndbs;
181 Ndb *db; /* data base file being searched */
183 Ndbtuple *t; /* last attribute value pair found */
189 field points to the pair within the entry matched by the
195 searches the database for an entry containing not only an
196 attribute/value pair,
198 but also a pair with the attribute
200 If successful, it returns a malloced copy of the NUL-terminated value associated with
206 will point to the entry. Otherwise the entry will be freed.
211 but queries the connection server
212 instead of looking directly at the database.
213 Its first argument specifies the network root to use.
214 If the argument is 0, it defaults to
218 frees a list of tuples returned by one of the other
222 takes the name of an IP system and returns the attribute
239 for an entry matching
245 attribute/value pair and returns all IP addresses in the entry.
248 is already an IP address, a tuple containing just
249 that address is returned.
252 looks up Internet protocol information about a system.
253 This is an IP aware search. It looks first for information
254 in the system's database entry and then in the database entries
255 for any IP subnets or networks containing the system.
256 The system is identified by the
257 attribute/value pair,
260 returns a list of tuples whose attributes match the
271 is excluded from the attribute name,
272 but causes any corresponding value returned
273 to be a resolved IP address(es), not a name.
274 For example, consider the following database entries describing a network,
275 a subnetwork, and a system.
278 ipnet=big ip=10.0.0.0
281 ipnet=dept ip=10.1.1.0 ipmask=255.255.255.0
283 ip=10.1.1.4 dom=x.big.com
290 ndbipinfo(db, "dom", "x.big.com", ["bootf" "smtp" "dns"], 3)
293 will return the tuples
295 .BR smtp=smtp1.big.com ,
297 .BR dns=dns.big.com .
307 The next three routines are used by programs that create the
308 hash tables and database files.
310 computes a hash offset into a table of length
315 reads and parses the next entry from the database file.
318 parse sequential entries in the database file.
319 A zero is returned at end of file.
322 submits a query about
328 It returns a linked list of
330 representing a single database entry.
331 The tuples are logically arranged into lines using the
333 field in the structure.
336 of query are and the attributes on each returned tuple line is:
339 find the IP addresses. Returns
346 look up the mail exchangers. Returns preference
352 do a reverse query. Here
356 IP address. Returns reverse name
362 get the system that this name is a nickname for. Returns the nickname
368 return the start of area record for this field. Returns
375 refresh time in seconds
377 retry time in seconds
379 expiration time in seconds
381 and minimum time to lie
385 name servers. Returns domain name
396 and returns a pointer to the tuple.
399 points to a particular line in the entry, the
400 search starts there and then wraps around to the beginning
403 All of the routines provided to search the database
404 provide an always consistent view of the relevant
405 files. However, it may be advantageous for an application
406 to read in the whole database using
410 and provide its own search routines. The
412 routine can be used by the application to periodically
413 check for changes. It returns zero
414 if none of the files comprising the database have
415 changes and non-zero if they have.
417 Finally, a number of routines are provided for manipulating tuples.
420 removes attr/val pair
432 concatenates two tuples and returns the result. Either
433 or both tuples may be nil.
438 to make the line containing attr/val pair
440 first in the entry and making
445 replaces a single att/val pair
451 All attr/val pairs in
453 end up on the same line.
463 of each tuple in the list
468 .BR /lib/ndb " directory of network database files
482 .L "buffer too short"
483 if the buffer provided isn't long enough for the
490 are deprecated versions of
495 They expect a fixed 64 byte long result
496 buffer and existed when the values of a
498 structure were fixed length.