📄 ethernet.h
字号:
// Copyright (C) 2002-2003 Intel Corporation, All Rights Reserved.
// Permission is hereby granted to merge this program code with
// other program material to create a derivative work. This
// derivative work may be distributed in compiled object form only.
// Any other publication of this program, in any form, without the
// explicit permission of the copyright holder is prohibited.
//
// Send questions and comments to erik.j.johnson@intel.com,
// aaron.kunze@intel.com
//-------------------------------------------------------------------
// ethernet.h - Chapter 6
// This file defines functions to process Ethernet II packets.
//
#include <ixp.h>
#include <dl_meta.h>
// These defines are the outputs from
// ethernet_validate
// ---------------------------------------------------
// The packet is invalid:
#define ETHERNET_VALIDATE_INVALID (IX_DROP + 1)
// The packet is valid and the packet's destination
// MAC address is the address of this device:
#define ETHERNET_VALIDATE_LOCAL (IX_DROP + 2)
// The packet is valid and the packet's destination
// MAC address is a multicast address:
#define ETHERNET_VALIDATE_MULTICAST (IX_DROP + 3)
// The packet is valid and the packet's destination
// MAC address is a broadcast address:
#define ETHERNET_VALIDATE_BROADCAST (IX_DROP + 4)
// The packet is valid, but not local, multicast, or
// broadcast:
#define ETHERNET_VALIDATE_OTHER (IX_DROP + 5)
// These defines are the outputs from
// ethernet_add_header
// ---------------------------------------------------
// The next hop MAC address was found and the Ethernet
// header was successfully added.
#define ETHERNET_ADD_HEADER_PASS (IX_DROP + 1)
// The output from ethernet_strip_header is the
// Ethernet protocol number. This particular one is
// for IP
#define ETHERNET_PROTO_IP 0x0800
//-------------------------------------------------------------------
// ethernet_init
//
// Description:
// Sets up any global settings needed to run any of the
// Ethernet functions. This needs to be called only
// once. Right now all it does is set up the hash
// multiplier.
//
// Parameters:
// None.
//
// Side effects: Hash multiplier is set.
//
// See also: n/a
//
// Example Usage: ethernet_init();
//
void ethernet_init();
//-------------------------------------------------------------------
// ethernet_validate
//
// Description:
// Verifies that the passed in packet is long enough to be an
// Ethernet II packet and has a valid source MAC address.
// Also tells the caller if the packet is addressed to the
// local address, a multicast address, and/or a broadcast
// address. The local address is determined from a place in
// SRAM that is set by the XScale core.
//
// Parameters:
// n/a
//
// Side effects: n/a
//
// See also: n/a
//
// Example Usage: ethernet_validate()
//
void ethernet_validate();
//-------------------------------------------------------------------
// ethernet_strip_header
//
// Description:
// Removes the Ethernet header from the packet puts
// the Ethernet protocol number in dl_next_block.
//
// Parameters:
// n/a
//
// Side effects: n/a
//
// See also: n/a
//
// Example Usage: ethernet_strip_header();
//
void ethernet_strip_header();
//-------------------------------------------------------------------
// ethernet_add_header
//
// Description:
// Adds an Ethernet header to an IP packet. This function uses
// the next hop ID as an index into a table and retrieves a MAC
// address to put in the destination address of the Ethernet
// packet. The source MAC address is set to the MAC address of
// the device. The Ethernet protocol number is passed in.
//
// Parameters:
// Inputs: eth_proto The Ethernet protocol number
// to insert in the packet.
// Constants: n/a
// Labels: n/a
//
// Side effects: n/a
//
// See also: n/a
//
// Example Usage: ethernet_add_header(ETH_PROTO_IP)
//
void ethernet_add_header(unsigned int eth_proto);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -