Main Page | Directories | File List | Globals

core.c

Go to the documentation of this file.
00001 /*
00002  * kernel_net/layer_2/core.c
00003  *
00004  * Copyright (c) 2003-2005 Lukasz Dembinski <dembol@nasa.com.pl>
00005  * All Rights Reserved
00006  * 
00007  * Date:        2005/06
00008  * Author:      Lukasz Dembinski
00009  * Info:        core.c core file
00010  * Contact:     mailto: <dembol@nasa.com.pl>
00011  *
00012  */
00013 
00014 #include <agnix/agnix.h>
00015 #include <agnix/adi/adi.h>
00016 #include <agnix/memory.h>
00017 #include <agnix/net/net.h>
00018 #include <agnix/list.h>
00019 #include <agnix/console.h>
00020 
00021 #define MOD_NAME        "NET: "
00022 
00023 struct list_head        layer_2_pack_list;
00024 spinlock_t              layer_2_pack_list_lock;
00025 
00026 int net_layer_2_add_pack(struct net_layer_2_pack *pack)
00027 {
00028     u32 flags;
00029 
00030     spin_lock_irqsave(&layer_2_pack_list_lock, flags);
00031     list_add(&pack->pack_list, &layer_2_pack_list);
00032     spin_unlock_irqrestore(&layer_2_pack_list_lock, flags);
00033 
00034     return 0;
00035 }
00036 
00037 int net_layer_2_recv_pack(struct frb_s *frb)
00038 {
00039     u32 flags;
00040 //    struct frb_s *frb_clone;
00041     struct list_head *tmp;
00042     struct net_layer_2_pack *pack;
00043 
00044     frb->frb_dev->if_ops->header_parse(frb);
00045     spin_lock_irqsave(&layer_2_pack_list_lock, flags);
00046 
00047     if (!list_empty(&layer_2_pack_list)) {
00048 
00049         list_for_each(tmp, &layer_2_pack_list) {
00050             pack = list_entry(tmp, struct net_layer_2_pack, pack_list);
00051 
00052             if (pack->pack_type != frb->frb_proto_type)
00053                 continue;
00054         
00055 //      frb_clone = frb;
00056 //      if (tmp->next != &layer_2_pack_list) {
00057 //          frb_clone = (struct frb_s *)get_free_pages(0);
00058 //          memcpy((void *)frb_clone, (void *)frb, sizeof(struct frb_s));
00059 //      }
00060 
00061             pack->receiver(frb);
00062         }
00063     }    
00064     
00065     spin_unlock_irqrestore(&layer_2_pack_list_lock, flags);
00066     
00067     return 0;
00068 }
00069 
00070 int net_layer_2_init(void)
00071 {
00072     printk(MOD_NAME "\tLayer 2: core");
00073 
00074     INIT_LIST_HEAD(&layer_2_pack_list);
00075     spin_lock_init(&layer_2_pack_list_lock);
00076 
00077     net_layer_2_eth_init();
00078     net_layer_2_arp_init();
00079 
00080     printk("\n");
00081 
00082     return 0;
00083 }
Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix