debuggers.hg

view tools/vnet/vnet-module/if_varp.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 /*
2 * Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free software Foundation, Inc.,
16 * 59 Temple Place, suite 330, Boston, MA 02111-1307 USA
17 *
18 */
20 #ifndef _VNET_IF_VARP_H
21 #define _VNET_IF_VARP_H
23 /* Need struct in_addr, struct in6_addr. */
24 #ifdef __KERNEL__
26 #include <linux/in.h>
27 #include <linux/in6.h>
29 #else
31 #include <sys/socket.h>
32 #include <netinet/in.h>
34 #endif
36 #include <linux/if_ether.h>
38 typedef struct Vmac {
39 unsigned char mac[ETH_ALEN];
40 } Vmac;
42 enum {
43 /* Varp protocol messages.
44 * Format is defined by struct VarpHdr.
45 */
46 VARP_ID = 1,
48 /* Vnet ethernet in udp messages.
49 * Format is uint16_t id (VUDP_ID), then
50 * struct etheriphdr.
51 */
52 VUDP_ID = 2,
54 /* Forwarded messages.
55 */
56 VFWD_ID = 3,
58 /* Varp request. */
59 VARP_OP_REQUEST = 1,
60 /* Varp announce. */
61 VARP_OP_ANNOUNCE = 2,
62 };
64 #define VNETID_SIZE8 16
65 #define VNETID_SIZE16 (VNETID_SIZE8 >> 1)
66 #define VNETID_SIZE32 (VNETID_SIZE8 >> 2)
68 typedef struct VnetId {
69 union {
70 uint8_t vnet8[VNETID_SIZE8];
71 uint16_t vnet16[VNETID_SIZE16];
72 uint32_t vnet32[VNETID_SIZE32];
73 } u;
74 } __attribute__((packed)) VnetId;
76 typedef struct VarpAddr {
77 uint8_t family; // AF_INET or AF_INET6.
78 union {
79 uint8_t raw[16];
80 struct in_addr ip4;
81 struct in6_addr ip6;
82 } u;
83 //uint16_t port;
84 } __attribute__((packed)) VarpAddr;
86 typedef struct VnetMsgHdr {
87 uint16_t id;
88 uint16_t opcode;
89 } __attribute__((packed)) VnetMsgHdr;
91 typedef struct VarpHdr {
92 VnetMsgHdr hdr;
93 VnetId vnet;
94 Vmac vmac;
95 VarpAddr addr;
96 } __attribute__((packed)) VarpHdr;
99 /** Default address for varp/vnet broadcasts: 224.10.0.1 */
100 #define VARP_MCAST_ADDR 0xe00a0001
102 /** UDP port to use for varp protocol. */
103 #define VARP_PORT 1798
105 #endif /* ! _VNET_IF_VARP_H */