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

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

?? hello_plugs.c

?? 一款基于FPGA的對于VGA實(shí)現(xiàn)全彩控制的程序
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):


// 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
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本人妖一区二区| 国产精品福利电影一区二区三区四区| 国产精品欧美经典| 五月婷婷激情综合| 成人黄色国产精品网站大全在线免费观看| 欧美丰满少妇xxxxx高潮对白| 国产精品萝li| 激情综合五月天| 欧美一级一区二区| 亚洲黄色免费网站| 成人激情小说网站| www久久精品| 奇米精品一区二区三区四区| 在线精品亚洲一区二区不卡| 国产精品久久看| 国产成人亚洲精品狼色在线| 日韩视频一区二区三区在线播放 | 精品欧美一区二区三区精品久久| 亚洲精品成人天堂一二三| 国产91在线|亚洲| 精品对白一区国产伦| 日本亚洲电影天堂| 欧美日韩国产精品自在自线| 亚洲六月丁香色婷婷综合久久 | 国产露脸91国语对白| 91精品国产综合久久久久久漫画 | 亚洲男人电影天堂| 从欧美一区二区三区| 久久久久亚洲综合| 极品美女销魂一区二区三区免费| 日韩午夜在线影院| 蜜臀91精品一区二区三区| 欧美剧情片在线观看| 亚洲成av人片在线| 欧美日韩国产天堂| 亚洲地区一二三色| 欧美精品日日鲁夜夜添| 亚洲成人黄色影院| 欧美图区在线视频| 婷婷丁香久久五月婷婷| 欧美放荡的少妇| 日韩黄色免费网站| 日韩美女天天操| 韩国毛片一区二区三区| 久久久蜜臀国产一区二区| 国产高清久久久| 国产欧美一区二区三区沐欲| 粉嫩av一区二区三区粉嫩| 国产精品免费免费| 色综合久久99| 午夜日韩在线观看| 日韩女同互慰一区二区| 韩国在线一区二区| 国产欧美一区二区三区在线老狼| 不卡免费追剧大全电视剧网站| 国产精品网站导航| 91豆麻精品91久久久久久| 亚洲成人免费视频| 精品久久免费看| 亚洲国产激情av| 8x福利精品第一导航| 欧美一区二区久久| 日韩一级完整毛片| 99九九99九九九视频精品| 久久99精品久久久久婷婷| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 国产精品久久久久久久久图文区 | 99re这里只有精品视频首页| 国产一区二区精品久久| 亚欧色一区w666天堂| 日韩亚洲欧美在线观看| 国产一区福利在线| 国产精品麻豆网站| 欧美亚洲日本一区| 精品在线观看视频| 一区视频在线播放| 欧美日韩在线电影| 极品少妇xxxx精品少妇| 国产精品久久影院| 欧美日韩激情一区| 国产一区二区三区四| 中文字幕亚洲一区二区va在线| 色婷婷精品大在线视频| 蜜桃精品在线观看| 国产精品久久久久久久蜜臀| 8x8x8国产精品| 成人福利视频网站| 日日夜夜免费精品视频| 中文字幕不卡在线播放| 欧美性猛交一区二区三区精品| 久久99精品国产麻豆婷婷| 综合av第一页| 日韩午夜激情电影| 一本一本大道香蕉久在线精品| 免费看日韩a级影片| 国产精品久线在线观看| 欧美一区二区三区免费| av色综合久久天堂av综合| 日韩在线一区二区三区| 中文字幕 久热精品 视频在线| 欧美日韩亚洲综合| 大胆欧美人体老妇| 亚洲精品一线二线三线无人区| 国产日韩av一区二区| 91最新地址在线播放| 免费美女久久99| 亚洲男人的天堂在线观看| 欧美一区二区免费视频| 93久久精品日日躁夜夜躁欧美| 老汉av免费一区二区三区| 亚洲精品中文在线观看| 久久久一区二区三区| 欧美日韩精品一区二区天天拍小说| 高清成人在线观看| 久久精品国产精品青草| 亚洲制服丝袜av| 国产精品蜜臀在线观看| www国产精品av| 91精品国产综合久久精品性色| 99精品视频一区| 国产精品99久久久久久久女警 | 精品国产精品一区二区夜夜嗨| 欧美激情在线观看视频免费| 免费亚洲电影在线| 色综合久久精品| 国产三级精品视频| 丁香婷婷综合激情五月色| 色天天综合色天天久久| 精品国产凹凸成av人导航| 免费成人美女在线观看| 五月综合激情日本mⅴ| 国产精品免费av| 久久男人中文字幕资源站| 日韩一本二本av| 欧美一区二区私人影院日本| 欧美体内she精高潮| 色悠悠亚洲一区二区| 成人aa视频在线观看| 国产成人av自拍| 国产成人精品免费在线| 久久99精品国产91久久来源| 日韩制服丝袜先锋影音| 午夜精品一区二区三区三上悠亚| 亚洲三级免费电影| 中文字幕五月欧美| 国产精品黄色在线观看| 国产片一区二区三区| 国产婷婷色一区二区三区四区| 欧美r级在线观看| 欧美大肚乱孕交hd孕妇| 日韩一级欧美一级| 欧美大尺度电影在线| 精品欧美一区二区久久| 欧美精品一区二区三区高清aⅴ | 中文字幕乱码日本亚洲一区二区| 精品国产伦一区二区三区观看体验 | 国产二区国产一区在线观看| 国产精品影视在线观看| 丁香啪啪综合成人亚洲小说 | 亚洲国产综合视频在线观看| 亚洲一二三级电影| 亚洲国产日韩综合久久精品| 亚洲一级二级三级| 日韩av成人高清| 久久国产精品72免费观看| 极品少妇xxxx精品少妇| 国产精品一区二区在线播放 | av一区二区三区黑人| 亚洲精品综合在线| 欧美日韩专区在线| 激情图区综合网| 亚洲色图欧洲色图婷婷| 91麻豆福利精品推荐| 亚洲6080在线| 久久色在线观看| 欧美午夜在线观看| 92国产精品观看| 麻豆久久久久久久| 欧美一区二区啪啪| 日韩一级片在线播放| 26uuu国产电影一区二区| 国产精品午夜电影| 一区二区三区在线观看国产| 亚洲一二三四区不卡| 日本aⅴ亚洲精品中文乱码| 极品尤物av久久免费看| 成人av资源站| 欧美视频一区在线| 精品久久久久香蕉网| 国产精品久久久久久久蜜臀| 亚洲一二三四区| 国产在线一区二区| 91婷婷韩国欧美一区二区| 欧美日韩精品福利| 国产亚洲一本大道中文在线| 亚洲人被黑人高潮完整版| 首页国产丝袜综合| 国产成人av福利| 欧美日韩国产不卡| 久久精品日产第一区二区三区高清版 |