summaryrefslogtreecommitdiff
path: root/cleopatre/application/managerd/inc/bridge.h
blob: 5b9599e84841510dfd53a800eca29ddee729e078 (plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * cleopatre/application/managerd/inc/bridge.h
 *
 * (C) Copyright 2009 SPiDCOM Technologies
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */
#ifndef BRIDGE_H
#define BRIDGE_H

#include "libmme.h"
#include "mme_nl.h"
#include "managerd.h"
#include "vs_mme.h"

/** Interfaces name */
#define BR_IFNAME    "br0"
#define LO_IFNAME    "lo"
#define PLC_IFNAME   "plc0"
#define ETH_IFNAME   "eth0"

/** Reception timeout in seconds */
#define WAIT_TOUT       1

/** return status for bridge_processing */
enum bridge_status {
    TO_SEND=0,
    TO_DROP=1,
};
/**
 * Processing a received frame before sending it.
 * Analyse received frame on buffer pointer, processing it
 * and give it on buffer pointer.
 *
 * \param  ctx  managerd context.
 * \param  buffer  received frame.
 * \param  len  received frame length that will be updated.
 * \param  max_len  size max of buffer.
 * \return  bridge status.
 */
enum bridge_status bridge_processing(struct managerd_ctx *ctx, uint8_t *buffer, int *len, int max_len);

/**
 * Receive a frame from BR interface.
 *
 * \param  ctx  managerd context.
 * \param  buffer  frame pointer.
 * \param  len  length allowed.
 * \return  received length or error code.
 */
int bridge_receive (struct managerd_ctx *ctx, uint8_t *buffer, int len);

/**
 * Send a frame to BR interface.
 *
 * \param  ctx  managerd context.
 * \param  buffer  frame pointer.
 * \param  len  length to send.
 * \return  error code.
 */
int bridge_send(struct managerd_ctx *ctx, uint8_t *buffer, int len);

/**
 * Initialize and prepare connections.
 *
 * \param  ctx  managerd context.
 * \return  error code.
 */
int bridge_init(struct managerd_ctx *ctx);

/**
 * Close connections.
 *
 * \param  ctx  managerd context.
 */
void bridge_uninit(struct managerd_ctx *ctx);

#endif /* BRIDGE_H */