1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/*
* $Id: conn_eth.c,v 1.6 2009-06-17 06:34:41 vrsieh Exp $
*
* Copyright (C) 2003-2009 FAUmachine Team <info@faumachine.org>.
* This program is free software. You can redistribute it and/or modify it
* under the terms of the GNU General Public License, either version 2 of
* the License, or (at your option) any later version. See COPYING.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "conn_eth.h"
#define CHIP_(x) conn_eth_ ## x
struct cpssp {
struct sig_eth *port_board;
struct sig_eth *port_eth;
};
static void
CHIP_(out_recv)(void *_cpssp, const void *buf, unsigned int buflen)
{
struct cpssp *cpssp = _cpssp;
sig_eth_send(cpssp->port_eth, cpssp, buf, buflen);
}
static void
CHIP_(in_recv)(void *_cpssp, const void *buf, unsigned int buflen)
{
struct cpssp *cpssp = _cpssp;
sig_eth_send(cpssp->port_board, cpssp, buf, buflen);
}
void *
CHIP_(create)(
const char *name,
struct sig_manage *port_manage,
struct sig_eth *port_board,
struct sig_eth *port_eth
)
{
static const struct sig_eth_funcs board_funcs = {
.recv = CHIP_(out_recv),
};
static const struct sig_eth_funcs eth_funcs = {
.recv = CHIP_(in_recv),
};
struct cpssp *cpssp;
cpssp = malloc(sizeof(*cpssp));
assert(cpssp);
/* Call */
cpssp->port_board = port_board;
sig_eth_connect(port_board, cpssp, &board_funcs);
cpssp->port_eth = port_eth;
sig_eth_connect(port_eth, cpssp, ð_funcs);
/* Out */
/* In */
return cpssp;
}
void
CHIP_(destroy)(void *_cpssp)
{
struct cpssp *cpssp = _cpssp;
free(cpssp);
}
|