/*

                                   _JNJ`                        
                               .JNMH`                           
                              JMMF`       `;.                   
                            .NMM)          `MN.                 
                            MMM)            (MML                
                           (MMM`             MMML               
                     M  I  D  N  I  G  H  T    C  o  D  E       
                           (NMMF             MHNH               
                            NMML            .MMM                
                             NMML          .NMH                 
                              4MMNL       .#F                   
                               `4HNNL_   `                      
                                   `"""`                        

                          Copyright (C) 2004-2006
       "Ian (Larry) Latter" <ian dot latter at midnightcode dot org>

    Midnight Code is a registered trademark of Ian Latter.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, and mirrored at the Midnight Code web
    site; as at version 2 of the License only.
  
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
  
    You should have received a copy of the GNU General Public License
    (version 2) along with this program; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA, or see http://midnightcode.org/gplv2.txt

*/


/* midnightcode-ip.h :: Midnight Code Internet Protocol library	*/

/* Includes software to support RFCs :: 1517-1520, 1878 */


#ifndef __MIDNIGHTCODE_IP_H
#define __MIDNIGHTCODE_IP_H 1


enum midnightcode_ip_option_t
{
  MIDNIGHTCODE_IP_SPECIAL_NONE = 0,
  MIDNIGHTCODE_IP_SPECIAL_RFC1700 = 1,
  MIDNIGHTCODE_IP_SPECIAL_RFC1918 = 2,
  MIDNIGHTCODE_IP_SPECIAL_RFC2544 = 4,
  MIDNIGHTCODE_IP_SPECIAL_RFC3068 = 8,
  MIDNIGHTCODE_IP_SPECIAL_RFC3171 = 16,
  MIDNIGHTCODE_IP_SPECIAL_RFC3330 = 32,
  MIDNIGHTCODE_IP_SPECIAL_ALL = 255
};

struct midnightcode_ip_subnets_t
{
  const char * address;
  const char * netmask;
};

int midnightcode_ip_cidrtomask(u_int32_t * netmask, int cidr);
int midnightcode_ip_masktocidr(int * cidr, u_int32_t netmask);
int midnightcode_ip_classmask(u_int32_t * netmask, u_int32_t address);
int midnightcode_ip_broadcast(u_int32_t * broadcast, u_int32_t address,
                     u_int32_t netmask);
int midnightcode_ip_network(u_int32_t * network, u_int32_t address,
                     u_int32_t netmask);
int midnightcode_ip_isinnet_s(u_int32_t target, const char * address_s,
                     const char * netmask_s);
int midnightcode_ip_isinnet(u_int32_t target, u_int32_t address,
                     u_int32_t netmask);
int midnightcode_ip_isspecial(int type, u_int32_t target);
int midnightcode_ip_isprivate(u_int32_t address);
int midnightcode_ip_ismulticast(u_int32_t address);
int midnightcode_ip_cmp(struct in_addr *ipv4_a, struct in_addr *ipv4_b);


#endif
