aboutsummaryrefslogtreecommitdiffstats
path: root/tools/vnet/vnetd/vnetd.h
blob: 00234c6287ac3146fc1edcd7b60e4771a73bc215 (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
/*
 * Copyright (C) 2004 Mike Wray <mike.wray@hp.com>.
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of the
 * License, or  (at your option) any later version. This library 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */
#ifndef _VNET_VNETD_H_
#define _VNET_VNETD_H_

#include <asm/types.h>
#include <linux/if_ether.h>
#include "if_varp.h"
#include "varp_util.h"

#include "connection.h"
#include "sxpr.h"

/** Vnetd udp port in host order. */
#define VNETD_PORT VARP_PORT

/** Vnetd peer port in host order. */
#define VNETD_PEER_PORT (VARP_PORT + 1)

typedef struct VnetMsgVarp {
    VarpHdr varph;
} VnetMsgVarp;

#define VNET_FWD_MAX (1500 + 200)

typedef struct VnetMsgFwd {
    VnetMsgHdr;
    uint16_t protocol;
    uint16_t len;
    uint8_t data[VNET_FWD_MAX];
} __attribute__((packed)) VnetMsgFwd;

typedef union VnetMsg {
    VnetMsgHdr hdr;
    VnetMsgVarp varp;
    VnetMsgFwd fwd;
} VnetMsg;

enum {
    VNET_VARP_ID = VARP_ID,
    VNET_FWD_ID  = 200,
};

typedef struct Vnetd {
    unsigned long port;
    unsigned long peer_port;
    int verbose;

    int esp_sock;
    int etherip_sock;

    struct sockaddr_in addr;
    struct sockaddr_in mcast_addr;

    Sxpr peers;

    Conn *listen_conn;
    Conn *udp_conn;
    Conn *bcast_conn;
    
    ConnList *connections;

} Vnetd;

extern Vnetd *vnetd;

#endif /* ! _VNET_VNETD_H_ */