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

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

?? ping.c

?? 一個簡單的ISOS模塊代碼。A simple ISOS module code
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* ############################################################################ (c) Copyright Virata Limited 2001## Virata Limited Confidential and Proprietary## The following software source code ("Software") is strictly confidential and# is proprietary to Virata Limited ("Virata").  It may only be read, used,# copied, adapted, modified or otherwise dealt with by you if you have# entered into a confidentiality agreement with Virata and then subject to the# terms of that confidentiality agreement and any other applicable agreement# between you and Virata.  If you are in any doubt as to whether you are# entitled to access, read, use, copy, adapt, modify or otherwise deal with# the Software or whether you are entitled to disclose the Software to any# other person you should contact Virata.  If you have not entered into a# confidentiality agreement with Virata granting access to this Software you# should forthwith return all media, copies and printed listings containing# the Software to Virata.## Virata reserves the right to take legal action against you should you breach# the above provisions.## If you are unsure, or to report violations, please contact# support@virata.com# ##########################################################################*//* * ISOS Ping - very simple ping support * * Ideas for extensions: *     Specify IP address in format of your choice (e.g. as wrapper for *         do_ping), not just as const char * *     Add an argument to send up to N pings, rather than default constant *     Add an argument to configure timeout (max length of time to *         wait for a reply), rather than default constant *     More advanced error reporting (i.e. report wider range of errors) *     Verbose output *     Support more ICMP options; flood pings *     Ping by hostname, not just by IP address *     ...and so on. */#include <atypes.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <messages.h>#include <errno.h>#include <net/if.h>#include <netinet/in.h>#include <netinet/ip_icmp.h>#include <netinet/icmp6.h>#include <sys/socket.h>#include <arpa/inet.h>#include <netdb.h>#include <ip.h>#include "ping.h"#if ATIC_SUPPORT_IPV6#define PING_SUPPORT_IPV6#else#undef PING_SUPPORT_IPV6#endif/* Length of the message buffers */#define PING_MSG_BUFFER_LEN     1500/* Macro to output string messages to user */#define PRINTF(x...) \    do {                            \        foreground_output_begin();  \        fprintf(stdout, "%C: " x);  \        foreground_output_end();    \    } while (0)static int ping_prepare_packet(int family, int fd, char *p_buf,                               int *p_buf_len);/* * ping_message_handler() is used by the socket library to manage * all non-socket-related messages received * As the only messages are ping requests or tell messages we just * reply to the message with an error. The sender can then retry  * if they want */static void ping_message_handler(ATMOS_MESSAGE *msg){    if (!(msg->code & MSG_REPLY_BIT))    {        msg->errno = EINTR;        sendreply(msg);    }}intmain(void){    /* Register ourself with the console */    console_register_process(atmos_pcb_current_get_name(), FALSE);    /*     * Since ping uses the socket library, it must also register     * a handler function for non-socket messages such as new tell messages or     * ping request messages     */    socket_register_message_handler(&ping_message_handler);    while (TRUE) /* Forever loop */    {        ATMOS_MESSAGE *msg = awaitmessage();        switch (msg->code)        {            case MSG_N_TELL:            {                MSG_D_TELL(data, msg);                do_ping(data->cmd);                sendreply(msg);                break;            }            case MSG_N_PING:            {                MSG_D_PING(data, msg);                msg->errno = do_ping_v4_v6(data->dest_addr, data->ifname);                sendreply(msg);                break;            }            default:            {                PRINTF("Unhandled message code %0x\n", msg->code);                if (!(msg->code & MSG_REPLY_BIT))                {                    sendreply(msg);                }            }        } /* end switch */        } /* end forever loop */} /* main *//* do_ping_v4_v6 -- *     simple 'ping' algorithm implmentation for IPv4 and IPv6 * * PARAMETERS: *     dest   - destination IP (v4 or v6) address in string notation *     ifname - outgoing interface name *              (for IPv6 link-local destination) * * RETURNS: *     error code  */intdo_ping_v4_v6(const char *dest, const char *ifname){    /* Destination address storage */    struct sockaddr_storage to;        /* String with address */    /* Assume INET6_ADDRSTRLEN > INET_ADDRSTRLEN */    char    to_str[INET6_ADDRSTRLEN];    int     err = ESUCCESS;              /* Error code */    int     family = AF_INET;            /* Protocol/address family */    int     protocol;                    /* Raw socket protocol */    int     status;                      /* Socket API call return code */    int     fd;                          /* Socket */    int     total = PING_MSG_BUFFER_LEN; /* Transmit buffer length */    char   *pkt;                         /* Buffer for transmit */        struct timeval  timeout;    /* Ping roundtrip timeout */    int             attempt;    /* Number of current attempt */    /* Preset destination address storage by zeros */    memset(&to, 0, sizeof(to));    /* Try to convert destination address in IPv4 */    if (inet_pton(AF_INET, dest,                  &(((struct sockaddr_in *)&to)->sin_addr)) == 1)    {        ((struct sockaddr *)&to)->sa_family = AF_INET;    }#ifdef PING_SUPPORT_IPV6    /* Try to convert destination address in IPv6 */    else if (inet_pton(AF_INET6, dest,                       &(((struct sockaddr_in6 *)&to)->sin6_addr)) == 1)    {        ((struct sockaddr *)&to)->sa_family = AF_INET6;    }#endif        else    {#ifdef DNS_CLIENT        struct hostent *hptr;        int             error_num;        int             flags = 0;#ifdef PING_SUPPORT_IPV6        family = AF_INET6;        flags = AI_DEFAULT;#endif        hptr = getipnodebyname(dest, family, flags, &error_num);        if ((hptr != NULL) && (hptr->h_addr_list != NULL) &&            (hptr->h_addr_list[0] != NULL))        {            if ((hptr->h_addrtype == AF_INET6) &&                (IN6_IS_ADDR_V4MAPPED(hptr->h_addr_list[0])))            {                ((struct sockaddr *)&to)->sa_family = AF_INET;                MAKE_INADDR_BY_IN6ADDR_V4(hptr->h_addr_list[0],                     &((struct sockaddr_in *)&to)->sin_addr);            }            else            {                /* Copy type of address */                ((struct sockaddr *)&to)->sa_family = hptr->h_addrtype;                /* Copy address */                memcpy((hptr->h_addrtype == AF_INET) ?                          (void *)&((struct sockaddr_in *)&to)->sin_addr :                          (void *)&((struct sockaddr_in6 *)&to)->sin6_addr,                       hptr->h_addr_list[0], hptr->h_length);            }            /* Free host entry structure */                            freehostent(hptr);        }        else#endif        {#ifdef DNS_CLIENT            if (hptr != NULL)            {                /* Free host entry structure */                freehostent(hptr);            }#endif            PRINTF("Invalid IP address specified.\n");            return EINVAL;        }    }       /* Get address family and related ICMP protocol number */    family = ((struct sockaddr *)&to)->sa_family;    protocol = (family == AF_INET) ? IPPROTO_ICMP :               (family == AF_INET6) ? IPPROTO_ICMPV6 :               (err = EINVAL);    if (err != 0)    {        PRINTF("Unknown address family %u.\n", family);        return err;    }#ifdef PING_SUPPORT_IPV6    /*      * For IPv6 link-local destination address additional      * parameter is necessary - outgoing interface name     */    if ((family == AF_INET6) &&        IN6_IS_ADDR_LINKLOCAL(&(((struct sockaddr_in6 *)&to)->sin6_addr)))    {        if (ifname == NULL)        {            PRINTF("Outgoing interface must be specified for IPv6 "                   "link-local destination.\n");            return EINVAL;                    }        else if ((((struct sockaddr_in6 *)&to)->sin6_scope_id =                     if_nametoindex(ifname)) == 0)        {            PRINTF("Unknown interface name '%s'.\n", ifname);            return EINVAL;                    }            }#else    UNUSED(ifname);#endif        /* Convert address from binary to string format */    if (inet_ntop(family,                  (family == AF_INET)                  ? (const void *)(&(((struct sockaddr_in *)&to)->sin_addr))                  : (const void *)(&(((struct sockaddr_in6 *)&to)->sin6_addr)),                  to_str, sizeof(to_str)) == NULL)    {        PRINTF("Could not convert source address.\n");        return -1;    }    /* Get a Raw socket for the ICMP protocol */    fd = socket(family, SOCK_RAW, protocol);    if (fd < 0)    {        PRINTF("Unable to create ICMP socket.\n");        return EINVAL;    }    /* It's better to allocate memory dynamic */    pkt = malloc(PING_MSG_BUFFER_LEN);    if (pkt == NULL)    {        PRINTF("Memory allocation failure\n");        return ENOMEM;    }        /* Prepare ICMP packet */    err = ping_prepare_packet(family, fd, pkt, &total);    if (err != 0)    {        free(pkt);        PRINTF("Unable to create packet.\n");        return err;    }    PRINTF("PING %s: %d data bytes\n", to_str, PING_EXTRA_DATA_LEN);    /*      * Change symbol DEFAULT_NUM_PING_ATTEMPTS or parameterise     * the function to increase the number of ping attempts from 1     */    for (attempt = 0; attempt < DEFAULT_NUM_PING_ATTEMPTS; attempt++)    {        /* Send the ICMP packet... */        status = sendto(fd, pkt, total, 0, (struct sockaddr *)&to, sizeof(to));        if (status != total)        {            PRINTF("Ping to host %s failed: %s\n", to_str, strerror(errno));            err = -1;            break;        }        /*          * Now wait for something to come back or the nominated timeout         * to expire (currently defaults to 4 seconds, but could easily         * paramterise the function and dispense with the constant)         */        timeout.tv_sec = DEFAULT_PING_TIMEOUT;        timeout.tv_usec = 0;        while (TRUE) /* Forever loop */        {            /* Set of file descriptors to be passed in select to read */            fd_set  read;            /* Length of the ICMP6 message */            int     len = 0;                        /* Source address of the received message */            struct sockaddr_storage from;            /* String with address */            /* Assume INET6_ADDRSTRLEN > INET_ADDRSTRLEN */            char    from_str[INET6_ADDRSTRLEN];            /* Buffer for incoming message */                        u_int8_t    p_buf[PING_MSG_BUFFER_LEN];            /* Send request and receive reply time */            struct timeval  time_send, time_recv;            /* Request-reply round trip time */                        unsigned long   roundtrip;                                    /* Prepare set of file descriptors to read from */            FD_ZERO(&read);            FD_SET(fd, &read);            /* Record when we called select */            gettimeofday(&time_send, NULL);            /* Wait for a packet or a timeout... */            status = select(fd + 1, &read, NULL, NULL, &timeout);            if (status == 0)            {                PRINTF("Request timed out.\n");                err = ETIMEDOUT;                break;            }            else if(status == -1)            {                PRINTF("Select call failed.\n");                err = EINVAL;                break;            }            /*              * We've received a packet. Calculate how long             * we have been in the select, and adjust the timeout,             * in case we have to enter the select again.             */            gettimeofday(&time_recv, NULL);            /* Calculate round trip time - in the time_recv */            tv_sub(&time_recv, &time_send);            /* Calculate timeout value for the next select call */            tv_sub(&timeout, &time_recv);            /* Receive packet */            len = sizeof(from);            status = recvfrom(fd, (char *)p_buf, sizeof(p_buf), 0,                              (struct sockaddr *)&from, &len);            if (status < 0)            {                PRINTF("Receive failed: recvfrom\n");                err = EINVAL;                break;            }                        /* Convert address from binary to string format */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
6080yy午夜一二三区久久| 亚洲成人免费在线观看| 亚洲夂夂婷婷色拍ww47| 免费视频一区二区| 91女厕偷拍女厕偷拍高清| 欧美zozozo| 午夜精品123| 在线观看国产精品网站| 久久久久免费观看| 麻豆成人免费电影| 欧美日韩国产一二三| 亚洲视频你懂的| 成人一区二区三区视频在线观看| 欧美一级欧美三级| 日欧美一区二区| 欧美色区777第一页| 亚洲激情一二三区| 色婷婷综合久久久久中文| 国产精品理伦片| 成人黄色在线网站| 国产精品久久久久四虎| 国产传媒日韩欧美成人| 久久久久久99久久久精品网站| 久久精品国产亚洲一区二区三区| 欧美视频一区二区三区在线观看| 玉足女爽爽91| 在线看国产一区二区| 一区二区三区四区不卡视频| 国产精品 日产精品 欧美精品| 久久久综合九色合综国产精品| 极品少妇xxxx精品少妇偷拍| 日韩免费观看2025年上映的电影| 日本美女一区二区三区视频| 日韩精品一区二区在线观看| 激情综合色综合久久综合| 精品国产乱码久久久久久牛牛| 秋霞电影网一区二区| 亚洲男人的天堂在线观看| 国产成人精品亚洲日本在线桃色| 久久综合狠狠综合久久综合88| 国产一区在线观看视频| 国产亚洲成av人在线观看导航| 福利一区在线观看| 亚洲婷婷在线视频| 欧美丝袜丝交足nylons图片| 丝袜美腿高跟呻吟高潮一区| 精品欧美一区二区三区精品久久| 久久成人免费电影| 国产精品久久久久久久浪潮网站| 99re视频这里只有精品| 亚洲最新视频在线观看| 在线播放欧美女士性生活| 老司机精品视频一区二区三区| 久久久精品日韩欧美| 91片在线免费观看| 日韩中文字幕一区二区三区| 久久久久久久久久美女| 不卡视频一二三| 亚洲一区二区三区美女| 欧美成人免费网站| 91麻豆国产在线观看| 日韩一区欧美二区| 国产精品欧美极品| 在线播放欧美女士性生活| 丰满少妇在线播放bd日韩电影| 一区二区视频在线| 精品区一区二区| 日本高清不卡aⅴ免费网站| 蜜臀av一区二区在线观看| 最新不卡av在线| 日韩精品资源二区在线| 99久久精品国产毛片| 蜜桃av一区二区三区电影| 最新热久久免费视频| 91 com成人网| av电影天堂一区二区在线| 水野朝阳av一区二区三区| 国产精品久久久久久久久免费相片 | 精品国产3级a| 色婷婷国产精品久久包臀| 国精产品一区一区三区mba桃花 | 精品影院一区二区久久久| 亚洲男人的天堂一区二区| 精品国产91九色蝌蚪| 在线观看视频91| 成人动漫一区二区三区| 精品一区二区成人精品| 亚洲一区二区三区中文字幕在线 | 亚洲超丰满肉感bbw| 日本一区二区免费在线观看视频 | 六月丁香婷婷久久| 一区av在线播放| 亚洲欧洲av色图| 欧美国产欧美亚州国产日韩mv天天看完整| 4438x亚洲最大成人网| 91热门视频在线观看| 成人黄色777网| 国产精品中文有码| 久久精品99国产精品| 午夜精品久久久久久久 | 国产亚洲短视频| 精品乱人伦一区二区三区| 欧美精品一二三| 91色九色蝌蚪| 99riav一区二区三区| 大美女一区二区三区| 国产精品资源网站| 国产成人夜色高潮福利影视| 精品一二三四区| 久88久久88久久久| 韩国精品主播一区二区在线观看 | 69成人精品免费视频| 欧美主播一区二区三区| 在线免费观看一区| 欧美三级日韩在线| 欧美男男青年gay1069videost| 欧美体内she精高潮| 91福利精品视频| 欧美亚洲自拍偷拍| 91精品国产综合久久福利| 欧美另类高清zo欧美| 欧美日韩精品久久久| 51精品秘密在线观看| 日韩三区在线观看| 亚洲精品一线二线三线| 国产情人综合久久777777| 国产欧美日韩综合精品一区二区| 国产精品视频一二| 一区二区中文字幕在线| 亚洲免费av高清| 午夜视频在线观看一区二区三区| 日本不卡1234视频| 国精产品一区一区三区mba视频| 国产乱色国产精品免费视频| 不卡一区二区在线| 色偷偷久久一区二区三区| 欧美日韩电影一区| 欧美精品一区二区三区一线天视频| 久久精品欧美日韩精品| 亚洲欧洲性图库| 香蕉久久夜色精品国产使用方法| 捆绑调教美女网站视频一区| 成人免费电影视频| 欧美性xxxxxx少妇| 久久综合999| 亚洲精品成人天堂一二三| 久久精品国产澳门| 成人黄色片在线观看| 欧美日韩国产电影| 国产日韩欧美一区二区三区乱码| 国产精品黄色在线观看| 天天综合网天天综合色| 国产白丝精品91爽爽久久| 日本高清不卡一区| 久久网站最新地址| 亚洲成人黄色影院| 国产成人8x视频一区二区| 在线看一区二区| 国产日产欧美一区二区三区| 亚洲h精品动漫在线观看| 精品一区二区久久久| 欧美亚洲自拍偷拍| 中文字幕欧美激情| 日韩二区三区四区| 色偷偷一区二区三区| 26uuu另类欧美| 亚洲成人激情av| www.亚洲激情.com| 日韩高清中文字幕一区| 成人高清视频免费观看| 日韩精品一区国产麻豆| 亚洲国产一区二区视频| 成人av网站在线观看| 欧美大肚乱孕交hd孕妇| 亚洲午夜久久久久久久久久久| 国产成人小视频| 久久一留热品黄| 欧美aaaaa成人免费观看视频| 91福利国产精品| 亚洲三级小视频| 成人伦理片在线| 久久这里只有精品首页| 日本在线播放一区二区三区| 欧美熟乱第一页| 亚洲精品高清视频在线观看| 波多野结衣在线一区| 日韩欧美一区电影| 免费成人性网站| 欧美一级搡bbbb搡bbbb| 午夜精品久久久久久久| 91国产丝袜在线播放| 1024精品合集| 91精品办公室少妇高潮对白| 日韩一区中文字幕| 成人av资源网站| 国产精品久久久久久亚洲伦| 成人午夜精品在线| 中文字幕免费观看一区| 成人中文字幕电影| 久久99久久99|