Back to the Résumé

#ifndef __P2P_H
#define __P2P_H

/* includes for the library */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
extern int errno;

#include "p2p_public.h"

/*** general defines *****************************************************/

#define FALSE 0
#define TRUE  1

/* error levels for errors_suck() */
#define FATAL 0x01
#define WARN  0x02
#define SYS   0x04

/* default maximums */
#define MAX_DGRAM 4096            /* the biggest datagram we accept */
#define MAX_BUFFER 256
#define MAX_QUEUE 8               /* our datagram queue size */

#define MAX_ADDRESS 256           /* maximum hostname length */
#define MAX_INTERFACE 10          /* maximum IF name length */
#define DEFAULT_INTERFACE "eth0"
#define RECV_PORT 31337           /* default port for transmissions */

/* crypto defines */
#define NUM_ROUNDS 8              /* should be >6 */
#define BLOCK_SIZE (sizeof(crypt_t) * 2)

/*** typedefs ************************************************************/

typedef int BOOL;

/* the datagram queue unit */
typedef struct {
   void *dg;
   size_t dg_len;
   struct sockaddr *sa;
   socklen_t sa_len;
} dgram;

/*** prototypes **********************************************************/

/* private functions */
int p2p_server_main(void);
int p2p_client_main(void);

void p2p_setkey(crypt_t);
BOOL p2p_iskeyset(void);
char *p2p_encrypt(char *, size_t *);
size_t p2p_decrypt(char *, size_t);

char *p2p_padding_add(char *, size_t *);
size_t p2p_padding_remove(char *, size_t);
void p2p_padding_free(char *);

void p2p_error(int, int, char *, ...);


#endif /* __P2P_H */


Back to the Résumé