Blame ether.h

Packit 9c3e7e
/**
Packit 9c3e7e
 * @file ether.h
Packit 9c3e7e
 * @brief Provides definitions useful when working with Ethernet packets.
Packit 9c3e7e
 * @note Copyright (C) 2012 Richard Cochran <richardcochran@gmail.com>
Packit 9c3e7e
 *
Packit 9c3e7e
 * This program is free software; you can redistribute it and/or modify
Packit 9c3e7e
 * it under the terms of the GNU General Public License as published by
Packit 9c3e7e
 * the Free Software Foundation; either version 2 of the License, or
Packit 9c3e7e
 * (at your option) any later version.
Packit 9c3e7e
 *
Packit 9c3e7e
 * This program is distributed in the hope that it will be useful,
Packit 9c3e7e
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 9c3e7e
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 9c3e7e
 * GNU General Public License for more details.
Packit 9c3e7e
 *
Packit 9c3e7e
 * You should have received a copy of the GNU General Public License along
Packit 9c3e7e
 * with this program; if not, write to the Free Software Foundation, Inc.,
Packit 9c3e7e
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Packit 9c3e7e
 */
Packit 9c3e7e
#ifndef HAVE_ETHER_H
Packit 9c3e7e
#define HAVE_ETHER_H
Packit 9c3e7e
Packit 9c3e7e
#include <stdint.h>
Packit 9c3e7e
Packit 9c3e7e
#define EUI48 6
Packit 9c3e7e
#define EUI64 8
Packit 9c3e7e
Packit 9c3e7e
#define MAC_LEN  EUI48
Packit 9c3e7e
#define GUID_LEN EUI64
Packit 9c3e7e
Packit 9c3e7e
#define GUID_OFFSET 36
Packit 9c3e7e
Packit 9c3e7e
typedef uint8_t eth_addr[MAC_LEN];
Packit 9c3e7e
Packit 9c3e7e
struct eth_hdr {
Packit 9c3e7e
	eth_addr dst;
Packit 9c3e7e
	eth_addr src;
Packit 9c3e7e
	uint16_t type;
Packit 9c3e7e
} __attribute__((packed));
Packit 9c3e7e
Packit 9c3e7e
#define VLAN_HLEN 4
Packit 9c3e7e
Packit 9c3e7e
struct vlan_hdr {
Packit 9c3e7e
	eth_addr dst;
Packit 9c3e7e
	eth_addr src;
Packit 9c3e7e
	uint16_t tpid;
Packit 9c3e7e
	uint16_t tci;
Packit 9c3e7e
	uint16_t type;
Packit 9c3e7e
} __attribute__((packed));
Packit 9c3e7e
Packit 9c3e7e
#define OFF_ETYPE (2 * sizeof(eth_addr))
Packit 9c3e7e
Packit 9c3e7e
#endif