2016-02-15 20:01:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define PARSER_STATE_LEN 256
|
|
|
|
|
struct backend;
|
|
|
|
|
typedef bool (*parser)(struct backend *, struct packet *);
|
|
|
|
|
struct backend {
|
|
|
|
|
enum peer_type type;
|
|
|
|
|
int fd;
|
|
|
|
|
struct buf buf;
|
|
|
|
|
char parser_state[PARSER_STATE_LEN];
|
|
|
|
|
parser parser;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2016-02-15 21:12:26 +00:00
|
|
|
void backend_init(struct backend *);
|
2016-02-15 20:01:48 +00:00
|
|
|
bool backend_connect(char *, char *, struct backend *, int);
|
|
|
|
|
bool backend_read(struct backend *);
|