2012-05-17 20:14:22 +01:00
|
|
|
#ifndef __PARAMS_H
|
|
|
|
#define __PARAMS_H
|
|
|
|
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#define _LARGEFILE64_SOURCE
|
|
|
|
|
2012-05-19 12:48:03 +01:00
|
|
|
#include "parse.h"
|
2012-05-17 20:14:22 +01:00
|
|
|
|
2012-05-19 12:48:03 +01:00
|
|
|
#include <sys/types.h>
|
2012-05-17 20:14:22 +01:00
|
|
|
|
2012-05-24 01:39:35 +01:00
|
|
|
enum mirror_finish_action {
|
|
|
|
ACTION_PROXY,
|
|
|
|
ACTION_EXIT,
|
|
|
|
ACTION_NOTHING
|
|
|
|
};
|
|
|
|
|
2012-05-21 04:03:17 +01:00
|
|
|
struct mirror_status {
|
|
|
|
pthread_t thread;
|
|
|
|
int client;
|
|
|
|
char *filename;
|
|
|
|
off64_t max_bytes_per_second;
|
2012-05-24 01:39:35 +01:00
|
|
|
enum mirror_finish_action action_at_finish;
|
2012-05-21 04:03:17 +01:00
|
|
|
|
|
|
|
char *mapped;
|
|
|
|
struct bitset_mapping *dirty_map;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct control_params {
|
|
|
|
int socket;
|
|
|
|
struct mode_serve_params* serve;
|
|
|
|
};
|
|
|
|
|
2012-05-17 20:14:22 +01:00
|
|
|
struct mode_serve_params {
|
2012-05-24 01:39:35 +01:00
|
|
|
/* address/port to bind to */
|
2012-05-17 20:14:22 +01:00
|
|
|
union mysockaddr bind_to;
|
2012-05-24 01:39:35 +01:00
|
|
|
/* number of entries in current access control list*/
|
2012-05-17 20:14:22 +01:00
|
|
|
int acl_entries;
|
2012-05-24 01:39:35 +01:00
|
|
|
/* pointer to access control list entries*/
|
2012-05-21 04:03:17 +01:00
|
|
|
struct ip_and_mask (*acl)[0];
|
2012-05-24 01:39:35 +01:00
|
|
|
/* file name to serve */
|
2012-05-17 20:14:22 +01:00
|
|
|
char* filename;
|
2012-05-24 01:39:35 +01:00
|
|
|
/* TCP backlog for listen() */
|
2012-05-17 20:14:22 +01:00
|
|
|
int tcp_backlog;
|
2012-05-24 01:39:35 +01:00
|
|
|
/* file name of UNIX control socket (or NULL if none) */
|
2012-05-18 18:44:34 +01:00
|
|
|
char* control_socket_name;
|
2012-05-24 01:39:35 +01:00
|
|
|
/* size of file */
|
2012-05-21 04:03:17 +01:00
|
|
|
off64_t size;
|
2012-05-24 01:39:35 +01:00
|
|
|
/* if you want the main thread to pause, set this to an writeable
|
|
|
|
* file descriptor. The main thread will then write a byte once it
|
|
|
|
* promises to hang any further writes.
|
|
|
|
*/
|
|
|
|
int pause_fd;
|
|
|
|
/* the main thread will set this when writes will be paused */
|
|
|
|
int paused;
|
|
|
|
/* set to non-zero to use given destination connection as proxy */
|
|
|
|
int proxy_fd;
|
2012-05-21 04:03:17 +01:00
|
|
|
|
|
|
|
struct mirror_status* mirror;
|
2012-05-17 20:14:22 +01:00
|
|
|
int server;
|
2012-05-18 23:39:16 +01:00
|
|
|
int control;
|
2012-05-17 20:14:22 +01:00
|
|
|
|
|
|
|
char* block_allocation_map;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mode_readwrite_params {
|
|
|
|
union mysockaddr connect_to;
|
|
|
|
off64_t from;
|
|
|
|
off64_t len;
|
|
|
|
int data_fd;
|
|
|
|
int client;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct client_params {
|
|
|
|
int socket;
|
|
|
|
|
|
|
|
int fileno;
|
|
|
|
char* mapped;
|
|
|
|
|
2012-05-21 04:03:17 +01:00
|
|
|
struct mode_serve_params* serve; /* FIXME: remove above duplication */
|
2012-05-19 12:48:03 +01:00
|
|
|
};
|
|
|
|
|
2012-05-17 20:14:22 +01:00
|
|
|
#endif
|
|
|
|
|