43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
#ifndef _UTIL_H_
|
|
#define _UTIL_H_
|
|
|
|
#include "rlocs.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include <openssl/sha.h>
|
|
|
|
#define debug(msg, ...) { fprintf( stderr, msg, ##__VA_ARGS__ ) ; fprintf( stdout, "\n" ); }
|
|
#define info(msg, ...) { fprintf( stdout, msg, ##__VA_ARGS__ ) ; fprintf( stdout, "\n" ); }
|
|
#define warn(msg, ...) { fprintf( stderr, msg, ##__VA_ARGS__ ) ; fprintf( stderr, "\n" ); }
|
|
|
|
|
|
void* xmalloc( size_t bytes );
|
|
int create_tun( const char* name );
|
|
|
|
int link_set_up( char *link_name, int state );
|
|
|
|
/* Our programs use this common struct to take advantage of common init code */
|
|
struct session {
|
|
struct rlocs *rlocs;
|
|
int listen_if;
|
|
int output_if;
|
|
int same_if;
|
|
};
|
|
|
|
int session_setup( struct session *session, char *config_file, char *listen_if, char *output_if );
|
|
|
|
|
|
/* We take an array of 2n rlocs to upgrade. First element of each pair is
|
|
* IP address, second element of each pair is path to private key file
|
|
*/
|
|
int session_upgrade_rlocs( struct session *session, int argc, char** args );
|
|
void session_teardown( struct session *session );
|
|
|
|
int sha256sum( unsigned char *src, size_t src_len, unsigned char dst[SHA256_DIGEST_LENGTH] );
|
|
|
|
|
|
|
|
#endif |