diff -Nur ppp-2.4.1/pppd/Makefile.linux myppp/ppp-2.4.1/pppd/Makefile.linux --- ppp-2.4.1/pppd/Makefile.linux 2006-09-14 14:52:54.000000000 +0200 +++ ppp-2.4.1/pppd/Makefile.linux 2006-09-14 14:55:44.000000000 +0200 @@ -17,7 +17,7 @@ auth.o options.o demand.o utils.o sys-linux.o ipxcp.o multilink.o \ tdb.o tty.o -all: pppd +all: pppd tdbread # # include dependancies if present and backup if as a header file @@ -114,9 +114,10 @@ INSTALL= install -install: pppd +install: pppd tdbread mkdir -p $(BINDIR) $(MANDIR) $(INSTALL) -c -m 555 pppd $(BINDIR)/pppd + $(INSTALL) -c -m 555 tdbread $(BINDIR)/tdbread if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \ chmod o-rx,u+s $(BINDIR)/pppd; fi $(INSTALL) -c -m 444 pppd.8 $(MANDIR)/man8 @@ -124,8 +125,11 @@ pppd: $(PPPDOBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS) +tdbread: tdbread.o tdb.o + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ + clean: - rm -f $(PPPDOBJS) pppd *~ #* core + rm -f $(PPPDOBJS) tdbread.o tdbread pppd *~ #* core depend: $(CPP) -M $(CFLAGS) $(PPPDSRCS) >.depend diff -Nur ppp-2.4.1/pppd/tdbread.c myppp/ppp-2.4.1/pppd/tdbread.c --- ppp-2.4.1/pppd/tdbread.c 1970-01-01 01:00:00.000000000 +0100 +++ ppp-2.4.1/pppd/tdbread.c 2006-09-14 14:52:32.000000000 +0200 @@ -0,0 +1,153 @@ +/** + * @file tdbread.c + * @author Thomas Geffert + * @date Thu Sep 14 10:28:31 2006 + * + * @brief Small program to extract information from pppd.tbd database. + * You can get information about a specific ppp process with its pid + * or view all keys available in the database. + */ + +/* + * (c) COPYRIGHT 2006 by 4G Systems GmbH Germany + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms AND provided that this software or + * any derived work is only used as part of the PPP daemon (pppd) + * and related utilities. + * The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Note: this software is also available under the Gnu Public License + * version 2 or later. + */ + +#include +#include +#include +#include +#include +#include /* needed for tdb.h starting with ppp-2.4.3 */ + +#include "tdb.h" +#include "pppd.h" +#include "pathnames.h" + +/** + * Callback function for tdb_traverse: show a key and its associated data + * + * @param tdb pointer to database + * @param key hash key + * @param dbuf data belonging to key + * @param state unused data pointer + * + * @return 0 if success, 1 to stop calling function + */ +static int show(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state) +{ + printf("%.*s: \"%.*s\"\n", key.dsize, key.dptr, dbuf.dsize, dbuf.dptr); + return 0; +} + +/** + * Parse command line option. Option is used to sepcify for which ppp process + * information should be shown. + * + * @param argc number of options + * @param argv pointer to array with options + * + * @return empty key if no valid option found, or key selected by config option + */ +TDB_DATA parse_options(int argc, char **argv) +{ + TDB_DATA key = { NULL, 0 }; + static char keyname[32] = { 0 }; + int c; + while (1) { + int option_index = 0; + static struct option long_options[] = { + {"pid", 1, 0, 'p'}, {"device", 1, 0, 'd'}, {"ifname", 1, 0, 'i'}, + {"ipremote", 1, 0, 'r'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0} + }; + + c = getopt_long (argc, argv, "p:d:i:r:h", long_options, &option_index); + if (c == -1) { + if ( optind