## tests/ip/test_ip.c

/* [<][>][^][v][top][bottom][index][help] */

## FUNCTIONS

This source file includes following functions.

1. main

    #include <iproutines.h>
    #include "bitmask.h"

    int main(void)
    /* [<][>][^][v][top][bottom][index][help] */
    {
      int i;
      ip_addr_t   myaddr;
      ip_prefix_t mypref;
      ip_range_t  myrange;
      char buf[32];

      printf("testing IP_pref and IP_addr functions ...\n");
      printf("correct input ...");

      IP_pref_e2b(&mypref, "123.21.12.1/7");
      IP_pref_b2a(&mypref, buf, 32);

      /* it should check the return value to see if it's OK */

      if( strcmp(buf, "123.21.12.1/7") == 0 ) {
        puts("OK");
      } else {
        puts("failed");
        exit(-1);
      }

    /*
      printf("incorrect input ...");
      IP_pref_e2b(&mypref, "123.21.12.A/7");
    */

      printf("testing IP_rang functions ...\n");

      IP_rang_e2b( &myrange, "123.21.12.7 - 123.21.56.67 ");
      IP_addr_b2a( &(myrange.begin), buf, 32);
      puts(buf);

      IP_addr_b2a( &(myrange.end), buf, 32);
      puts(buf);

      printf("testing IP_addr_bit functions ...\n");
      IP_addr_e2b(&myaddr, "195.21.12.1");
      IP_addr_b2a( &myaddr, buf, 32);
      printf("for address %s (%08x)\n", buf, myaddr.words[0]);

      for(i=0;i<32;i++) {
            printf("%2d \t%d\n", i, IP_addr_bit_get(&myaddr, i));
      }

      printf("testing IP_rang_decomp function ...\n");
      {
        GList *preflist = NULL;

        extern void ip_print_prefix(void *dataptr, void *junk);

        printf("range decomposed into mask: %x\n",
               IP_rang_decomp(&myrange, &preflist));

        g_list_foreach( preflist, ip_print_prefix, NULL );

      }

      return 0;
    }

/* [<][>][^][v][top][bottom][index][help] */