URI:
       tclassmask.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tclassmask.c (622B)
       ---
            1 #include <u.h>
            2 #include <libc.h>
            3 #include <ip.h>
            4 
            5 uchar classmask[4][16] = {
            6         0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0x00,0x00,0x00,
            7         0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0x00,0x00,0x00,
            8         0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0x00,0x00,
            9         0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0x00,
           10 };
           11 
           12 uchar*
           13 defmask(uchar *ip)
           14 {
           15         return classmask[ip[IPv4off]>>6];
           16 }
           17 
           18 void
           19 maskip(uchar *from, uchar *mask, uchar *to)
           20 {
           21         int i;
           22 
           23         for(i = 0; i < IPaddrlen; i++)
           24                 to[i] = from[i] & mask[i];
           25 }