3 ndbopen, ndbcat, ndbchanged, ndbclose, ndbreopen, ndbsearch, ndbsnext, ndbgetvalue, ndbfree, ipattr, ndbgetipaddr, ndbipinfo, csipinfo, ndbhash, ndbparse, csgetvalue, ndbfindattr, dnsquery, ndbdiscard, ndbconcatenate, ndbreorder, ndbsubstitute, ndbdedup \- 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 Ndbtuple* ndbdedup(Ndbtuple *t)
93 void ndbsetmalloctag(Ndbtuple *t, uintptr tag)
95 These routines are used by network administrative programs to search
97 They operate on the database files described in
105 to allocate a buffer for it.
108 is zero, all network database files are opened.
111 concatenates two open databases. Either argument may be nil.
114 throws out any cached information
115 for the database files associated with
117 and reopens the files.
120 closes any database files associated with
122 and frees all storage associated with them.
127 search a database for an entry containing the
128 attribute/value pair,
131 is used to find the first match and
133 is used to find each successive match.
134 On a successful search both return a linked list of
136 structures acquired by
138 that represent the attribute/value pairs in the
140 On failure they return zero.
143 typedef struct Ndbtuple Ndbtuple;
149 ulong ptr; /* for the application; starts 0 */
150 char valbuf[Ndbvlen]; /* initial allocation for val */
156 pointers chain together all pairs in the entry in a null-terminated list.
159 pointers chain together all pairs on the same line
161 Thus, a program can implement 2 levels of binding for
163 In general, pairs on the same line are bound tighter
164 than pairs on different lines.
172 and should be pointed to valid storage before calling
174 which will fill it with information used by
176 to link successive searches.
182 typedef struct Ndbs Ndbs;
184 Ndb *db; /* data base file being searched */
186 Ndbtuple *t; /* last attribute value pair found */
192 field points to the pair within the entry matched by the
198 searches the database for an entry containing not only an
199 attribute/value pair,
201 but also a pair with the attribute
203 If successful, it returns a malloced copy of the NUL-terminated value associated with
209 will point to the entry. Otherwise the entry will be freed.
214 but queries the connection server
215 instead of looking directly at the database.
216 Its first argument specifies the network root to use.
217 If the argument is 0, it defaults to
221 frees a list of tuples returned by one of the other
225 takes the name of an IP system and returns the attribute
248 attribute/value pair and returns all IP addresses.
251 is already an IP address, a tuple containing just
252 that address is returned.
255 looks up Internet protocol information about a system.
256 This is an IP aware search. It looks first for information
257 in the system's database entry and then in the database entries
258 for any IP subnets or networks containing the system.
259 The system is identified by the
260 attribute/value pair,
263 returns a list of tuples whose attributes match the
274 is excluded from the attribute name,
275 but causes any corresponding value returned
276 to be a resolved IP address(es), not a name.
277 For example, consider the following database entries describing a network,
278 a subnetwork, and a system.
281 ipnet=big ip=10.0.0.0
284 ipnet=dept ip=10.1.1.0 ipmask=255.255.255.0
286 ip=10.1.1.4 dom=x.big.com
293 ndbipinfo(db, "dom", "x.big.com", ["bootf" "smtp" "dns"], 3)
296 will return the tuples
298 .BR smtp=smtp1.big.com ,
300 .BR dns=dns.big.com .
310 The next three routines are used by programs that create the
311 hash tables and database files.
313 computes a hash offset into a table of length
318 reads and parses the next entry from the database file.
321 parse sequential entries in the database file.
322 A zero is returned at end of file.
325 submits a query about
331 It returns a linked list of
333 representing a single database entry.
334 The tuples are logically arranged into lines using the
336 field in the structure.
339 of query are and the attributes on each returned tuple line is:
342 find the IP addresses. Returns
349 find the IPv6 addresses. Returns
356 look up the mail exchangers. Returns preference
362 do a reverse query. Here
366 IP address. Returns reverse name
372 get the system that this name is a nickname for. Returns the nickname
378 return the start of area record for this field. Returns
385 refresh time in seconds
387 retry time in seconds
389 expiration time in seconds
391 and minimum time to lie
395 get the service records. Returns the priority of target host
399 for entries with the same priority,
400 port on this target host of this service
402 and the domain name of the target host
406 get the descriptive text. The semantics of the text depends
410 name servers. Returns domain name
421 and returns a pointer to the tuple.
424 points to a particular line in the entry, the
425 search starts there and then wraps around to the beginning
428 All of the routines provided to search the database
429 provide an always consistent view of the relevant
430 files. However, it may be advantageous for an application
431 to read in the whole database using
435 and provide its own search routines. The
437 routine can be used by the application to periodically
438 check for changes. It returns zero
439 if none of the files comprising the database have
440 changes and non-zero if they have.
442 Finally, a number of routines are provided for manipulating tuples.
445 removes attr/val pair
457 concatenates two tuples and returns the result. Either
458 or both tuples may be nil.
463 to make the line containing attr/val pair
465 first in the entry and making
470 replaces a single attr/val pair
476 All attr/val pairs in
478 end up on the same line.
483 removes duplicate attr/val pairs from tuple list
492 of each tuple in the list
497 .BR /lib/ndb " directory of network database files