亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? hello_plugs.c

?? 很多儀器都輸出同步時鐘
?? C
?? 第 1 頁 / 共 2 頁
字號:


// ex:set tabstop=4:
// +--------------------
// | Includes
// |

#include "excalibur.h"
#include "hello_plugs_menu.h"
#include "plugs.h"


#if __nios16__
	#define SMALL 1
#endif


// Set __adapter__ to the current design...

#include "plugs_example_designs.h"


// +--------------------
// | Types

enum
	{
	k_menu_settings = 1,
	k_menu_actions,		// ping & nslookup
	};

// +---------------------------------
// | Global State
// |
// | (If you must have globals, put them
// | in one struct for tidiness! And name
// | the one instance "g".)

typedef struct
	{
	ns_plugs_persistent_network_settings pns;

	int arp_scan_replies[256];	// matrix of who has responded

	int sniff_pause;	// if set, prints dots instead of packets
	int sniff_count;	// total packets sniffed in session
	} ns_globals;

static ns_globals g; // = {0};

// +----------------------------------------
// | Local Prototypes
// |

static int r_reset_settings(int x);
static int r_reinitialize(int x);
static int show_abbreviated_settings(int x);


// +----------------------------------------
// | Initialization and Utilities
// |


// +----------------------------------------
// | r_get_settings_from_flash
// |
// | If there's flash memory, get the settings from
// | the conventional location in flash. If the
// | index looks crazy, or there's no flash, then
// | reset the settings to our default values.
// |

void r_get_settings_from_flash(void)
	{
	int i;

#ifdef nasys_main_flash
	g.pns = *nasys_plugs_persistent_network_settings;
	if(g.pns.signature != 0x00005afe)
		r_reset_settings(0);
#else
	r_reset_settings(0);
#endif
	}


int r_save_settings(int x)
	{
#ifdef nasys_main_flash
	printf("erasing flash\n");
	nr_flash_erase_sector((void *)-1,(void *)nasys_plugs_persistent_network_settings);

	printf("writing flash at 0x%08x\n",nasys_plugs_persistent_network_settings);
    g.pns.signature = 0x00005afe;

	nr_flash_write_buffer((void *)-1,(void *)nasys_plugs_persistent_network_settings,(void *)&g.pns,sizeof(g.pns));
#endif
	}


int r_set_settings(void)
	{
	int result;


	nr_plugs_terminate();

	result = nr_plugs_initialize(0, &g.pns.settings,
			__adapter__,
			__adapter_irq__,
			__adapter_struct_addr__);

	if(result < 0)
        goto go_home;

    // after initializing, pull the settings back into our globals
    result = nr_plugs_get_settings(0,&g.pns.settings);
    if(result)
        goto go_home;

go_home:
    if(result < 0)
        nr_plugs_print_error_message("[r_set_settings]",result);

	return result;
	}


void r_initialize(void)
	{
	nr_zerorange((char *)(&g),sizeof(g));
	r_get_settings_from_flash();
	r_set_settings(); // initializes plugs, too
	}


// ++=================================================
// || Network Settings Menu Procs
// ||

// Routines


static int show_ip_address(ns_plugs_network_settings *ns)
    {
	printf("            ip address: ");
	nr_plugs_print_ip_address_decimal(ns->ip_address);

    if(ns->flags & ne_plugs_flag_dhcp)
        printf("        (obtained via dhcp)");

	printf("\n");
    }

static int show_settings(int x)
	{
#if SMALL
	return show_abbreviated_settings(x);
#else
    ns_plugs_network_settings ns;
    nr_plugs_get_settings(0,&ns);  // show the settings plugs library reports, regardless what WE set

	printf("\n Network Settings \n\n");
	printf("      ethernet address: ");
	nr_plugs_print_ethernet_address(&ns.ethernet_address);
	printf("\n");

    show_ip_address(&ns);

	printf(" nameserver ip address: ");
	nr_plugs_print_ip_address_decimal(ns.nameserver_ip_address);
	printf("\n");

	printf("           subnet mask: ");
	nr_plugs_print_ip_address_decimal(ns.subnet_mask);
	printf("\n");

	printf("    gateway ip address: ");
	nr_plugs_print_ip_address_decimal(ns.gateway_ip_address);
	printf("\n");

	printf("\n");
#endif SMALL
	}

static int show_abbreviated_settings(int x)
	{
    ns_plugs_network_settings ns;

    nr_plugs_get_settings(0,&ns);  // show the settings plugs library reports, regardless what WE set

    show_ip_address(&ns);
	printf("\n");
	}

static int input_ip_address(char *prompt, net_32 *ip_inout)
	{
	int result;
	char s[64];

	nr_plugs_ip_to_string(*ip_inout,s);
	result = r_input_string(prompt,0,s);
	nr_plugs_string_to_ip(s,ip_inout);

	return result;
	}

static int r_input_long(char *prompt, long *x_inout)
	{
	int result;
	char s[64];

	nr_plugs_long_to_string(*x_inout,s);
	result = r_input_string(prompt,0,s);
	*x_inout = nr_plugs_string_to_long(s);

	return result;
	}

static int r_edit_settings(int x)
	{
	char s[64];
	ns_plugs_network_settings *settings;
    int result;

	settings = &g.pns.settings;

	nr_plugs_ethernet_to_string(&settings->ethernet_address,s);
	result = r_input_string("      ethernet address",0,s);
    if(result < 0)
        goto go_home;

	nr_plugs_string_to_ethernet(s,&settings->ethernet_address);

    // |
    // | use dhcp [y/n]
    // |
        {
        int dhcp_flag = settings->flags & ne_plugs_flag_dhcp;
        s[0] = dhcp_flag ? 'Y' : 'N';
        s[1] = 0;

ask_about_dhcp:
        result = r_input_string("              use dhcp",0,s);
        if(result < 0)
            goto go_home;

        if(s[0] == 'Y' || s[0] == 'y')
            settings->flags |= ne_plugs_flag_dhcp;
        else if(s[0] == 'N' || s[0] == 'n')
            settings->flags &= ~ne_plugs_flag_dhcp;
        else
            goto ask_about_dhcp;
        }

    // |
    // | no dhcp? do it the hard way
    // |
    if(!(settings->flags & ne_plugs_flag_dhcp))
        {
	    result = input_ip_address("            ip address",&settings->ip_address);
        if(result < 0)
            goto go_home;

	    result = input_ip_address(" nameserver ip address",&settings->nameserver_ip_address);
        if(result < 0)
            goto go_home;

	    result = input_ip_address("           subnet mask",&settings->subnet_mask);
        if(result < 0)
            goto go_home;

	    result = input_ip_address("    gateway ip address",&settings->gateway_ip_address);
        if(result < 0)
            goto go_home;
        }

	printf("\n");
go_home:
    if(result >= 0)
	    r_set_settings();
    
    return result;
	}

static int r_reset_settings(int x)
	{
	ns_plugs_network_settings settings = {0,0,0,0,0,0,0};

	settings.ethernet_address.u32=0x11121314;
	settings.ethernet_address.l16=0x1516 + nr_timer_milliseconds();
	settings.nameserver_ip_address = nm_ip2n(10,0,0,1);
	settings.subnet_mask = nm_ip2n(255,255,255,0);
	settings.gateway_ip_address = nm_ip2n(10,0,0,255);

    // dhcp on first setting. It's good.

    settings.flags = ne_plugs_flag_dhcp;
	settings.ip_address = nm_ip2n(10,0,0,51);
	g.pns.settings = settings;

    r_reinitialize(0);

	return 0;
	}

static int r_reinitialize(int x)
	{
    printf("Reinitializing...\n");
	
	r_set_settings();

	return 0;
	}

// ++=================================================
// || Network Action Menu Items
// ||

#if !SMALL
// +-----------------------------------------------------
// | Ping Proc and Pinger

// Utility to do unaligned long-int read from packet
unsigned long get_bytes_32(void *address)
	{
	unsigned char *w = address;
	return ((long)w[0] << 24) + ((long)w[1] << 16) + ((long)w[2] << 8) + w[3];
	}
// Utility to do unaligned long-int write to packet
void put_bytes_32(void *address,unsigned long x)
	{
	unsigned char *w = address;
	w[0] = x >> 24;
	w[1] = x >> 16;
	w[2] = x >> 8;
	w[3] = x;
	}

// +----------------------------------
// | ping_proc -- gets called for icmp packets
// | from the ip address being pinged.

int ping_proc(int plug_handle,
		void *context,
		ns_plugs_packet *p,
		void *payload,
		int payload_length)
	{
	ns_plugs_icmp_packet *icmpp = payload;
	ns_plugs_ip_packet *ipp = p[ne_plugs_ip].header;
	long time;

	// |
	// | We don't expect them to be pinging us
	// | back or anything, and this plug will
	// | filter for only the remote host
	// | we're pinging, but if they do send
	// | a ping-request, we'll print a message
	// | mentioning it.
	// |
	// | We mostly expect the first case: ping reply to our ping.
	// |

	if(icmpp->type == ne_plugs_icmp_ping_reply)
		{
		time = get_bytes_32(icmpp->payload);
		time = nr_timer_milliseconds() - time;

		printf(" [ping_proc] got ping reply from ");
		nr_plugs_print_ip_address(ipp->source_ip_address);
		printf(" (%d msec)\n",time);
		}
	else if(icmpp->type == ne_plugs_icmp_ping_request)
		{
		printf("ping_proc: got ping request from ");
		nr_plugs_print_ip_address(ipp->source_ip_address);
		printf("!\n");
		}
	else
		printf("ping_proc: got icmp type %d\n",icmpp->type);
	}

#define k_ping_count 4

int r_ping_host(int x) // both PING menu items come here, debug with x=1.
	{
	int ping_plug;
	static char *default_host = "www.altera.com";
	char host[64];
	char *hostp;
	net_32 ip;
	int result;
	char data[64];
	ns_plugs_icmp_packet *ping_request = (ns_plugs_icmp_packet *)data;
				// overlay it on data, for nonzero payload
	int len;
	int i;

	host[0] = 0;

	// x = 1 means have debuggin turned on
	x = x ? (ne_plugs_flag_debug_rx | ne_plugs_flag_debug_tx) : 0;

	while(1)
		{
		printf("\n\n");
		result = r_input_string("  Internet host to ping by name (<ESC> to finish)",
				default_host,host);
		if(result < 0)	
			break;

		// Allocate the plug of icmp type

		result = nr_plugs_create(&ping_plug,
			ne_plugs_icmp,
			0,	// port number, does not matter here
			ping_proc,
			0,
			x);	// flags set depending on menu choice

		if(result)
			{
			printf(" Could not create ping plugs.\n");
			nr_plugs_print_error_message("[ping test]",result);
			continue;
			}

		// |
		// | First, see if, perchance, it was a
		// | dot-separated numerical string
		// |

		if(host[0] >= '0' && host[0] <= '9')
			{
			nr_plugs_string_to_ip(host,&ip);
			ip = nr_n2h32(ip);
			hostp = 0;
			}
		else
			{
			ip = 0;
			hostp = host;
			}

		// Connect to remote host by name

		result = nr_plugs_connect(ping_plug,hostp,ip,0);	// talk to remote host

		if(result)
			{
			printf(" Lookup failure on %s.\n",host);
			nr_plugs_print_error_message("[ping test]",result);

			// Delete the plug, since we can't connect, and we'll allocate again
			nr_plugs_destroy(ping_plug);

			continue;
			}
		printf("Connected!\n\n");


		// | Construct the ping request

		ping_request->type = ne_plugs_icmp_ping_request;
		ping_request->code = 0;

		ping_request->payload[0] = 0;
		ping_request->payload[1] = 3;
		ping_request->payload[2] = 4;
		ping_request->payload[3] = 8;

		// "length" is packet + data

		len = sizeof(ns_plugs_icmp_packet) + 4;
		for(i = 0; i < k_ping_count; i++)
			{
			printf("Sending ping %d of %d.\n",i+1,k_ping_count);

			// | Pass the time as payload
			put_bytes_32(ping_request->payload,nr_timer_milliseconds());

			nr_plugs_send(ping_plug,(void *)data,len,0);

			// Wait 1 second, pumping the ether all the time
				{
				long t0 = nr_timer_milliseconds();
				while(nr_timer_milliseconds() - t0 < 1000)
					nr_plugs_idle();
				}
			}

		// All done pinging, delete the plug

		result = nr_plugs_destroy(ping_plug);
		}
	}


// +--------------------------------------------------
// | DNS lookup routine
// |

int r_dns_lookup(int x)
	{
	static char *default_host = "www.altera.com";
	char host[64];
	net_32 ip;
	int result;

	host[0] = 0;

	printf("\nEnter host names to look up, <ESC> when finished.\n\n");

	while(1)
		{
		printf("\n\n");
		result = r_input_string("  Internet host to look up by name",default_host,host);
		if(result < 0)	
			break;

		result = nr_plugs_name_to_ip(host,&ip);

		if(result)

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费成人性网站| 国产精品视频线看| 日韩精品欧美精品| 777久久久精品| 五月综合激情网| 日韩欧美亚洲一区二区| 美女www一区二区| 久久色在线视频| 成人精品电影在线观看| 亚洲精品一二三| 7777精品伊人久久久大香线蕉完整版| 美女视频一区二区三区| 久久精品一级爱片| 91浏览器打开| 蜜桃视频在线观看一区| 久久久亚洲精华液精华液精华液| 国产精品一品二品| 专区另类欧美日韩| 337p亚洲精品色噜噜| 精品一区二区久久| 亚洲同性gay激情无套| 欧美欧美欧美欧美首页| 捆绑紧缚一区二区三区视频| 国产亚洲精品福利| 欧美午夜精品一区二区蜜桃| 另类的小说在线视频另类成人小视频在线| 国产婷婷色一区二区三区 | 国产精品三级电影| 亚洲国产高清aⅴ视频| 欧美性高清videossexo| 久久99精品国产91久久来源| 最新国产精品久久精品| 欧美久久高跟鞋激| 成人av午夜电影| 日本系列欧美系列| 亚洲乱码一区二区三区在线观看| 日韩午夜av电影| 欧美中文字幕一区二区三区亚洲| 国内成+人亚洲+欧美+综合在线| 一区二区三区在线视频免费观看| 精品国产乱码久久久久久闺蜜| 91豆麻精品91久久久久久| 国产一区二区三区电影在线观看| 亚洲黄色片在线观看| 久久久久97国产精华液好用吗| 欧美色视频一区| 成人黄色777网| 久久99国产精品免费网站| 依依成人综合视频| 国产精品嫩草久久久久| 精品国产免费人成电影在线观看四季| 91久久精品日日躁夜夜躁欧美| 国产成人一区在线| 日韩avvvv在线播放| 亚洲一区二区3| 亚洲同性同志一二三专区| 国产午夜久久久久| 精品欧美一区二区三区精品久久 | 91福利视频网站| 成年人国产精品| 国产**成人网毛片九色| 久久成人免费网站| 奇米影视7777精品一区二区| 亚洲v精品v日韩v欧美v专区| 亚洲精品日日夜夜| 亚洲女与黑人做爰| 亚洲图片欧美激情| 中文字幕亚洲电影| 国产精品美日韩| 国产午夜一区二区三区| 久久久美女毛片| 精品国产乱码久久久久久牛牛 | 久久影音资源网| 日韩免费观看高清完整版 | 日本久久精品电影| 色诱视频网站一区| 91黄色在线观看| 在线一区二区观看| 欧洲人成人精品| 在线观看国产91| 欧美日韩久久久一区| 欧美午夜精品久久久久久超碰| 国产精品区一区二区三| 中文字幕一区在线观看| 中文字幕中文字幕在线一区| 国产精品国产三级国产三级人妇 | 精品国产91久久久久久久妲己| 欧美大片一区二区| 久久精品一区二区三区不卡牛牛| 国产丝袜在线精品| 18成人在线视频| 夜夜操天天操亚洲| 日本美女视频一区二区| 国产精品一区二区三区乱码| 99视频在线精品| 91传媒视频在线播放| 7777精品久久久大香线蕉| 精品国产乱码91久久久久久网站| 国产精品婷婷午夜在线观看| 自拍偷自拍亚洲精品播放| 亚洲一区二区在线观看视频| 毛片av一区二区| 国产白丝网站精品污在线入口| av一区二区三区四区| 欧美日韩视频在线观看一区二区三区 | 综合久久国产九一剧情麻豆| 亚洲国产日日夜夜| 久久国产精品第一页| 丁香激情综合五月| 欧美日韩一区二区不卡| 久久久久久免费网| 一区二区日韩av| 国产剧情一区在线| 在线观看av一区二区| 精品国产乱码久久久久久1区2区| 国产精品电影一区二区| 婷婷国产在线综合| 成人免费高清在线| 欧美福利视频导航| 中文字幕不卡在线观看| 图片区小说区国产精品视频| 国产剧情在线观看一区二区| 欧美专区日韩专区| 国产日产欧美一区| 亚洲午夜精品在线| av欧美精品.com| 日韩视频免费观看高清完整版| 国产精品成人一区二区艾草| 日韩高清一级片| 91免费版在线| 久久久久久久久久久久电影| 亚洲制服丝袜av| www.欧美色图| 亚洲精品一区二区精华| 亚洲电影中文字幕在线观看| 大美女一区二区三区| 欧美老人xxxx18| 亚洲精品亚洲人成人网在线播放| 国产精品一区免费在线观看| 欧美女孩性生活视频| 亚洲黄一区二区三区| 成人晚上爱看视频| 国产午夜精品久久| 狂野欧美性猛交blacked| 欧美日韩黄色一区二区| 亚洲另类色综合网站| 成人污视频在线观看| 久久精品夜色噜噜亚洲a∨| 日韩avvvv在线播放| 欧美日韩国产乱码电影| 亚洲综合在线免费观看| 91视频在线观看| 久久久亚洲综合| 国产一区视频导航| 久久久天堂av| 国产一区二区三区四| 日韩免费看的电影| 久久狠狠亚洲综合| 91精品国产品国语在线不卡 | 一区二区高清免费观看影视大全| www.色精品| 中文字幕一区免费在线观看| 成人av一区二区三区| 中文字幕不卡在线观看| 成人午夜电影久久影院| 国产精品乱码久久久久久| 成人黄页在线观看| 中文字幕日韩一区| aaa欧美大片| 一区二区三区不卡视频在线观看| 日本大香伊一区二区三区| 亚洲第一二三四区| 这里只有精品视频在线观看| 美女视频黄免费的久久| 精品少妇一区二区三区在线播放| 久久99久久精品欧美| 国产午夜亚洲精品不卡| av激情成人网| 亚洲一区在线观看免费| 欧美日韩免费视频| 日本欧美大码aⅴ在线播放| 日韩欧美色电影| 国产精品一二三| 亚洲人成网站精品片在线观看| 欧美系列在线观看| 日本美女视频一区二区| 久久香蕉国产线看观看99| 成人综合激情网| 国产精品不卡一区二区三区| 欧美性淫爽ww久久久久无| 日韩精品1区2区3区| 久久久91精品国产一区二区三区| 成人影视亚洲图片在线| 亚洲狼人国产精品| 日韩一区二区精品在线观看| 国产suv一区二区三区88区| 一区二区三区中文字幕精品精品| 91精品国产综合久久国产大片 | 亚洲精品视频一区二区| 欧美一区二区三区视频在线观看|