Sha256: bd24146996259f0877a5456a11a076e4523176512aa0d34aa1333db972150fde

Contents?: true

Size: 1.86 KB

Versions: 23

Compression:

Stored size: 1.86 KB

Contents

/*
  Copyright (C) 2009-2012 NEC Corporation

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License, version 2, as
  published by the Free Software Foundation.

  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.,
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef _ETH_H_
#define _ETH_H_

#include <stdint.h>

#define ETH_ADDR_LEN 6
#define ETH_TYPE_LEN 2
#define ETH_TYPE_IPV4 0x0800
#define ETH_TYPE_ARP 0x0806

typedef struct eth {
    uint8_t src[ETH_ADDR_LEN];
    uint8_t dst[ETH_ADDR_LEN];
    uint16_t type;
    uint32_t length; /* payload length not including header fields */
    uint8_t *payload;
} eth;

extern uint8_t eth_mac_addr_bc[ETH_ADDR_LEN];

eth *eth_create(uint8_t src[ETH_ADDR_LEN], uint8_t dst[ETH_ADDR_LEN],
                uint16_t type, uint8_t *payload, uint32_t length);
eth *eth_create_from_raw(uint8_t *frame, uint32_t length);
int eth_destroy(eth *eth);
int eth_set_src(eth *eth, uint8_t *src);
int eth_set_dst(eth *eth, uint8_t *dst);
int eth_set_type(eth *eth, uint16_t type);
int eth_set_payload(eth *eth, uint8_t *payload, uint32_t length);
int eth_set_payload_nocopy(eth *eth, uint8_t *payload, uint32_t length);

int eth_get_src(eth *eth, uint8_t *src);
int eth_get_dst(eth *eth, uint8_t *dst);
int eth_get_type(eth *eth, uint16_t *type);
int eth_get_payload(eth *eth, uint8_t *payload, uint32_t *length);

uint8_t *eth_get_frame(eth *eth, uint8_t *buffer, uint32_t *length);

char *eth_dump(eth *eth, char *dump);

#endif /* _ETH_H_ */

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
trema-0.3.9 vendor/phost/src/eth.h
trema-0.3.8 vendor/phost/src/eth.h
trema-0.3.7 vendor/phost/src/eth.h
trema-0.3.6 vendor/phost/src/eth.h
trema-0.3.5 vendor/phost/src/eth.h
trema-0.3.4 vendor/phost/src/eth.h
trema-0.3.3 vendor/phost/src/eth.h
trema-0.3.2 vendor/phost/src/eth.h
trema-0.3.1 vendor/phost/src/eth.h
trema-0.3.0 vendor/phost/src/eth.h
trema-0.2.8 vendor/phost/src/eth.h
trema-0.2.7 vendor/phost/src/eth.h
trema-0.2.6 vendor/phost/src/eth.h
trema-0.2.5 vendor/phost/src/eth.h
trema-0.2.4 vendor/phost/src/eth.h
trema-0.2.3 vendor/phost/src/eth.h
trema-0.2.2.1 vendor/phost/src/eth.h
trema-0.2.2 vendor/phost/src/eth.h
trema-0.2.1 vendor/phost/src/eth.h
trema-0.2.0 vendor/phost/src/eth.h