/*

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


#ifndef __MIDNIGHTCODE_ROUTE_H
#define __MIDNIGHTCODE_ROUTE_H 1


#define MIDNIGHTCODE_ROUTE_STRUCTURE "route"

struct midnightcode_route_element_t
{
  int flags;
  int in_ifindex;
  int out_ifindex;
  int metric;
  int priority;
  int scope;
  int is_defaultroute;
  struct in_addr ipv4_prefsource;
  struct in_addr ipv4_source;
  struct in_addr ipv4_sourcemask;
  struct in_addr ipv4_destination;
  struct in_addr ipv4_destmask;
  struct in_addr ipv4_gateway;
  char in_ifname[64];
  char out_ifname[64];
  char ipv4_prefsource_s[32];
  char ipv4_source_s[32];
  char ipv4_sourcemask_s[32];
  char ipv4_destination_s[32];
  char ipv4_destmask_s[32];
  char ipv4_gateway_s[32];
  midnightcode_list_entry(midnightcode_route_element_t)
};

midnightcode_list_head(midnightcode_route_head_t,
                       midnightcode_route_element_t)

enum midnightcode_route_scope_t
{
  MIDNIGHTCODE_ROUTE_SCOPE_GLOBAL = 0,
  MIDNIGHTCODE_ROUTE_SCOPE_SITE = 200,
  MIDNIGHTCODE_ROUTE_SCOPE_LINK = 253,
  MIDNIGHTCODE_ROUTE_SCOPE_HOST = 254,
  MIDNIGHTCODE_ROUTE_SCOPE_NOWHERE = 255
};

int midnightcode_route_scope(char * buffer, int buffer_size, int scope);
int midnightcode_route_listrecv(int sockfd, char *msgbuf, int bufsize,
                  uint msgseq, uint msgpid);
int midnightcode_route_listadd(
                  struct midnightcode_route_head_t * elements,
                  struct midnightcode_route_element_t * now_element,
                  void * msg_nlhdr);
int midnightcode_route_default(struct midnightcode_route_head_t *elements);
int midnightcode_route_list(struct midnightcode_route_head_t * elements);
int midnightcode_route_add(char * ipv4_address_s, char * ipv4_mask_s,
                  char * ipv4_gateway_s, char * interface);
int midnightcode_route_to_config(
                  struct midnightcode_route_head_t * route_elements,
                  struct midnightcode_config_head_t * config_elements);
int midnightcode_route_from_config(
                  struct midnightcode_route_head_t * route_elements,
                  struct midnightcode_config_head_t * config_elements);

#endif
