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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? isp.c

?? eCos/RedBoot for勤研ARM AnywhereII(4510) 含全部源代碼
?? C
字號:
//==========================================================================
//
//      tests/isp.c
//
//      Test of PPP and CHAT connection to an ISP
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Portions created by Nick Garnett are
// Copyright (C) 2003 eCosCentric Ltd.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//####BSDCOPYRIGHTBEGIN####
//
// -------------------------------------------
//
// Portions of this software may have been derived from OpenBSD, 
// FreeBSD or other sources, and are covered by the appropriate
// copyright disclaimers included herein.
//
// -------------------------------------------
//
//####BSDCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s):    nickg
// Contributors: gthomas (ping code), nickg
// Date:         2003-06-01
// Purpose:      
// Description:  This test uses CHAT to set up a modem, dial, talk to an ISP
//               and then ping some well known addresses. It then brings the
//               link down.
//              
//
//####DESCRIPTIONEND####
//
//==========================================================================

// PPP test code

#include <network.h>

#include <pkgconf/system.h>
#include <pkgconf/net.h>
#include <pkgconf/ppp.h>

#include <cyg/ppp/ppp.h>

#include <cyg/io/io.h>
#include <cyg/io/serialio.h>

#include <cyg/infra/testcase.h>

//==========================================================================

#include <arpa/inet.h>

// Fill in the blanks if necessary
#ifndef TNR_OFF
# define TNR_OFF()
#endif
#ifndef TNR_ON
# define TNR_ON()
#endif
#ifndef TNR_INIT
# define TNR_INIT()
#endif
#ifndef TNR_PRINT_ACTIVITY
# define TNR_PRINT_ACTIVITY()
#endif

#define NUM_PINGS 16
#define MAX_PACKET 4096
#define MIN_PACKET   64
#define MAX_SEND   4000

#define PACKET_ADD  ((MAX_SEND - MIN_PACKET)/NUM_PINGS)
#define nPACKET_ADD  1 

static unsigned char pkt1[MAX_PACKET], pkt2[MAX_PACKET];

#define UNIQUEID 0x1234

void
pexit(char *s)
{
    CYG_TEST_FAIL_FINISH(s);
}

// Compute INET checksum
int
inet_cksum(u_short *addr, int len)
{
    register int nleft = len;
    register u_short *w = addr;
    register u_short answer;
    register u_int sum = 0;
    u_short odd_byte = 0;

    /*
     *  Our algorithm is simple, using a 32 bit accumulator (sum),
     *  we add sequential 16 bit words to it, and at the end, fold
     *  back all the carry bits from the top 16 bits into the lower
     *  16 bits.
     */
    while( nleft > 1 )  {
        sum += *w++;
        nleft -= 2;
    }

    /* mop up an odd byte, if necessary */
    if( nleft == 1 ) {
        *(u_char *)(&odd_byte) = *(u_char *)w;
        sum += odd_byte;
    }

    /*
     * add back carry outs from top 16 bits to low 16 bits
     */
    sum = (sum >> 16) + (sum & 0x0000ffff); /* add hi 16 to low 16 */
    sum += (sum >> 16);                     /* add carry */
    answer = ~sum;                          /* truncate to 16 bits */
    return (answer);
}

static int
show_icmp(unsigned char *pkt, int len, 
          struct sockaddr_in *from, struct sockaddr_in *to)
{
    cyg_tick_count_t *tp, tv;
    struct ip *ip;
    struct icmp *icmp;
    tv = cyg_current_time();
    ip = (struct ip *)pkt;
    if ((len < sizeof(*ip)) || ip->ip_v != IPVERSION) {
        diag_printf("%s: Short packet or not IP! - Len: %d, Version: %d\n", 
                    inet_ntoa(from->sin_addr), len, ip->ip_v);
        return 0;
    }
    icmp = (struct icmp *)(pkt + sizeof(*ip));
    len -= (sizeof(*ip) + 8);
    tp = (cyg_tick_count_t *)&icmp->icmp_data;
    if (icmp->icmp_type != ICMP_ECHOREPLY) {
        diag_printf("%s: Invalid ICMP - type: %d\n", 
                    inet_ntoa(from->sin_addr), icmp->icmp_type);
        return 0;
    }
    if (icmp->icmp_id != UNIQUEID) {
        diag_printf("%s: ICMP received for wrong id - sent: %x, recvd: %x\n", 
                    inet_ntoa(from->sin_addr), UNIQUEID, icmp->icmp_id);
    }
    diag_printf("%d bytes from %s: ", len, inet_ntoa(from->sin_addr));
    diag_printf("icmp_seq=%d", icmp->icmp_seq);
    diag_printf(", time=%dms\n", (int)(tv - *tp)*10);
    return (from->sin_addr.s_addr == to->sin_addr.s_addr);
}

static void
ping_host(int s, struct sockaddr_in *host)
{
    struct icmp *icmp = (struct icmp *)pkt1;
    int icmp_len = MIN_PACKET;
    int seq, ok_recv, bogus_recv;
    cyg_tick_count_t *tp;
    long *dp;
    struct sockaddr_in from;
    int i, len, fromlen;

    ok_recv = 0;
    bogus_recv = 0;
    diag_printf("PING server %s\n", inet_ntoa(host->sin_addr));
    for (seq = 0;  seq < NUM_PINGS;  seq++, icmp_len += PACKET_ADD ) {
        TNR_ON();
        // Build ICMP packet
        icmp->icmp_type = ICMP_ECHO;
        icmp->icmp_code = 0;
        icmp->icmp_cksum = 0;
        icmp->icmp_seq = seq;
        icmp->icmp_id = 0x1234;
        // Set up ping data
        tp = (cyg_tick_count_t *)&icmp->icmp_data;
        *tp++ = cyg_current_time();
        dp = (long *)tp;
        for (i = sizeof(*tp);  i < icmp_len;  i += sizeof(*dp)) {
            *dp++ = i;
        }
        // Add checksum
        icmp->icmp_cksum = inet_cksum( (u_short *)icmp, icmp_len+8);
        // Send it off
        if (sendto(s, icmp, icmp_len+8, 0, (struct sockaddr *)host, sizeof(*host)) < 0) {
            TNR_OFF();
            perror("sendto");
            continue;
        }
        // Wait for a response
        fromlen = sizeof(from);
        len = recvfrom(s, pkt2, sizeof(pkt2), 0, (struct sockaddr *)&from, &fromlen);
        TNR_OFF();
        if (len < 0) {
            perror("recvfrom");
            icmp_len = MIN_PACKET - PACKET_ADD; // just in case - long routes
        } else {
            if (show_icmp(pkt2, len, &from, host)) {
                ok_recv++;
            } else {
                bogus_recv++;
            }
        }
    }
    TNR_OFF();
    diag_printf("Sent %d packets, received %d OK, %d bad\n", NUM_PINGS, ok_recv, bogus_recv);
}

static void do_ping(char *addr)
{
    struct protoent *p;
    struct timeval tv;
    struct sockaddr_in host;
    int s;

    if ((p = getprotobyname("icmp")) == (struct protoent *)0) {
        pexit("getprotobyname");
        return;
    }
    s = socket(AF_INET, SOCK_RAW, p->p_proto);
    if (s < 0) {
        pexit("socket");
        return;
    }
    tv.tv_sec = 1;
    tv.tv_usec = 0;
    setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
    // Set up host address
    host.sin_family = AF_INET;
    host.sin_len = sizeof(host);
    inet_aton(addr, &host.sin_addr);
    host.sin_port = 0;

    ping_host(s, &host);
    
}

//==========================================================================


#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000)
static char stack[STACK_SIZE];
static cyg_thread thread_data;
static cyg_handle_t thread_handle;

//==========================================================================
/*

Captured session:


AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0                     
OK                                                   
ATD08440416662                                       
CONNECT 42666/ARQ/V90/LAPM/V42BIS                    
anchor-du-10.access.demon.net


login: xxxxxx
Password: yyyyyy
Protocol: ppp
xxxxxx: IP Address: XXX.XXX.XXX.XXX  Running PPP on 1223
No operational problems reported.
Finger status@gate.demon.co.uk for more info - Last change 16:30 Jun 08
HELLO

                                                                                
                                                                                
OK                                                                              
ATH                                                                             
OK                                                                              

*/

static char *script[] =
{
    "ABORT"             ,       "BUSY"                                  ,
    "ABORT"             ,       "NO CARRIER"                            ,
    "ABORT"             ,       "ERROR"                                 ,
    ""                  ,       "ATZ"                                   ,
    "OK"                ,       "AT S7=45 S0=0 L1 V1 X4 &C1 E1 Q0"      ,
    "OK"                ,       "ATD" CYGPKG_PPP_DEFAULT_DIALUP_NUMBER  ,
    "ogin:--ogin:"      ,       CYGPKG_PPP_AUTH_DEFAULT_USER            ,
    "assword:"          ,       CYGPKG_PPP_AUTH_DEFAULT_PASSWD          ,
    "otocol:"           ,       "ppp"                                   ,
    "HELLO"             ,       "\\c"                                   ,
    0
};

//==========================================================================

void
isp_test(cyg_addrword_t p)
{
    CYG_TEST_INIT();

    diag_printf("Start ISP test\n");

    init_all_network_interfaces();

    {
        cyg_ppp_options_t options;
        cyg_ppp_handle_t ppp_handle;

        cyg_ppp_options_init( &options );

//        options.debug = 1;
//        options.kdebugflag = 1;

        options.modem = 1;
        options.script = &script[0];
        
        ppp_handle = cyg_ppp_up( CYGPKG_PPP_TEST_DEVICE, &options );

        CYG_TEST_INFO( "Waiting for PPP to come up");
    
        cyg_ppp_wait_up( ppp_handle );

        CYG_TEST_INFO( "Delaying for a while...");
        
        cyg_thread_delay(10*100);
        
        CYG_TEST_INFO( "Pinging");
        
        do_ping("195.173.57.10");       // anchor-du-10.access.demon.net
        do_ping("194.154.160.254");     // fluffy.ecoscentric.com
        do_ping("66.187.233.205");      // sources.redhat.com
        
        CYG_TEST_INFO( "Bringing PPP down");

        cyg_ppp_down( ppp_handle );
    
        CYG_TEST_INFO( "Waiting for PPP to go down");

        cyg_ppp_wait_down( ppp_handle );
    }
    
    CYG_TEST_PASS_FINISH("ISP test OK");
}

//==========================================================================

void
cyg_start(void)
{
    // Create a main thread, so we can run the scheduler and have time 'pass'
    cyg_thread_create(10,                // Priority - just a number
                      isp_test,          // entry
                      0,                 // entry parameter
                      "ISP test",        // Name
                      &stack[0],         // Stack
                      STACK_SIZE,        // Size
                      &thread_handle,    // Handle
                      &thread_data       // Thread data structure
            );
    cyg_thread_resume(thread_handle);  // Start it
    cyg_scheduler_start();
}

//==========================================================================

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩三级视频在线观看| 国产精品一二三四区| 欧美最新大片在线看| 亚洲小说春色综合另类电影| 在线欧美日韩国产| 天堂久久一区二区三区| 日韩一级片在线观看| 久久精品72免费观看| 国产欧美精品一区| 日本福利一区二区| 香蕉久久夜色精品国产使用方法 | 亚洲一区欧美一区| 88在线观看91蜜桃国自产| 卡一卡二国产精品 | 欧美日韩在线亚洲一区蜜芽| 日日夜夜精品免费视频| 欧美精品一区二区三区高清aⅴ| 国内国产精品久久| 亚洲视频小说图片| 日韩一区二区免费高清| 国产成人av一区| 亚洲午夜久久久久中文字幕久| 欧美不卡激情三级在线观看| eeuss鲁一区二区三区| 亚洲高清视频中文字幕| 久久久久久日产精品| 欧美亚洲丝袜传媒另类| 国产中文字幕一区| 亚洲一二三区在线观看| 久久综合中文字幕| 在线观看国产一区二区| 国产乱码精品1区2区3区| 亚洲精品国产一区二区精华液 | 国产精品麻豆欧美日韩ww| 欧美三级午夜理伦三级中视频| 精品制服美女丁香| 洋洋成人永久网站入口| 久久精品一二三| 欧美日韩日本视频| 成人av在线一区二区三区| 天天色综合成人网| 亚洲色图一区二区三区| 日韩欧美国产不卡| 在线观看三级视频欧美| 丰满岳乱妇一区二区三区| 奇米影视一区二区三区小说| 自拍av一区二区三区| 久久亚洲一区二区三区四区| 精品视频色一区| 99re亚洲国产精品| 国产福利一区在线| 精品视频在线看| 丰满少妇久久久久久久| 久久国产欧美日韩精品| 性欧美疯狂xxxxbbbb| 又紧又大又爽精品一区二区| 国产色产综合色产在线视频| 日韩欧美123| 555www色欧美视频| 欧美亚洲综合在线| 92国产精品观看| 成人亚洲一区二区一| 激情五月婷婷综合| 美女脱光内衣内裤视频久久网站| 亚洲一区在线观看免费 | ㊣最新国产の精品bt伙计久久| 久久先锋资源网| 欧美成人vr18sexvr| 91精品免费在线观看| 欧美精品日韩一本| 欧美三级欧美一级| 欧美性xxxxxx少妇| 欧美综合久久久| 色av综合在线| 在线观看视频一区| 欧美影院一区二区三区| 欧美在线色视频| 欧美午夜影院一区| 欧美三级电影在线看| 欧美影院精品一区| 欧美人牲a欧美精品| 欧美日韩一区高清| 91精品国产麻豆国产自产在线 | 欧美一区欧美二区| 日韩视频在线永久播放| 精品毛片乱码1区2区3区 | 91麻豆精品国产自产在线观看一区| 欧美亚日韩国产aⅴ精品中极品| 欧美亚洲一区三区| 777欧美精品| 欧美精品一区二区三区在线| 亚洲精品一区二区三区香蕉| 亚洲精品一区二区三区福利| 久久精品视频免费观看| 国产精品色呦呦| 一区二区免费在线播放| 日韩成人av影视| 国产一区二区日韩精品| 成人黄色免费短视频| 欧亚洲嫩模精品一区三区| 欧美一区二区三区思思人 | 亚洲视频在线一区观看| 成人黄色软件下载| 在线观看免费亚洲| 欧美成人精品1314www| 中文字幕乱码日本亚洲一区二区| 亚洲日本丝袜连裤袜办公室| 亚洲gay无套男同| 国产一区欧美一区| 91高清在线观看| 日韩色在线观看| 成人欧美一区二区三区在线播放| 香蕉影视欧美成人| 国产不卡在线播放| 欧美中文字幕一区| 久久色视频免费观看| 一区二区三区欧美日韩| 国模套图日韩精品一区二区| 色婷婷精品久久二区二区蜜臀av| 日韩欧美国产一区二区三区 | 亚瑟在线精品视频| 国产成人免费xxxxxxxx| 欧美亚男人的天堂| 国产日韩三级在线| 日韩高清不卡在线| 91热门视频在线观看| 日韩你懂的在线播放| **性色生活片久久毛片| 紧缚捆绑精品一区二区| 欧美影视一区在线| 亚洲国产精品传媒在线观看| 水蜜桃久久夜色精品一区的特点| 国产激情91久久精品导航| 777久久久精品| 伊人夜夜躁av伊人久久| 国产成人综合网| 日韩精品中文字幕一区二区三区| 一区二区三区四区高清精品免费观看 | 99国产精品99久久久久久| 久久综合九色综合欧美就去吻| 亚洲国产wwwccc36天堂| 成人动漫在线一区| 久久精品男人天堂av| 全部av―极品视觉盛宴亚洲| 欧美主播一区二区三区| 日韩毛片精品高清免费| 丰满亚洲少妇av| 久久蜜桃一区二区| 韩国视频一区二区| 欧美大片顶级少妇| 免费成人在线视频观看| 在线成人免费观看| 香蕉加勒比综合久久| 欧美系列亚洲系列| 亚洲一区二区三区中文字幕在线| k8久久久一区二区三区 | 精品99一区二区| 一区二区三区日韩欧美| 91福利在线播放| 亚洲国产精品黑人久久久| 美腿丝袜亚洲色图| 欧美va在线播放| 天堂va蜜桃一区二区三区漫画版| a在线播放不卡| 欧美二区乱c少妇| 日韩成人一级大片| 欧美性三三影院| 亚洲精品日日夜夜| 在线观看三级视频欧美| 亚洲图片激情小说| 成人av先锋影音| 久久久久久免费网| 国产精品一区在线| 欧美精品一区二区三区高清aⅴ| 激情综合一区二区三区| 91精品国产综合久久精品| 亚洲国产成人高清精品| 不卡的看片网站| 国产精品女上位| 国产一区二三区| 精品国产99国产精品| 国产成人av电影在线| 久久久久久久免费视频了| 国内久久婷婷综合| 国产精品二三区| 成人精品视频.| 欧美国产国产综合| 喷水一区二区三区| 久久综合成人精品亚洲另类欧美| 青青草国产精品亚洲专区无| 在线播放亚洲一区| 国产一区二区久久| 国产清纯在线一区二区www| 国产精品1区2区3区在线观看| 久久综合给合久久狠狠狠97色69| 91在线码无精品| 亚洲精品久久嫩草网站秘色| 欧美色国产精品| 国产成人久久精品77777最新版本| 久久久久国色av免费看影院|