__PREFIX_BEGIN__
//-----------------------------------------------------------------------------
// Copyright © 2004 - Philip Howard - All rights reserved
//
// 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; either version 2
// of the License, or (at your option) any later version.
//
// 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
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//-----------------------------------------------------------------------------
// package	libh/net
// homepage	http://libh.slashusr.org/
//-----------------------------------------------------------------------------
// author	Philip Howard
// email	libh at ipal dot org
// homepage	http://phil.ipal.org/
//-----------------------------------------------------------------------------
// This file is best viewed using a fixed spaced font such as Courier
// and in a display at least 120 columns wide.
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// file		libh/net.h
//-----------------------------------------------------------------------------
#ifndef __NET_H__
#define __NET_H__
__PREFIX_END__

__INCLUDE_BEGIN__
#include <netdb.h>
#include <netinet/in.h>
#include <stdarg.h>

#include <libh/map.h>

__INCLUDE_END__

__DEFINE_BEGIN__
#define IPV4_STR_TO_ADDR_ADDR           0x00000001
#define IPV4_STR_TO_ADDR_ADDR2          0x00000002
#define IPV4_STR_TO_ADDR_COUNT          0x00000004
#define IPV4_STR_TO_ADDR_PORT           0x00000008
#define IPV4_STR_TO_ADDR_PREFIX         0x00000010
#define IPV4_STR_TO_ADDR_NETMASK        0x00000020

#define IPV4_STR_TO_ADDR_BAD_ADDR       0x00010000
#define IPV4_STR_TO_ADDR_BAD_ADDR2      0x00020000
#define IPV4_STR_TO_ADDR_BAD_COUNT      0x00040000
#define IPV4_STR_TO_ADDR_BAD_PORT       0x00080000
#define IPV4_STR_TO_ADDR_BAD_PREFIX     0x00100000

#define IPV4_STR_TO_ADDR_BAD_CHAR       0x40000000

#define IPV4_STR_TO_ADDR_ERROR          0x80000000

//-----------------------------------------------------------------------------
// structs and typedefs
//-----------------------------------------------------------------------------
typedef uint32_t	ipv4_t		;

struct ipv4_netinfo {
    ipv4_t		address		;
    ipv4_t		address2	;
    ipv4_t		netfirst	;
    ipv4_t		netlast		;
    ipv4_t		netmask		;
    uint32_t		count		;
    unsigned int	prefix		;
    unsigned int	port		;
    unsigned int	flags		;
};

__DEFINE_END__

__SUFFIX_BEGIN__
#endif /* __NET_H__ */
__SUFFIX_END__

