/*

                                   _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-2007
       "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-interface.h :: Midnight Code network interface library	*/


#ifndef __MIDNIGHTCODE_INTERFACE_H
#define __MIDNIGHTCODE_INTERFACE_H 1


#define MIDNIGHTCODE_INTERFACE_STRUCTURE "interface"

struct midnightcode_interface_element_t
{
  int is_enabled;
  char name[64];
  char name_root[32];
  char name_alias[32];
  int mtu;
  int flags;
  int ifindex;
  int is_alias;
  int is_static;
  unsigned char mac_address[6];
  struct in_addr ipv4_address;
  struct in_addr ipv4_mask;
  struct in_addr ipv4_broadcast;
  char mac_address_s[32];
  char ipv4_address_s[32];
  char ipv4_mask_s[32];
  char ipv4_broadcast_s[32];
  char vendor_name[128];
  midnightcode_list_entry(midnightcode_interface_element_t)
};

midnightcode_list_head(midnightcode_interface_head_t,
                       midnightcode_interface_element_t)

struct midnightcode_interface_vendor_t
{
  unsigned int id;
  const char * name;
};

enum midnightcode_interface_marry_t
{
  MIDNIGHTCODE_INTERFACE_MARRY_DEFAULT = 0,
  MIDNIGHTCODE_INTERFACE_MARRY_BASIC = 1,
  MIDNIGHTCODE_INTERFACE_MARRY_ONMAC = 2,
  MIDNIGHTCODE_INTERFACE_MARRY_ONNAME = 4
};

int midnightcode_interface_writehosts(char * hosts_file,
                     struct midnightcode_interface_head_t * elements);
int midnightcode_interface_up(
                     struct midnightcode_interface_element_t * interface);
int midnightcode_interface_down(
                     struct midnightcode_interface_element_t * interface);
int midnightcode_interface_configure(
                     struct midnightcode_interface_element_t * interface);
int midnightcode_interface_add(
                     struct midnightcode_interface_head_t * elements,
                     char * pattern,
                     struct midnightcode_interface_element_t ** element);
int midnightcode_interface_probe(
                     struct midnightcode_interface_element_t * element,
                     int sockfd, void * ifr_v);
int midnightcode_interface_list(
                     struct midnightcode_interface_head_t * elements);
int midnightcode_interface_support(void);
int midnightcode_interface_byindex(
                     struct midnightcode_interface_head_t * elements,
                     int index);
int midnightcode_interface_byname(
                     struct midnightcode_interface_head_t * elements,
                     char * pattern,
                     struct midnightcode_interface_element_t ** element);
int midnightcode_interface_only(
                     struct midnightcode_interface_head_t * elements);
int midnightcode_interface_to_config(
                     struct midnightcode_interface_head_t * interface_elements,
                     struct midnightcode_config_head_t * config_elements);
int midnightcode_interface_from_config(
                     struct midnightcode_interface_head_t * interface_elements,
                     struct midnightcode_config_head_t * config_elements);
int midnightcode_interface_transfer(
                     struct midnightcode_interface_element_t * destination,
                     struct midnightcode_interface_element_t * source);
int midnightcode_interface_marry(
                     struct midnightcode_interface_head_t * lives,
                     struct midnightcode_interface_head_t * stores,
                     int options);
int midnightcode_interface_isalias(
                     struct midnightcode_interface_element_t * element);
int midnightcode_interface_vendor(char * name, int name_size,
                     unsigned char * mac_addres);


#endif
