<commit_before>/*
 * The olsr.org Optimized Link-State Routing daemon(olsrd)
 * Copyright (c) 2004, <NAME>(<EMAIL>)
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met:
 *
 * * Redistributions of source code must retain the above copyright 
 *   notice, this list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright 
 *   notice, this list of conditions and the following disclaimer in 
 *   the documentation and/or other materials provided with the 
 *   distribution.
 * * Neither the name of olsr.org, olsrd nor the names of its 
 *   contributors may be used to endorse or promote products derived 
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * Visit http://www.olsr.org for more information.
 *
 * If you find this software useful feel free to make a donation
 * to the project. For more information see the website or contact
 * the copyright holders.
 *
 * $Id: interfaces.h,v 1.35 2006/11/15 23:07:59 bernd67 Exp $
 */


#ifndef _OLSR_INTERFACE
#define _OLSR_INTERFACE

#include <sys/types.h>
#include <sys/socket.h>
#include <time.h>

#include "olsr_types.h"

#define _PATH_PROCNET_IFINET6           "/proc/net/if_inet6"


#define IPV6_ADDR_ANY		0x0000U

#define IPV6_ADDR_UNICAST      	0x0001U
#define IPV6_ADDR_MULTICAST    	0x0002U
#define IPV6_ADDR_ANYCAST	0x0004U

#define IPV6_ADDR_LOOPBACK	0x0010U
#define IPV6_ADDR_LINKLOCAL	0x0020U
#define IPV6_ADDR_SITELOCAL	0x0040U

#define IPV6_ADDR_COMPATv4	0x0080U

#define IPV6_ADDR_SCOPE_MASK	0x00f0U

#define IPV6_ADDR_MAPPED	0x1000U
#define IPV6_ADDR_RESERVED	0x2000U


#define MAX_IF_METRIC           100


enum olsr_if_wieght
  {
    WEIGHT_LOWEST = 0,
    WEIGHT_LOW,
    WEIGHT_ETHERNET_1GBP,     /* Ethernet 1Gb+        */
    WEIGHT_ETHERNET_1GB,      /* Ethernet 1Gb         */
    WEIGHT_ETHERNET_100MB,    /* Ethernet 100Mb       */
    WEIGHT_ETHERNET_10MB,     /* Ethernet 10Mb        */
    WEIGHT_ETHERNET_DEFAULT,  /* Ethernet unknown rate*/
    WEIGHT_WLAN_HIGH,         /* >54Mb WLAN           */
    WEIGHT_WLAN_54MB,         /* 54Mb 802.11g         */
    WEIGHT_WLAN_11MB,         /* 11Mb 802.11b         */
    WEIGHT_WLAN_LOW,          /* <11Mb WLAN           */
    WEIGHT_WLAN_DEFAULT,      /* WLAN unknown rate    */
    WEIGHT_SERIAL,            /* Serial device        */
    WEIGHT_HIGH,              /* Max                  */
    WEIGHT_HIGHEST = WEIGHT_HIGH
  };

struct if_gen_property
{
  olsr_u32_t             owner_id;
  void                   *data;
  struct if_gen_property *next;
};

struct vtimes
{
  olsr_u8_t hello;
  olsr_u8_t tc;
  olsr_u8_t mid;
  olsr_u8_t hna;
};

/* Output buffer structure. This should actually be in net_olsr.h but we have circular references then.
 */
struct olsr_netbuf
{
  olsr_u8_t *buff;/* Pointer to the allocated buffer */
  int bufsize;    /* Size of the buffer */
  int maxsize;    /* Max bytes of payload that can be added to the buffer */
  int pending;    /* How much data is currently pending in the buffer */
  int reserved;   /* Plugins can reserve space in buffers */
};


/**
 *A struct containing all necessary information about each
 *interface participating in the OLSD routing
 */
struct interface 
{
  /* IP version 4 */
  struct	sockaddr int_addr;		/* address */
  struct	sockaddr int_netmask;		/* netmask */
  struct	sockaddr int_broadaddr;         /* broadcast address */
  /* IP version 6 */
  struct        sockaddr_in6 int6_addr;         /* Address */
  struct        sockaddr_in6 int6_multaddr;     /* Multicast */
  /* IP independent */
  union         olsr_ip_addr ip_addr;
  int           is_hcif;                        /* Is this a emulated host-client if? */
  int           olsr_socket;                    /* The broadcast socket for this interface */
  int	        int_metric;			/* metric of interface */
  int           int_mtu;                        /* MTU of interface */
  int	        int_flags;			/* see below */
  char	        *int_name;			/* from kernel if structure */
  int           if_index;                       /* Kernels index of this interface */
  int           if_nr;                          /* This interfaces index internally*/
  int           is_wireless;                    /* wireless interface or not*/
  olsr_u16_t    olsr_seqnum;                    /* Olsr message seqno */

  float         hello_etime;
  struct        vtimes valtimes;

  clock_t       fwdtimer;                       /* Timeout for OLSR forwarding on this if */

#ifdef USE_LIBNET
  void          *libnet_ctx;                    /* libnet context(void to avoid dependency */
#endif
  struct olsr_netbuf netbuf;                    /* the buffer to construct the packet data */

  struct        if_gen_property *gen_properties;/* Generic interface properties */

  int           ttl_index; /* index in TTL array for fish-eye */

  struct	interface *int_next;<commit_msg>* cosmetic: whitesoace cleanup<commit_after>/*
 * The olsr.org Optimized Link-State Routing daemon(olsrd)
 * Copyright (c) 2004, <NAME>(<EMAIL>)
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met:
 *
 * * Redistributions of source code must retain the above copyright 
 *   notice, this list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright 
 *   notice, this list of conditions and the following disclaimer in 
 *   the documentation and/or other materials provided with the 
 *   distribution.
 * * Neither the name of olsr.org, olsrd nor the names of its 
 *   contributors may be used to endorse or promote products derived 
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * Visit http://www.olsr.org for more information.
 *
 * If you find this software useful feel free to make a donation
 * to the project. For more information see the website or contact
 * the copyright holders.
 *
 * $Id: interfaces.h,v 1.36 2007/01/30 16:52:41 bernd67 Exp $
 */


#ifndef _OLSR_INTERFACE
#define _OLSR_INTERFACE

#include <sys/types.h>
#include <sys/socket.h>
#include <time.h>

#include "olsr_types.h"

#define _PATH_PROCNET_IFINET6           "/proc/net/if_inet6"


#define IPV6_ADDR_ANY		0x0000U

#define IPV6_ADDR_UNICAST      	0x0001U
#define IPV6_ADDR_MULTICAST    	0x0002U
#define IPV6_ADDR_ANYCAST	0x0004U

#define IPV6_ADDR_LOOPBACK	0x0010U
#define IPV6_ADDR_LINKLOCAL	0x0020U
#define IPV6_ADDR_SITELOCAL	0x0040U

#define IPV6_ADDR_COMPATv4	0x0080U

#define IPV6_ADDR_SCOPE_MASK	0x00f0U

#define IPV6_ADDR_MAPPED	0x1000U
#define IPV6_ADDR_RESERVED	0x2000U


#define MAX_IF_METRIC           100


enum olsr_if_wieght
  {
    WEIGHT_LOWEST = 0,
    WEIGHT_LOW,
    WEIGHT_ETHERNET_1GBP,     /* Ethernet 1Gb+        */
    WEIGHT_ETHERNET_1GB,      /* Ethernet 1Gb         */
    WEIGHT_ETHERNET_100MB,    /* Ethernet 100Mb       */
    WEIGHT_ETHERNET_10MB,     /* Ethernet 10Mb        */
    WEIGHT_ETHERNET_DEFAULT,  /* Ethernet unknown rate*/
    WEIGHT_WLAN_HIGH,         /* >54Mb WLAN           */
    WEIGHT_WLAN_54MB,         /* 54Mb 802.11g         */
    WEIGHT_WLAN_11MB,         /* 11Mb 802.11b         */
    WEIGHT_WLAN_LOW,          /* <11Mb WLAN           */
    WEIGHT_WLAN_DEFAULT,      /* WLAN unknown rate    */
    WEIGHT_SERIAL,            /* Serial device        */
    WEIGHT_HIGH,              /* Max                  */
    WEIGHT_HIGHEST = WEIGHT_HIGH
  };

struct if_gen_property
{
  olsr_u32_t             owner_id;
  void                   *data;
  struct if_gen_property *next;
};

struct vtimes
{
  olsr_u8_t hello;
  olsr_u8_t tc;
  olsr_u8_t mid;
  olsr_u8_t hna;
};

/* Output buffer structure. This should actually be in net_olsr.h but we have circular references then.
 */
struct olsr_netbuf
{
  olsr_u8_t *buff;/* Pointer to the allocated buffer */
  int bufsize;    /* Size of the buffer */
  int maxsize;    /* Max bytes of payload that can be added to the buffer */
  int pending;    /* How much data is currently pending in the buffer */
  int reserved;   /* Plugins can reserve space in buffers */
};


/**
 *A struct containing all necessary information about each
 *interface participating in the OLSD routing
 */
struct interface 
{
  /* IP version 4 */
  struct	sockaddr int_addr;		/* address */
  struct	sockaddr int_netmask;		/* netmask */
  struct	sockaddr int_broadaddr;         /* broadcast address */
  /* IP version 6 */
  struct        sockaddr_in6 int6_addr;         /* Address */
  struct        sockaddr_in6 int6_multaddr;     /* Multicast */
  /* IP independent */
  union         olsr_ip_addr ip_addr;
  int           is_hcif;                        /* Is this a emulated host-client if? */
  int           olsr_socket;                    /* The broadcast socket for this interface */
  int	        int_metric;			/* metric of interface */
  int           int_mtu;                        /* MTU of interface */
  int	        int_flags;			/* see below */
  char	        *int_name;			/* from kernel if structure */
  int           if_index;                       /* Kernels index of this interface */
  int           if_nr;                          /* This interfaces index internally*/
  int           is_wireless;                    /* wireless interface or not*/
  olsr_u16_t    olsr_seqnum;                    /* Olsr message seqno */

  float         hello_etime;
  struct        vtimes valtimes;

  clock_t       fwdtimer;                       /* Timeout for OLSR forwarding on this if */

#ifdef USE_LIBNET
  void          *libnet_ctx;                    /* libnet context(void to avoid dependency */
#endif
  struct olsr_netbuf netbuf;                    /* the buffer to construct the packet data */

  struct        if_gen_property *gen_properties;/* Generic interface properties */
  
  int           ttl_index; /* index in TTL array for fish-eye */

  struct	interface *int_next;
{'fraction_non_alphanumeric': 0.07044776119402985, 'fraction_numerical': 0.02490405117270789, 'mean_word_length': 2.3753598157743236, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3575909', 'n_tokens_mistral': 3891, 'n_tokens_neox': 3473, 'n_words': 1200}