91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 55KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-13
  • 語言: 其他
  • 標(biāo)簽: OPNET??

資源簡介

使用opnet仿真軟件仿真AODV路由,對于初學(xué)者能起到幫助作用

資源截圖

代碼片段和文件信息

/***************************************************************************
??????????????????????????aodv_dev.c??-??description
?????????????????????????????-------------------
????begin????????????????:?Thu?Aug?7?2003
????copyright????????????:?(C)?2003?by?Luke?Klein-Berndt
????email????????????????:?kleinb@nist.gov
?***************************************************************************/

#include?“aodv_dev.h“

//extern?char?*g_aodv_dev;
extern?char?g_aodv_dev[8];
extern?aodv_route?*g_my_route;
extern?u_int32_t?g_my_ip;

aodv_dev?*aodv_dev_list;

aodv_dev?*create_aodv_dev(struct?net_device?*dev?struct?in_ifaddr?*ifa)
{
????aodv_dev?*new_dev;
????aodv_route?*tmp_route;

????tmp_route?=?create_aodv_route(ifa->ifa_address);

????tmp_route->ip?=?ifa->ifa_address;
????//tmp_route->netmask?=?calculate_netmask(0);?//ifa->ifa_mask;
????tmp_route->self_route?=?1;
????tmp_route->seq?=?1;
????tmp_route->old_seq?=?0;
????tmp_route->rreq_id?=?1;
????tmp_route->metric?=?0;
????tmp_route->next_hop?=?tmp_route->ip;
????tmp_route->lifetime?=?-1;
????tmp_route->route_valid?=?1;
????tmp_route->route_seq_valid?=?1;
????tmp_route->dev?=?dev;


????if?((new_dev?=?(aodv_dev?*)?kmalloc(sizeof(aodv_dev)?GFP_ATOMIC))?==?NULL)
????{
????????/*?Couldn‘t?create?a?new?entry?in?the?routing?table?*/
????????printk(KERN_WARNING?“AODV:?Not?enough?memory?to?create?Route?Table?Entry\n“);
????????return?NULL;
????}


????new_dev->ip?=?tmp_route->ip;
????new_dev->netmask?=?ifa->ifa_mask;
????new_dev->route_entry?=?tmp_route;
????new_dev->dev?=?dev;
????new_dev->next=NULL;
????

????g_my_route?=?tmp_route;
????g_my_ip?=?g_my_route->ip;

????insert_kernel_route_entry(tmp_route->ip?tmp_route->next_hop?tmp_route->netmask?dev->name);


????return?new_dev;

}

int?insert_aodv_dev(struct?net_device?*dev)
{
????aodv_dev?*new_dev;
????int?success=0?error=0;
????struct?in_ifaddr?*ifa;
????struct?in_device?*in_dev;
????char?netmask[16];


????read_lock(&in_dev->lock);

????if?((in_dev=__in_dev_get(dev))?==?NULL)
{
return?0;
}

????read_lock(&in_dev->lock);
????for_primary_ifa(in_dev)
{
????????if?((strcmp(g_aodv_dev““)!=0)?&&?(strncmp(dev->name?g_aodv_dev?IFNAMSIZ)?==?0))
????????{

?????????? if?(ifa==NULL)
???????????{
??????????? return?success;
????????????}

????????????new_dev?=?create_aodv_dev(dev?ifa);
????????????strcpy(netmask?inet_ntoa(new_dev->netmask?&?new_dev->ip));
????????????printk(KERN_INFO?“INTERFACE?LIST:?Adding?interface:?%s??IP:?%s?Subnet:?%s\n“?dev->name?inet_ntoa(ifa->ifa_address)?netmask);




????????????strncpy(new_dev->name?dev->name?IFNAMSIZ);

????????????new_dev->next?=?aodv_dev_list;
????????????aodv_dev_list?=?new_dev;
????????????error?=?sock_create(PF_INET?SOCK_DGRAM?0?&(new_dev->sock));
????????????if?(error?????????????{
????????????????kfree(new_dev);
????????????????read_unlock(&in_dev->lock);
????????????????printk(KERN_ERR?“Error?during?creation?of?socket;?terminating?%d\n“?error);
????????????????return?err

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

-----------?---------??----------?-----??----

???????????????158842????????????????????51


評論

共有 條評論