Revision 1a0ca1e1 slirp/slirp.h

b/slirp/slirp.h
170 170
/* osdep.c */
171 171
int qemu_socket(int domain, int type, int protocol);
172 172

  
173
#define ETH_ALEN 6
174
#define ETH_HLEN 14
175

  
176
#define ETH_P_IP  0x0800        /* Internet Protocol packet  */
177
#define ETH_P_ARP 0x0806        /* Address Resolution packet */
178

  
179
#define ARPOP_REQUEST 1         /* ARP request */
180
#define ARPOP_REPLY   2         /* ARP reply   */
181

  
182
struct ethhdr {
183
    unsigned char  h_dest[ETH_ALEN];   /* destination eth addr */
184
    unsigned char  h_source[ETH_ALEN]; /* source ether addr    */
185
    unsigned short h_proto;            /* packet type ID field */
186
};
187

  
188
struct arphdr {
189
    unsigned short ar_hrd;      /* format of hardware address */
190
    unsigned short ar_pro;      /* format of protocol address */
191
    unsigned char  ar_hln;      /* length of hardware address */
192
    unsigned char  ar_pln;      /* length of protocol address */
193
    unsigned short ar_op;       /* ARP opcode (command)       */
194

  
195
    /*
196
     *  Ethernet looks like this : This bit is variable sized however...
197
     */
198
    unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */
199
    uint32_t      ar_sip;           /* sender IP address       */
200
    unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
201
    uint32_t      ar_tip;           /* target IP address       */
202
} __attribute__((packed));
203

  
204
#define ARP_TABLE_SIZE 16
205

  
206
typedef struct ArpTable {
207
    struct arphdr table[ARP_TABLE_SIZE];
208
    int next_victim;
209
} ArpTable;
210

  
211
void arp_table_add(Slirp *slirp, int ip_addr, uint8_t ethaddr[ETH_ALEN]);
212

  
213
bool arp_table_search(Slirp *slirp, int in_ip_addr,
214
                      uint8_t out_ethaddr[ETH_ALEN]);
173 215

  
174 216
struct Slirp {
175 217
    QTAILQ_ENTRY(Slirp) entry;
......
181 223
    struct in_addr vdhcp_startaddr;
182 224
    struct in_addr vnameserver_addr;
183 225

  
184
    /* ARP cache for the guest IP addresses (XXX: allow many entries) */
185
    uint8_t client_ethaddr[6];
186

  
187 226
    struct in_addr client_ipaddr;
188 227
    char client_hostname[33];
189 228

  
......
227 266
    char *tftp_prefix;
228 267
    struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
229 268

  
269
    ArpTable arp_table;
270

  
230 271
    void *opaque;
231 272
};
232 273

  

Also available in: Unified diff