Commit cb2454cc authored by Cedric Roux's avatar Cedric Roux
Browse files

first version of forwarder

to be redone (the local tracer shall not configure the tracee by
itself but only forward what the remote tracer sends)
parent ee5d8c60
#include "defs.h"
#include <stdlib.h>
#include <stdio.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <unistd.h>
typedef struct {
int s;
} forward_data;
void *forwarder(char *ip, int port)
return 0;
forward_data *f;
struct sockaddr_in a;
f = malloc(sizeof(*f)); if (f == NULL) abort();
f->s = socket(AF_INET, SOCK_STREAM, 0);
if (f->s == -1) { perror("socket"); exit(1); }
a.sin_family = AF_INET;
a.sin_port = htons(port);
a.sin_addr.s_addr = inet_addr(ip);
if (connect(f->s, (struct sockaddr *)&a, sizeof(a)) == -1)
{ perror("connect"); exit(1); }
return f;
void forward(void *_fowarder, char *buf, int size)
void forward(void *_forwarder, char *buf, int size)
forward_data *f = _forwarder;
while (size) {
int l = write(f->s, buf, size);
if (l <= 0) { printf("forward error\n"); exit(1); }
size -= l;
buf += l;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment