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

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

?? vxping.c

?? VxWorks網絡編程詳細介紹
?? C
字號:
/* vxPing.c - send ICMP ECHO_REPLY packets to a particular network host*/  /* Copyright 1984-1997 Wind River Systems, Inc. *//*modification history--------------------01i,14nov97,ns removed packetSize from the function xmtMsg01h,14nov97,ns added bzero in constructIcmpMsg function 01g,14nov97,ns initalized msgNum to 0 , removed u_char pointer from 	    constructIcmpMsg function01f,06nov97,mm added copyright.01e,10Oct97,mm cast arg 1 of taskIdFigure01d,10Oct97,mm definded transmitEchoMessage, xmtMsg and configureSocket01c,10Oct97,mm included "netShow.h", "usrLib.h", "hostLib.h", <stdio.h>,                        <string.h> and "sockLib.h"01b,10Oct97,mm changed ip_hl to ip_v_hl 01a,18Feb94,ms extensively modified for VxDemo.   *//* INCLUDES */#include "vxWorks.h"#include "socket.h"#include "sockLib.h"#include "netinet/in_systm.h"#include "in.h"#include "netinet/ip.h"#include "netinet/ip_icmp.h"#include "taskLib.h"#include "netShow.h"#include "usrLib.h"#include "hostLib.h"#include <stdio.h>#include <string.h>#include "inetLib.h"#define TASK_PRI       100   /* Priority of spawned tasks */#define TASK_STACK_SIZE  10000 /* stack size of the spawned tasks */#define ICMP_HDRLEN	 sizeof (struct icmp)#define MY_ICMP_ID     0x1234 /* globals */LOCAL int	 msgNum = 0 ;LOCAL struct sockaddr_in  destAddr;LOCAL int 	 sockFd;LOCAL char	 dstHost [20];  /* Name of the remote host to ping */LOCAL int        numReceived = 0 ;LOCAL int 	 origNumPackets;LOCAL int	 numPkts;/* forward declarations */LOCAL STATUS startPing();STATUS rcvPings ();LOCAL void constructIcmpMsg (struct icmp  *);LOCAL void pingResponse ();LOCAL u_short inCksm (u_short *);STATUS transmitEchoMessage();STATUS xmtMsg(struct icmp* msg);STATUS configureSocket(char* nameofHost);/* Needs to be compiled with -DUSE_BITFIELDS flag *//***************************************************************************** * vxPing - send ICMP ECHO_REPLY packets to a particular network host to  *        elicit an ICMP ECHO_RESPONSE from that specified network host *        and prints "<host> is alive" on the standard output if the host *        responds, otherwise prints ICMP error messages. *         *        When using ping, make sure the host you want to ping is already *        in the host table. If not, add the host to the host table using *        hostAdd. If the host you want to ping is in a different network *        than your VxWorks system, make sure route is established to that *        host. If route is not already established, use routeAdd to add *        the route.  * *  EXAMPLE: * *     To run ping, from the VxWorks shell do as follows: *     -> vxPing ("nameOfTheHost", count) * *     where nameOfTheHost is the name of the host you want to ping and  *     count is the number of requests to send ( example: ping ("sevana", 5) ) */STATUS vxPing   (   char *hostName,    /* Name of the host to ping */   int numPackets     /* Number of requests to send */   )   {   int num_packs;   int status;   /* get user's parameters */   if (hostName == NULL)        {       printf ("Must enter a host name to Ping\n") ;       return (ERROR);       }   if (numPackets > 1)        num_packs = numPackets;   else       num_packs = 1;   numPkts = num_packs;   origNumPackets = num_packs;   msgNum = 0;   /* configure for network communications */   status = configureSocket (hostName) ;      if (status == ERROR)      {      printf ("error while trying to configure socket\n") ;      return (ERROR);      }   if (taskSpawn ("tStartPing", TASK_PRI, 0, TASK_STACK_SIZE,                   (FUNCPTR) startPing, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) == ERROR)      {      perror ("spawning startPing task filed");      return (ERROR);      }   if (taskSpawn ("tRcvPing", TASK_PRI, 0, TASK_STACK_SIZE,                   (FUNCPTR) rcvPings, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) == ERROR)      {      perror ("spawning rcvPings task filed");      return (ERROR);      }   return (OK);   }/***************************************************************************** * configureSocket - Configures socket for ICMP protocol  * * RETURNS : OK or ERROR * */STATUS configureSocket    (   char *nameOfHost    )    {    printf ("Name of the host to ping is -> %s\n", nameOfHost);    bzero ((char *) &destAddr, sizeof (destAddr));    destAddr.sin_family = AF_INET ;    if ((destAddr.sin_addr.s_addr = hostGetByName (nameOfHost)) == ERROR)        {	if ( (destAddr.sin_addr.s_addr = inet_addr (nameOfHost)) == ERROR)	    {            perror ("bad host!");            return (ERROR) ;            }	}    strcpy (dstHost, nameOfHost);    sockFd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);    if (sockFd < 0)        {        perror ("socket failed in configure_socket");        return (ERROR);        }    else        {        return (OK) ;        }    }/***************************************************************************** * startPing - Initiates ping * * RETURNS : OK or ERROR * */LOCAL STATUS startPing()    {    while (1)        {        if (numPkts > 0)            {            numPkts--;            if (transmitEchoMessage() == ERROR)                {                printf ("Error in transmitEchoMessage\n");                return (ERROR);                }            }        else            break ;        taskDelay(5) ;        }   pingResponse ();   return (OK);   }/***************************************************************************** * transmitEchoMessage - Fill ICMP header and transmit ECHO_REQUEST datagrams * * RETURNS : OK or ERROR * */STATUS transmitEchoMessage()   {   struct icmp  icmpMsg;   constructIcmpMsg (&icmpMsg);   if (xmtMsg (&icmpMsg) == ERROR)       return (ERROR);   return (OK);   } /***************************************************************************** * constructIcmpMsg - Fills ICMP header * */LOCAL void constructIcmpMsg    (    struct icmp  *icmpMessage    )    {    bzero ( (char *) icmpMessage, sizeof (struct icmp) );    icmpMessage->icmp_type = ICMP_ECHO;    icmpMessage->icmp_code = 0;    icmpMessage->icmp_cksum = 0;    icmpMessage->icmp_id = MY_ICMP_ID;    icmpMessage->icmp_seq = msgNum++;    icmpMessage->icmp_cksum = inCksm ((u_short *) icmpMessage);    }/***************************************************************************** * xmtMsg - transmit ECHO_REQUEST datagrams * * RETURNS : OK or ERROR * */STATUS xmtMsg    (    struct icmp *msg     )   {   int result;   if ((result = sendto (sockFd, (caddr_t) msg, ICMP_HDRLEN, 0,           (struct sockaddr *) &destAddr, sizeof(destAddr))) < 0)        {       perror ("sendto error");       return (ERROR);       }   else        if (result != sizeof (msg))           printf ("wrote %s %d bytes, return = %d\n", dstHost,                      (int) ICMP_HDRLEN, result);   return (OK);   }/***************************************************************************** * rcvPings - receive ICMP ECHO_RESPONSE from the specified network host * */STATUS rcvPings()    {    int                 remAddrlen;    struct sockaddr_in  remAddr;    int                 iphdrlen;    struct ip           *ipPtr;    struct icmp         *icmpPtr;    u_char     recvpack[4096] ;    numReceived = 0 ;    remAddrlen = sizeof(remAddr) ;    while (1)  /* loop until we break out */        {        if ((recvfrom (sockFd, recvpack, sizeof (recvpack), 0,                        (struct sockaddr *) &remAddr, &remAddrlen)) < 0)            {            perror ("recvfrom error");            return (ERROR);            }        else            {            ipPtr = (struct ip *) recvpack ;            iphdrlen = (LSB4 (ipPtr->ip_v_hl)) << 2;            icmpPtr = (struct icmp *) (recvpack + iphdrlen);            if ((icmpPtr->icmp_type == ICMP_ECHOREPLY)                                            && (icmpPtr->icmp_id == MY_ICMP_ID))                {                numReceived++ ;                if (numReceived == origNumPackets)                    return (OK);                }            }        }    }/***************************************************************************** * pingResponse - prints "<host> is alive" on the standard output if the host *                responds, otherwise prints ICMP error messages. *         */LOCAL void pingResponse()    {    if (numReceived == origNumPackets)        printf("\nhost %s is alive\n", dstHost);    else        {        printf("\ntrouble response with %s: snt %d packet%c, received %d packet%c\n\n",                 dstHost, origNumPackets, ((origNumPackets != 1) ? 's' : ' '),                 numReceived, ((numReceived != 1) ? 's' : ' ') ) ;        icmpstatShow ();        if (taskDelete (taskIdFigure ((int)"tRcvPing")) == ERROR)            {            perror ("Error in taskDelete");            return;            }        }    }/***************************************************************************** * inCksm - compute checksum *         * RETURNS the calculated checksum (ones complement) of the icmp struct */u_short inCksm    (    register u_short  *msg_ptr    )        {    register long    sum;    register u_short answer;    int              index;    sum = 0 ;    for (index = 0 ; index < 4 ; index++)        {        sum = sum + *msg_ptr ;        msg_ptr++ ;        }    sum = (sum >> 16) + (sum & 0xffff) ;    sum = sum + (sum >> 16) ;    answer = ~sum ;    return (answer) ;    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久国产一区二区三区四区 | 91精选在线观看| 久久蜜桃av一区精品变态类天堂 | 国产日产亚洲精品系列| 亚洲亚洲精品在线观看| 国产精品一区2区| 日韩欧美久久一区| 婷婷综合在线观看| 日本道精品一区二区三区| 日韩欧美一二三四区| 亚洲综合色婷婷| 99re66热这里只有精品3直播 | 91在线码无精品| 中文字幕av资源一区| 久久99精品久久久久久国产越南 | 欧美午夜精品免费| 自拍偷拍国产精品| 国产福利不卡视频| 精品久久一区二区| 久久机这里只有精品| 欧美一区二区三区视频免费 | 日韩美女视频19| 国产成人av电影在线播放| 精品国产乱码久久久久久影片| 亚洲18女电影在线观看| 欧美三区免费完整视频在线观看| 日韩美女精品在线| 91视频免费观看| 一区二区三区在线影院| 一本色道久久综合亚洲精品按摩| 中文字幕一区二区三区四区不卡| 波多野结衣欧美| 亚洲欧洲精品一区二区精品久久久 | 成人18视频日本| 国产精品美日韩| 97se亚洲国产综合自在线| 欧美国产欧美综合| caoporen国产精品视频| 亚洲另类在线一区| 欧美三级韩国三级日本一级| 亚洲午夜免费视频| 日韩欧美123| 福利91精品一区二区三区| 国产精品毛片久久久久久| 一本到不卡精品视频在线观看| 亚洲免费电影在线| 欧美日韩亚洲综合一区二区三区| 天天免费综合色| 欧美岛国在线观看| 暴力调教一区二区三区| 亚洲在线观看免费视频| 91精品国产91热久久久做人人 | 91麻豆国产福利精品| 亚洲综合一二三区| 91精品国产一区二区三区| 极品少妇一区二区| 最新日韩在线视频| 欧美一级专区免费大片| 国产精品影视网| 洋洋av久久久久久久一区| 欧美一区二区三级| 成人性视频免费网站| 亚洲精品国产视频| 亚洲精品在线观看网站| 色综合久久久久综合| 蜜臀久久99精品久久久久久9| 国产欧美日本一区视频| 91国产福利在线| 国产一区二区三区av电影| 一区二区高清免费观看影视大全 | 激情综合色播五月| 亚洲免费在线电影| 欧美不卡在线视频| 色老汉一区二区三区| 精品一二线国产| 午夜伦理一区二区| 一区二区中文视频| 亚洲精品一区二区三区99| 欧美专区日韩专区| 成人免费毛片aaaaa**| 亚洲图片自拍偷拍| 亚洲欧美日韩一区| 国产日本欧美一区二区| 欧美一区二区免费视频| 日本乱人伦aⅴ精品| 国产乱人伦偷精品视频不卡| 亚洲444eee在线观看| 亚洲视频在线一区二区| 久久久91精品国产一区二区三区| 6080日韩午夜伦伦午夜伦| 色综合中文综合网| 日韩视频一区二区| 色噜噜狠狠成人中文综合| 成人永久免费视频| 国产麻豆成人传媒免费观看| 日韩精品乱码免费| 亚洲国产日韩精品| 一区二区国产视频| 有坂深雪av一区二区精品| 国产精品入口麻豆原神| 国产亚洲精品久| 精品日韩欧美在线| 日韩免费在线观看| 日韩欧美一二区| 日韩精品一区二区三区在线播放| 91精品国产综合久久精品性色| 91国产免费看| 欧美日韩国产首页| 欧美在线观看视频一区二区三区| 成人av资源网站| 成人性生交大合| 成人一级黄色片| av中文字幕在线不卡| av激情成人网| 日本高清不卡aⅴ免费网站| 在线视频一区二区免费| 欧美优质美女网站| 欧美一区欧美二区| 91精品国产综合久久久久久久| 日韩一区二区三区三四区视频在线观看 | 色中色一区二区| 91久久精品网| 欧美老年两性高潮| 制服丝袜在线91| 日韩精品中文字幕一区| 国产欧美一区二区精品仙草咪| 欧美激情一区二区三区| 亚洲伦理在线精品| 午夜精品在线看| 久久不见久久见中文字幕免费| 精品在线亚洲视频| 成人精品小蝌蚪| 欧亚洲嫩模精品一区三区| 91精品久久久久久久99蜜桃| 日韩免费性生活视频播放| 久久久亚洲午夜电影| 亚洲女人小视频在线观看| 亚洲国产成人av网| 国产一区欧美一区| 91在线国内视频| 欧美一级爆毛片| 国产精品美日韩| 日本不卡一二三| 不卡一卡二卡三乱码免费网站| 色综合久久88色综合天天| 日韩欧美另类在线| 亚洲婷婷综合色高清在线| 日韩福利视频网| 成人免费看视频| 日韩精品最新网址| 一区二区三区四区在线播放| 麻豆国产欧美一区二区三区| av色综合久久天堂av综合| 欧美人与禽zozo性伦| 欧美激情一区二区三区| 青青草国产精品97视觉盛宴| 成人高清免费在线播放| 91精品欧美综合在线观看最新| 国产日产亚洲精品系列| 亚洲午夜精品在线| 成人h动漫精品一区二区| 91精品麻豆日日躁夜夜躁| 自拍偷拍国产精品| 国产精品99久久久| 8x8x8国产精品| 亚洲精品自拍动漫在线| 国产一区二区精品久久| 9191精品国产综合久久久久久| 国产精品久久久久久福利一牛影视 | 色悠久久久久综合欧美99| 精品国产网站在线观看| 亚洲一区二区不卡免费| 国产aⅴ综合色| 精品久久久久久久人人人人传媒| 亚洲精品ww久久久久久p站| 国产激情视频一区二区三区欧美| 欧美日韩精品一区视频| 尤物在线观看一区| va亚洲va日韩不卡在线观看| 久久亚洲捆绑美女| 免费高清在线一区| 337p亚洲精品色噜噜| 午夜精品福利久久久| 在线视频国内一区二区| 国产精品萝li| 成人福利在线看| 国产精品天干天干在观线| 国产成人午夜精品5599| 久久精品视频免费| 国产精品白丝jk白祙喷水网站| 精品裸体舞一区二区三区| 免费看欧美女人艹b| 7777精品伊人久久久大香线蕉完整版 | 国产.欧美.日韩| 久久久青草青青国产亚洲免观| 久久精品国产精品青草| 日韩一卡二卡三卡四卡| 免费日本视频一区| 日韩一级二级三级精品视频| 日本成人中文字幕|