Main Page | Directories | File List | Globals

ip_core.c File Reference

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

Include dependency graph for ip_core.c:

Go to the source code of this file.

Defines

#define MOD_NAME   "NET: "

Functions

int ip_recv (struct frb_s *frb)
int ip_ioctl_set_ifaddr (struct adi_netdev_s *netdev, struct net_addr_s *addr)
int ip_ioctl_set_debug (int enable)
int ip_ioctl_get_debug (void)
int ip_print_stats (void)
int net_layer_3_ip_init (void)

Variables

int ip_debug = 0
net_layer_2_pack ip_pack


Define Documentation

#define MOD_NAME   "NET: "
 

Definition at line 21 of file ip_core.c.


Function Documentation

int ip_ioctl_get_debug void   ) 
 

Definition at line 47 of file ip_core.c.

References ip_debug.

Referenced by agnix_console_ip_debug().

00048 {
00049     return ip_debug;
00050 }

int ip_ioctl_set_debug int  enable  ) 
 

Definition at line 40 of file ip_core.c.

References ip_debug.

Referenced by agnix_console_ip_debug().

00041 {
00042     ip_debug = enable;
00043     
00044     return 0;
00045 }

int ip_ioctl_set_ifaddr struct adi_netdev_s *  netdev,
struct net_addr_s *  addr
 

Definition at line 33 of file ip_core.c.

References memcpy().

Referenced by agnix_console_net_ifconfig().

00034 {
00035     memcpy(&netdev->if_layer_3.if_addr, addr, sizeof(struct net_addr_s));
00036 
00037     return 0;
00038 }

Here is the call graph for this function:

int ip_print_stats void   ) 
 

Definition at line 52 of file ip_core.c.

References printf().

Referenced by agnix_console_ip_stats().

00053 {
00054     printf("\n");
00055     printf("Total IP packets:     %d\n", ip_stats.total_packets);
00056     printf("Bad checksum packets: %d\n", ip_stats.bad_checksum_packets);
00057     
00058     return 0;
00059 }

Here is the call graph for this function:

int ip_recv struct frb_s *  frb  ) 
 

Definition at line 61 of file ip_core.c.

References frb_data(), ip_checksum(), ip_debug, printf(), and printk().

00062 {
00063     struct ip_hdr_s *iphdr = (struct ip_hdr_s *)frb_data(frb);
00064     u16 checksum;
00065     u8 *saddr_ptr = (u8 *)&iphdr->saddr;
00066     u8 *daddr_ptr = (u8 *)&iphdr->daddr;
00067 
00068     if (ip_debug) {
00069         printf("Packet IP recv %d.%d.%d.%d -> %d.%d.%d.%d\n", 
00070         saddr_ptr[0], saddr_ptr[1], saddr_ptr[2], saddr_ptr[3], 
00071         daddr_ptr[0], daddr_ptr[1], daddr_ptr[2], daddr_ptr[3]);
00072     }
00073 
00074     ip_stats.total_packets++;
00075 
00076     checksum = ip_checksum(iphdr);
00077 
00078     if (ip_checksum(iphdr) != 0) {
00079         printk("Packet IP bad checksum\n");
00080         ip_stats.bad_checksum_packets++;
00081     }
00082 
00083     return 0;
00084 }

Here is the call graph for this function:

int net_layer_3_ip_init void   ) 
 

Definition at line 86 of file ip_core.c.

References ip_pack, net_layer_2_add_pack(), and printk().

Referenced by net_layer_3_init().

00087 {
00088     printk(", IPv4");
00089 
00090     net_layer_2_add_pack(&ip_pack);
00091     
00092     return 0;
00093 }

Here is the call graph for this function:


Variable Documentation

int ip_debug = 0
 

Definition at line 24 of file ip_core.c.

Referenced by ip_ioctl_get_debug(), ip_ioctl_set_debug(), and ip_recv().

struct net_layer_2_pack ip_pack
 

Initial value:

 {
    .pack_type          = 0x0008,
    .receiver           = ip_recv,
}

Definition at line 26 of file ip_core.c.

Referenced by net_layer_3_ip_init().

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix