Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tuntap.h File Reference
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  device
 

Macros

#define LIBTUNTAP_H_
 
#define IF_NAMESIZE   16
 
#define IF_DESCRSIZE   50 /* XXX: Tests needed on NetBSD and OpenBSD */
 
#define TUNFD_INVALID_VALUE   -1
 
#define TUNTAP_ID_MAX   256
 
#define TUNTAP_ID_ANY   257
 
#define TUNTAP_MODE_ETHERNET   0x0001
 
#define TUNTAP_MODE_TUNNEL   0x0002
 
#define TUNTAP_MODE_PERSIST   0x0004
 
#define TUNTAP_LOG_NONE   0x0000
 
#define TUNTAP_LOG_DEBUG   0x0001
 
#define TUNTAP_LOG_INFO   0x0002
 
#define TUNTAP_LOG_NOTICE   0x0004
 
#define TUNTAP_LOG_WARN   0x0008
 
#define TUNTAP_LOG_ERR   0x0016
 
#define TUNTAP_VERSION_MAJOR   0
 
#define TUNTAP_VERSION_MINOR   3
 
#define TUNTAP_VERSION   ((TUNTAP_VERSION_MAJOR<<8)|TUNTAP_VERSION_MINOR)
 
#define TUNTAP_GET_FD(x)   (x)->tun_fd
 
#define TUNTAP_EXPORT
 

Typedefs

typedef int t_tun
 
typedef struct in_addr t_tun_in_addr
 
typedef struct in6_addr t_tun_in6_addr
 
typedef void(* t_tuntap_log )(int, const char *)
 

Functions

TUNTAP_EXPORT struct devicetuntap_init (void)
 
TUNTAP_EXPORT int tuntap_version (void)
 
TUNTAP_EXPORT void tuntap_destroy (struct device *)
 
TUNTAP_EXPORT void tuntap_release (struct device *)
 
TUNTAP_EXPORT int tuntap_start (struct device *, int, int)
 
TUNTAP_EXPORT char * tuntap_get_ifname (struct device *)
 
TUNTAP_EXPORT int tuntap_set_ifname (struct device *, const char *)
 
TUNTAP_EXPORT char * tuntap_get_hwaddr (struct device *)
 
TUNTAP_EXPORT int tuntap_set_hwaddr (struct device *, const char *)
 
TUNTAP_EXPORT int tuntap_set_descr (struct device *, const char *)
 
TUNTAP_EXPORT int tuntap_up (struct device *)
 
TUNTAP_EXPORT int tuntap_down (struct device *)
 
TUNTAP_EXPORT int tuntap_get_mtu (struct device *)
 
TUNTAP_EXPORT int tuntap_set_mtu (struct device *, int)
 
TUNTAP_EXPORT int tuntap_set_ip (struct device *, const char *, int)
 
TUNTAP_EXPORT int tuntap_read (struct device *, void *, size_t)
 
TUNTAP_EXPORT int tuntap_write (struct device *, void *, size_t)
 
TUNTAP_EXPORT int tuntap_get_readable (struct device *)
 
TUNTAP_EXPORT int tuntap_set_nonblocking (struct device *dev, int)
 
TUNTAP_EXPORT int tuntap_set_debug (struct device *dev, int)
 
TUNTAP_EXPORT void tuntap_log_set_cb (t_tuntap_log cb)
 Copyright (c) 2012, PICHOT Fabien Paul Leonard <pichot.fabienATgmail.com> Copyright (c) 2012, Tristan Le Guern <leguern at="" medu="" dot="" se>=""> More...
 
void tuntap_log_default (int, const char *)
 
void tuntap_log_hexdump (void *, size_t)
 
void tuntap_log_chksum (void *, int)
 
int tuntap_sys_start (struct device *, int, int)
 
void tuntap_sys_destroy (struct device *)
 
int tuntap_sys_set_hwaddr (struct device *, struct ether_addr *)
 
int tuntap_sys_set_ipv4 (struct device *, t_tun_in_addr *, uint32_t)
 
int tuntap_sys_set_ipv6 (struct device *, t_tun_in6_addr *, uint32_t)
 
int tuntap_sys_set_ifname (struct device *, const char *, size_t)
 
int tuntap_sys_set_descr (struct device *, const char *, size_t)
 

Variables

TUNTAP_EXPORT t_tuntap_log tuntap_log
 

Macro Definition Documentation

#define IF_DESCRSIZE   50 /* XXX: Tests needed on NetBSD and OpenBSD */

Referenced by tuntap_set_descr().

#define IF_NAMESIZE   16
#define LIBTUNTAP_H_
#define TUNFD_INVALID_VALUE   -1
#define TUNTAP_EXPORT
#define TUNTAP_GET_FD (   x)    (x)->tun_fd
#define TUNTAP_ID_ANY   257
#define TUNTAP_ID_MAX   256

Referenced by tuntap_sys_start().

#define TUNTAP_LOG_DEBUG   0x0001
#define TUNTAP_LOG_INFO   0x0002
#define TUNTAP_LOG_NONE   0x0000
#define TUNTAP_MODE_ETHERNET   0x0001
#define TUNTAP_MODE_PERSIST   0x0004
#define TUNTAP_MODE_TUNNEL   0x0002
#define TUNTAP_VERSION   ((TUNTAP_VERSION_MAJOR<<8)|TUNTAP_VERSION_MINOR)

Referenced by tuntap_version().

#define TUNTAP_VERSION_MAJOR   0
#define TUNTAP_VERSION_MINOR   3

Typedef Documentation

typedef int t_tun
typedef struct in6_addr t_tun_in6_addr
typedef struct in_addr t_tun_in_addr
typedef void(* t_tuntap_log)(int, const char *)

Function Documentation

TUNTAP_EXPORT void tuntap_destroy ( struct device )

References tuntap_release(), and tuntap_sys_destroy().

Referenced by main().

TUNTAP_EXPORT int tuntap_down ( struct device )
TUNTAP_EXPORT char* tuntap_get_hwaddr ( struct device )
TUNTAP_EXPORT char* tuntap_get_ifname ( struct device )

References device::if_name.

TUNTAP_EXPORT int tuntap_get_readable ( struct device )
void tuntap_log_chksum ( void *  ,
int   
)

References tuntap_log, and TUNTAP_LOG_NONE.

void tuntap_log_default ( int  ,
const char *   
)
void tuntap_log_hexdump ( void *  ,
size_t   
)

References tuntap_log, and TUNTAP_LOG_NONE.

TUNTAP_EXPORT void tuntap_log_set_cb ( t_tuntap_log  cb)

Copyright (c) 2012, PICHOT Fabien Paul Leonard <pichot.fabienATgmail.com> Copyright (c) 2012, Tristan Le Guern <leguern at="" medu="" dot="" se>="">

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

References tuntap_log, and tuntap_log_default().

Referenced by main().

TUNTAP_EXPORT int tuntap_read ( struct device ,
void *  ,
size_t   
)
TUNTAP_EXPORT void tuntap_release ( struct device )

References device::ctrl_sock, free(), and device::tun_fd.

Referenced by main(), and tuntap_destroy().

TUNTAP_EXPORT int tuntap_set_debug ( struct device dev,
int   
)
TUNTAP_EXPORT int tuntap_set_descr ( struct device ,
const char *   
)
TUNTAP_EXPORT int tuntap_set_hwaddr ( struct device ,
const char *   
)
TUNTAP_EXPORT int tuntap_set_ifname ( struct device ,
const char *   
)
TUNTAP_EXPORT int tuntap_set_ip ( struct device ,
const char *  ,
int   
)
TUNTAP_EXPORT int tuntap_set_mtu ( struct device ,
int   
)
TUNTAP_EXPORT int tuntap_set_nonblocking ( struct device dev,
int   
)
void tuntap_sys_destroy ( struct device )
int tuntap_sys_set_descr ( struct device ,
const char *  ,
size_t   
)
int tuntap_sys_set_hwaddr ( struct device ,
struct ether_addr *   
)
int tuntap_sys_set_ifname ( struct device ,
const char *  ,
size_t   
)
int tuntap_sys_set_ipv4 ( struct device ,
t_tun_in_addr ,
uint32_t   
)
int tuntap_sys_set_ipv6 ( struct device ,
t_tun_in6_addr ,
uint32_t   
)

References tuntap_log, TUNTAP_LOG_INFO, and TUNTAP_LOG_NOTICE.

Referenced by tuntap_set_ip().

TUNTAP_EXPORT int tuntap_up ( struct device )

References device::ctrl_sock, device::flags, if(), and device::if_name.

Referenced by main().

TUNTAP_EXPORT int tuntap_version ( void  )

References TUNTAP_VERSION.

TUNTAP_EXPORT int tuntap_write ( struct device ,
void *  ,
size_t   
)

Variable Documentation