home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / net / bind-contrib.tar.gz / bind-contrib.tar / contrib / misc / settransfer.shar / ns_xfr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-25  |  2.4 KB  |  89 lines

  1. #if !defined(line) && !defined(SABER)
  2. static char sccsid[] = "@(#)ns_xfr.c    1.1 (Rutgers) 7/16/93";
  3. static char rcsid[] = "$Id:";
  4. #endif /* not lint */
  5. /*
  6.  *
  7.  * ns_xfr.c - support for specifying the program to be used to do
  8.  * zone transfers.  This isn't obvious, but this is actually support
  9.  * for shuffling address records, cnames, etc - anything you want.
  10.  *
  11.  * Note that if this code is turned on, then the sorting of responses
  12.  * is actively turned off -- since these are order dependent - then
  13.  * such things as sorting responses tends to bung things up a bit.
  14.  *
  15.  * This codes enables the "transfer" keyword in the named.boot
  16.  * file.  There you may use the syntax:
  17.  *        transfer        <zone-name>        <program name>
  18.  *
  19.  * Of course, inside of that program, you can do *anything* you
  20.  * want to do.  Currently I'm actually using a shell script that
  21.  * does a "round robin" ordering of addresses.  With the right
  22.  * ancillary programs - you could even have it page you everytime
  23.  * it does a zone transfer.
  24.  *
  25.  * This is the result of a long and arduous trek through the IETF,
  26.  * a working group, and a lot of frustration.  All of this for
  27.  * load-balancing. - TpB (brisco@noc.rutgers.edu)
  28.  */
  29.  
  30. #include <sys/param.h>
  31. #include <sys/socket.h>
  32. #include <sys/time.h>
  33. #include <sys/stat.h>
  34. #include <netinet/in.h>
  35. #include <arpa/nameser.h>
  36. #include <syslog.h>
  37. #include <signal.h>
  38. #include <resolv.h>
  39. #include <stdio.h>
  40. #include <errno.h>
  41. #include <ctype.h>
  42. #include "named.h"
  43.  
  44. #ifdef SETTRANSFER
  45. #define MAXTRANDEFS 128
  46. struct xfr_element {
  47.     char * domain;
  48.     char * prog;
  49. };
  50. static struct xfr_element xfr_table[MAXTRANDEFS];
  51. static int no_xfrs;
  52.  
  53. setXfer(dname, progname)
  54. char * dname;
  55. char * progname;
  56. {
  57.     char *d, *p;
  58.     extern int debug;
  59.     if (no_xfrs >= MAXTRANDEFS) {
  60.     if (debug)
  61.         dprintf(1, (ddt,"Set Transfer:  max# exceeded.  Dropping.\n"));
  62.     return;
  63.     }
  64.     d = xfr_table[no_xfrs].domain = malloc(strlen(dname)+1);
  65.     p = xfr_table[no_xfrs].prog = malloc(strlen(progname)+1);
  66.     strcpy(d, dname);
  67.     strcpy(p, progname);
  68.     if (debug) fprintf(ddt,"Set transfer[%d] for domain %s to %s\n",
  69.             no_xfrs,d,p);
  70.     no_xfrs++;
  71. }
  72.  
  73. char *
  74. getXfer(dname)
  75. char * dname;
  76. {
  77.     char * p;
  78.     int i;
  79.     p = (char *)NULL;
  80.     for (i=0; i<no_xfrs && p==(char*)NULL; i++) {
  81.     if (!strcasecmp(xfr_table[i].domain,dname))
  82.         p = xfr_table[i].prog;
  83.     }
  84.     if (debug) fprintf(ddt,"Transfer for domain %s is %s\n",
  85.             dname,p?p:_PATH_XFER);
  86.     return(p);
  87. }
  88. #endif SETTRANSFER
  89.