Main Page | Directories | File List | Globals

eth_core.c File Reference

#include <agnix/agnix.h>
#include <agnix/adi/adi.h>
#include <agnix/init.h>
#include <agnix/net/net.h>
#include <agnix/memory.h>
#include <agnix/console.h>
#include <agnix/sprintf.h>

Include dependency graph for eth_core.c:

Go to the source code of this file.

Defines

#define ETH_CORE_DEBUG   0
#define MOD_NAME   "NET: "

Functions

int eth_header_build (struct frb_s *frb, u8 *mac_dest, u8 *mac_source, u16 proto)
int eth_header_parse (struct frb_s *frb)
int eth_set_mtu (struct adi_netdev_s *netdev, int mtu)
int eth_set_mac_addr (struct adi_netdev_s *netdev, u8 *mac_addr)
int eth_set_broadcast_addr (struct adi_netdev_s *netdev, u8 *broadcast_addr)
int eth_device_compose_name (struct adi_netdev_s *netdev)
int eth_device_init (struct adi_netdev_s *netdev)
int net_layer_2_eth_init (void)

Variables

int eth_device_nr = 0


Define Documentation

#define ETH_CORE_DEBUG   0
 

Definition at line 22 of file eth_core.c.

#define MOD_NAME   "NET: "
 

Definition at line 23 of file eth_core.c.


Function Documentation

int eth_device_compose_name struct adi_netdev_s *  netdev  ) 
 

Definition at line 95 of file eth_core.c.

References eth_device_nr, and sprintf().

Referenced by adi_netdev_compose_name().

00096 {
00097     sprintf(netdev->if_name, "eth%d", eth_device_nr);    
00098     eth_device_nr++;
00099 
00100     return 0;
00101 }

Here is the call graph for this function:

int eth_device_init struct adi_netdev_s *  netdev  ) 
 

Definition at line 103 of file eth_core.c.

References eth_header_build(), eth_header_parse(), eth_set_broadcast_addr(), eth_set_mac_addr(), and eth_set_mtu().

Referenced by adi_netdev_init().

00104 {
00105     netdev->if_layer_2.if_addr_len      = NET_LAYER_2_ETH_MAC_LEN;
00106     netdev->if_layer_2.if_mtu           = NET_LAYER_2_ETH_MTU;
00107     netdev->if_layer_2.if_type          = IF_TYPE_ETH;
00108     netdev->if_ops->set_mac_addr        = eth_set_mac_addr;
00109     netdev->if_ops->set_broadcast_addr  = eth_set_broadcast_addr;
00110     netdev->if_ops->set_mtu             = eth_set_mtu;
00111     netdev->if_ops->header_build        = eth_header_build;
00112     netdev->if_ops->header_parse        = eth_header_parse;
00113 
00114     eth_set_broadcast_addr(netdev, NET_LAYER_2_ETH_BROADCAST);
00115     
00116     return 0;
00117 }

Here is the call graph for this function:

int eth_header_build struct frb_s *  frb,
u8 *  mac_dest,
u8 *  mac_source,
u16  proto
 

Definition at line 27 of file eth_core.c.

References frb_pop(), and memcpy().

Referenced by eth_device_init().

00028 {
00029     struct eth_hdr_s *eth_hdr;
00030     
00031     eth_hdr = (struct eth_hdr_s *)frb_pop(frb, sizeof(struct eth_hdr_s));
00032     memcpy((void *)eth_hdr->mac_dest, mac_dest, NET_LAYER_2_ETH_MAC_LEN);
00033 
00034     if (mac_source != NULL)
00035         memcpy((void *)eth_hdr->mac_source, mac_source, NET_LAYER_2_ETH_MAC_LEN);
00036     else
00037         memcpy((void *)eth_hdr->mac_source, frb->frb_dev->if_layer_2.if_addr, NET_LAYER_2_ETH_MAC_LEN);
00038         
00039     eth_hdr->proto = htons(proto);
00040 
00041     return 0;
00042 }

Here is the call graph for this function:

int eth_header_parse struct frb_s *  frb  ) 
 

Definition at line 44 of file eth_core.c.

References frb_data(), frb_push(), memcmp(), and printk().

Referenced by eth_device_init().

00045 {
00046     struct eth_hdr_s *ethhdr = (struct eth_hdr_s *)frb_data(frb);
00047 #if ETH_CORE_DEBUG
00048     int i;
00049 
00050     u8 *ptr = (u8 *)frb->frb_data;
00051 
00052     for (i = 0; i < 64; i++) {
00053         printk("%02X ", ptr[i]);
00054     }
00055     printk("\n");
00056 
00057 #endif
00058 
00059     if (ntohs(ethhdr->proto) > 1536)
00060         frb->frb_proto_type = ethhdr->proto;
00061     else
00062         frb->frb_proto_type = ETH_P_802_3;
00063     
00064     if (frb->frb_data[0] & 0x01) {
00065         if (!memcmp(frb->frb_data, frb->frb_dev->if_layer_2.if_addr_broadcast, NET_LAYER_2_ETH_MAC_LEN))
00066             frb->frb_dest_type = FRB_DEST_TYPE_BROADCAST;
00067     } else
00068     if (!memcmp(frb->frb_data, frb->frb_dev->if_layer_2.if_addr, NET_LAYER_2_ETH_MAC_LEN))
00069         frb->frb_dest_type = FRB_DEST_TYPE_LOCAL;
00070     else
00071         frb->frb_dest_type = FRB_DEST_TYPE_OTHER;
00072 
00073     frb_push(frb, sizeof(struct eth_hdr_s));
00074 
00075     return 0;
00076 }

Here is the call graph for this function:

int eth_set_broadcast_addr struct adi_netdev_s *  netdev,
u8 *  broadcast_addr
 

Definition at line 88 of file eth_core.c.

References memcpy().

Referenced by eth_device_init().

00089 {
00090     memcpy(netdev->if_layer_2.if_addr_broadcast, broadcast_addr, NET_LAYER_2_ETH_MAC_LEN);
00091 
00092     return 0;
00093 }

Here is the call graph for this function:

int eth_set_mac_addr struct adi_netdev_s *  netdev,
u8 *  mac_addr
 

Definition at line 83 of file eth_core.c.

Referenced by eth_device_init().

00084 {
00085     return 0;
00086 }

int eth_set_mtu struct adi_netdev_s *  netdev,
int  mtu
 

Definition at line 78 of file eth_core.c.

Referenced by eth_device_init().

00079 {
00080     return 0;
00081 }

int net_layer_2_eth_init void   ) 
 

Definition at line 119 of file eth_core.c.

References printk().

Referenced by net_layer_2_init().

00120 {
00121     printk(", eth");
00122     
00123     return 0;
00124 }

Here is the call graph for this function:


Variable Documentation

int eth_device_nr = 0
 

Definition at line 25 of file eth_core.c.

Referenced by eth_device_compose_name().

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix