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

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

?? sntpslib.c

?? vxworks的完整的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* sntpsLib.c - Simple Network Time Protocol (SNTP) server library *//* Copyright 1984 - 2000 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history --------------------01l,07may02,kbw  man page edits01k,25oct00,ham  doc: cleanup for vxWorks AE 1.0.01j,16mar99,spm  removed references to configAll.h (SPR #25663)01i,16mar99,spm  recovered orphaned code from tor2_0_x branch (SPR #25770)01h,01dec98,spm  corrected man page references for clock hook (SPR #22860)01g,14dec97,jdi  doc: cleanup.01f,10dec97,kbw  made minor man page changes01e,04dec97,spm  added minor changes to man pages; changed parameter names to                  comply with coding standards01d,02sep97,spm  corrected return value and typecast for sntpsConfigSet routine01c,27aug97,spm  corrected header file name in library description01b,15jul97,spm  code cleanup, documentation, and integration; entered in                 source code control01a,24may97,kyc  written*//* DESCRIPTIONThis library implements the server side of the Simple Network Time Protocol(SNTP), a protocol that allows a system to maintain the accuracy of its internal clock based on time values reported by one or more remote sources. The library is included in the VxWorks image if INCLUDE_SNTPS is defined at the time the image is built.USER INTERFACEThe routine sntpsInit() is called automatically during system startup when the SNTP server library is included in the VxWorks image. Depending on the value of SNTPS_MODE, the server executes in either a passive or an active mode.  When SNTPS_MODE is set to SNTP_PASSIVE (0x2), the server waits forrequests from clients, and sends replies containing an NTP timestamp. Whenthe mode is set to SNTP_ACTIVE (0x1), the server transmits NTP timestampinformation at fixed intervals. When executing in active mode, the SNTP server uses the SNTPS_DSTADDR and SNTPS_INTERVAL definitions to determine the target IP address and broadcastinterval.  By default, the server will transmit the timestamp information tothe local subnet broadcast address every 64 seconds.  These settings can bechanged with a call to the sntpsConfigSet() routine.  The SNTP server operatingin active mode will still respond to client requests.The SNTP_PORT definition in assigns the source and destination UDP port.  The default port setting is 123 as specified by the relevant RFC.  Finally, theSNTP server requires access to a reliable external time source.  TheSNTPS_TIME_HOOK constant specifies the name of a routine with the followinginterface:.CS    STATUS sntpsTimeHook (int request, void *pBuffer);.CEThis routine can be assigned directly by altering the value of SNTPS_TIME_HOOKor can be installed by a call to the sntpsClockSet() routine. The manual pagesfor sntpsClockSet() describe the parameters and required operation of thetimestamp retrieval routine.  Until this routine is specified, the SNTP serverwill not provide timestamp information.VXWORKS AE PROTECTION DOMAINSUnder VxWorks AE, the SNPT server can run in the kernel protection domain only. The SNTPS_TIME_HOOK MUST, if used, must reference a function in the kernel protection domain.  This restriction does not apply under non-AE versions of VxWorks.  INCLUDE FILES: sntpsLib.hSEE ALSO: sntpcLib, RFC 1769*//* includes */#include "vxWorks.h"#include "sysLib.h"#include "inetLib.h"#include "sockLib.h"#include "netLib.h"#include "ioLib.h"#include "wdLib.h"#include "usrLib.h"#include "errnoLib.h"#include "sntpsLib.h"#include <sys/ioctl.h>/* defines */#define NSEC_BASE2 	30 	/* Integral log2 for nanosecond conversion. *//* forward declarations */LOCAL void sntpsMsgSend (void);LOCAL void sntpsStart (void);LOCAL int sntpsTaskPriority  = 56;    /* Priority level of SNTP server. */LOCAL int sntpsTaskOptions = 0;       /* Option settings for SNTP server. */LOCAL int sntpsTaskStackSize = 5000;  /* Stack size for SNTP server task. */LOCAL WDOG_ID   sntpsTimer;           /* Timer for periodic broadcasts. */LOCAL SEM_ID    sntpsMutexSem;        /* Protection for clock changes. */LOCAL BOOL 	sntpsInitialized;     /* Ready to send timestamps? */LOCAL BOOL 	sntpsClockReady;      /* Clock hook assigned? */LOCAL ULONG 	sntpsClockId;         /* SNTP clock identifier. */LOCAL ULONG     sntpsRefId;           /* Default reference identifier. */LOCAL ULONG     sntpsResolution;      /* Clock resolution, in nanoseconds. */LOCAL INT8      sntpsPrecision;       /* Clock precision, in RFC format. */LOCAL u_char 	sntpsMode;            /* Active or passive operation. */LOCAL short 	sntpsInterval;        /* Broadcast interval, in seconds. */LOCAL u_short 	sntpsPort;            /* UDP source and destination port. */LOCAL struct in_addr 	sntpsDstAddr; /* Broadcast or multicast destination. */LOCAL FUNCPTR   sntpsClockHookRtn;    /* Access to timestamp information. *//********************************************************************************* sntpsInit - set up the SNTP server** This routine is called from usrNetwork.c to link the SNTP server module into* the VxWorks image.  It creates all necessary internal data structures and* initializes the SNTP server according to the assigned settings.** RETURNS: OK or ERROR.** ERRNO:*  S_sntpsLib_INVALID_PARAMETER** NOMANUAL*/STATUS sntpsInit     (    char * 	pDevName, 	/* boot device name */    u_char 	mode, 		/* broadcast or unicast mode */    char * 	pDstAddr, 	/* destination IP address for broadcasts */    short 	interval, 	/* broadcast interval */    u_short 	port, 		/* UDP source/destination port */    FUNCPTR 	pTimeHookRtn 	/* timestamp retrieval routine */    )    {    STATUS result = OK;    int retVal;    int sockNum = 0;    struct ifreq ifr;    struct in_addr ifAddr;    struct in_addr ifMask;    sntpsInitialized = FALSE;    sntpsClockReady = FALSE;    sntpsRefId = 0;    /* Default ref. ID if hook routine returns ERROR */    /* Set mode to specified value. */    if (mode != SNTP_ACTIVE && mode != SNTP_PASSIVE)        {        errnoSet (S_sntpsLib_INVALID_PARAMETER);        return (ERROR);        }    else        sntpsMode = mode;           /* For active (broadcast) mode, set message interval and target address. */    if (sntpsMode == SNTP_ACTIVE)        {        /* Sanity check broadcast interval and assign target address. */        if (interval < 0)            interval = 0;        sntpsInterval = interval;        /* Use subnet local broadcast address if none specified. */        if (pDstAddr == NULL)            {            /* Combine IP address of interface and current netmask. */            sockNum = socket (AF_INET, SOCK_RAW, 0);            if (sockNum == -1)                return (ERROR);            bzero ( (char *)&ifr, sizeof (struct ifreq));            strcpy (ifr.ifr_name, pDevName);            ifr.ifr_addr.sa_len = sizeof (struct sockaddr_in);            retVal = ioctl (sockNum, SIOCGIFADDR, (int)&ifr);            if (retVal != 0)                {                close (sockNum);                return (ERROR);                }            ifAddr.s_addr =                        ( (struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;            retVal = ioctl (sockNum, SIOCGIFNETMASK, (int)&ifr);            if (retVal != 0)                {                close (sockNum);                return (ERROR);                }            ifMask.s_addr =                        ( (struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;            close (sockNum);            /* Extract network address and fill host portion with ones. */            sntpsDstAddr.s_addr = (ifAddr.s_addr & ifMask.s_addr)                                     | ~ifMask.s_addr;            }        else        /* Use specified destination address. */            {            sntpsDstAddr.s_addr = inet_addr (pDstAddr);            if (sntpsDstAddr.s_addr == ERROR)                {                errnoSet (S_sntpsLib_INVALID_PARAMETER);                return (ERROR);                }            }        /* Create timer for periodic transmissions. */        sntpsTimer = wdCreate ();        if (sntpsTimer == NULL)            return (ERROR);        }    /* Create synchronization semaphore for changing clock. */    sntpsMutexSem = semBCreate (SEM_Q_FIFO, SEM_FULL);    if (sntpsMutexSem == NULL)        {        if (sntpsMode == SNTP_ACTIVE)            wdDelete (sntpsTimer);        return (ERROR);        }    sntpsPort = htons (port);    sntpsInitialized = TRUE;    /* Enable transmission if timestamp retrieval routine is provided. */    result = sntpsClockSet (pTimeHookRtn);    if (result == OK)        sntpsClockReady = TRUE;     result = taskSpawn ("tSntpsTask", sntpsTaskPriority, sntpsTaskOptions,                        sntpsTaskStackSize, (FUNCPTR) sntpsStart,                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0);    return (result);    }/********************************************************************************* sntpsLog2Get - find approximate power of two** This routine determines the nearest integral power of two for the given * value, without using floating point arithmetic.  It is used to convert * 32-bit nanosecond values into signed integers for assignment to the poll * and precision fields of NTP messages.** RETURNS: Nearest integral log base two value, in host byte order.** ERRNO: N/A** INTERNAL* Floating-point calculations can't be used because some boards (notably* the SPARC architectures) disable software floating point by default to* speed up context switching. These boards abort with an exception when* floating point operations are encountered.** NOMANUAL*/INT8 sntpsLog2Get    (    ULONG inval 	/* input value for calculation */    )    {    int loop;    int floor; 		/* Nearest power of two for smaller value */    int limit; 		/* Nearest power of two for larger value */    int result;    ULONG mask; 	/* Bitmask for log2 calculation */    if (inval == 0)        result = 0;    else        {        /*         * Set increasing numbers of the low-order bits of the input value         * to zero until all bits have been cleared. The current and previous         * values of the loop counter indicate the adjacent integral powers         * of two.         */        for (loop = 0; loop < 32; loop ++)            {            mask = ~0 << loop;     /* Mask out the rightmost "loop" bits. */            if ( (inval & mask) == 0)                break;            }        floor = 1 << (loop - 1);        limit = 1 << loop;        if (inval - floor < limit - inval)            result = loop - 1;        else            result = loop;        }       return (result);    }/********************************************************************************* sntpsClockSet - assign a routine to access the reference clock** This routine installs a hook routine that is called to access the * reference clock used by the SNTP server. This hook routine must use the * following interface:* .CS*     STATUS sntpsClockHook (int request, void *pBuffer);* .CE * The hook routine should copy one of three settings used by the server to* construct outgoing NTP messages into <pBuffer> according to the value of * the <request> parameter.  If the requested setting is available, the * installed routine should return OK (or ERROR otherwise).** This routine calls the given hook routine with the <request> parameter * set to SNTPS_ID to get the 32-bit reference identifier in the format* specified in RFC 1769.  It also calls the hook routine with <request> * set to SNTPS_RESOLUTION to retrieve a 32-bit value containing the clock * resolution in nanoseconds.  That value will be used to determine the 8-bit * signed integer indicating the clock precision (according to the format * specified in RFC 1769).  Other library routines will set the <request> * parameter to SNTPS_TIME to retrieve the current 64-bit NTP timestamp * from <pBuffer> in host byte order.  The routine sntpsNsecToFraction() will * convert a value in nanoseconds to the format required for the NTP * fractional part.** VXWORKS AE PROTECTION DOMAINS* Under VxWorks AE, you can call this function from within the kernel * protection domain only.  In addition, all arguments to this function can  * reference only that data which is valid in the kernel protection domain. * This restriction does not apply under non-AE versions of VxWorks.  ** RETURNS: OK or ERROR.** ERRNO: N/A*/STATUS sntpsClockSet    (    FUNCPTR 	pClockHookRtn 	/* new interface to reference clock */    )    {    STATUS result;    INT8 basetwo;    if (pClockHookRtn == NULL)        return (ERROR);    /* Don't change clock setting if current routine is in use. */    semTake (sntpsMutexSem, WAIT_FOREVER);    sntpsClockHookRtn = pClockHookRtn;    /* Get clock precision and clock identifier. */    result = (* sntpsClockHookRtn) (SNTPS_ID, &sntpsClockId);    if (result == ERROR)  /* Clock ID not available. Use default value. */        sntpsClockId = sntpsRefId;    result = (* sntpsClockHookRtn) (SNTPS_RESOLUTION, &sntpsResolution);    if (result == ERROR)        sntpsPrecision = 0;    else        {        /* Find nearest power of two to clock resolution. */        basetwo = sntpsLog2Get (sntpsResolution);        /*         * Convert to seconds required for NTP message. Subtract nearest          * integer to log base two of 1E9 (corresponds to division of clock          * resolution by 1E9).         */        sntpsPrecision = basetwo - NSEC_BASE2;        }    if (!sntpsClockReady)        sntpsClockReady = TRUE;     /* Enable transmission of messages. */    semGive (sntpsMutexSem);    return (OK);    }/********************************************************************************* sntpsNsecToFraction - convert portions of a second to NTP format** This routine is provided for convenience in fulfilling an SNTPS_TIME request* to the clock hook.  It converts a value in nanoseconds to the fractional part * of the NTP timestamp format.  The routine is not designed to convert * non-normalized values greater than or equal to one second.  Although the NTP * time format provides a precision of about 200 pico-seconds, rounding errors * in the conversion process decrease the accuracy as the input value increases.* In the worst case, only the 24 most significant bits are valid, which reduces* the precision to tenths of a micro-second.** RETURNS: Value for NTP fractional part in host-byte order.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久亚洲高清| 韩国欧美国产1区| 欧美丝袜丝交足nylons图片| 日韩av在线免费观看不卡| 国产女人水真多18毛片18精品视频| 国产精品一级黄| 夜夜夜精品看看| 久久免费看少妇高潮| 91九色最新地址| 国产精品综合久久| 免费久久99精品国产| 国产精品久久777777| 久久久久亚洲蜜桃| 欧美美女直播网站| 波多野结衣一区二区三区| 日日欢夜夜爽一区| 夜夜嗨av一区二区三区网页 | 亚洲欧美日韩国产一区二区三区| 56国语精品自产拍在线观看| 99精品黄色片免费大全| 大胆亚洲人体视频| 高清不卡一区二区| 国产永久精品大片wwwapp| 久久精品国产999大香线蕉| 男女男精品视频网| 捆绑调教一区二区三区| 免费观看久久久4p| 久久国产福利国产秒拍| 韩国女主播一区| 成人禁用看黄a在线| 成人精品免费网站| 97国产一区二区| 欧美最猛性xxxxx直播| 欧美乱熟臀69xxxxxx| 亚洲精品在线三区| 欧美激情在线一区二区三区| 有码一区二区三区| 久久99久久精品欧美| 国产一二精品视频| 91社区在线播放| 久久久影院官网| 欧美视频在线播放| 亚洲欧美视频在线观看视频| 国产日韩欧美精品综合| 麻豆中文一区二区| 91精品国产品国语在线不卡| 五月激情六月综合| 国产成人亚洲精品狼色在线| 日本韩国精品在线| 欧美一区二区三区免费大片| 日韩欧美二区三区| 国产精品午夜久久| 日韩综合在线视频| 国产精品一级在线| 91丨九色丨尤物| 欧美丝袜自拍制服另类| 欧美肥妇free| 国产欧美综合色| 午夜私人影院久久久久| 国产高清视频一区| 91久久国产最好的精华液| 717成人午夜免费福利电影| 久久久久久久久久久黄色| 亚洲欧洲综合另类| 岛国精品在线观看| 亚洲精品国产一区二区三区四区在线| 亚洲欧美日韩国产综合| 91麻豆免费看| 亚洲一区二区三区精品在线| 欧美亚洲国产一区二区三区va| 亚洲色图丝袜美腿| 欧亚洲嫩模精品一区三区| 亚洲一区二区在线免费看| 91视频一区二区| 亚洲老妇xxxxxx| 一本高清dvd不卡在线观看| 综合色天天鬼久久鬼色| 色八戒一区二区三区| 婷婷久久综合九色综合伊人色| 欧美日韩高清一区二区| 午夜一区二区三区视频| 精品少妇一区二区三区日产乱码 | 久久久精品日韩欧美| 国产精品1区2区| 亚洲成人免费在线观看| 久久这里只有精品6| 色噜噜夜夜夜综合网| 天天免费综合色| 亚洲欧美一区二区三区国产精品| 色婷婷亚洲精品| 国产乱码精品一区二区三区五月婷 | 国产成人啪免费观看软件| 91网站最新网址| 国产99久久久久| 国产99久久久国产精品潘金网站| 成人ar影院免费观看视频| 91在线播放网址| 91精品午夜视频| 久久久久国产精品免费免费搜索| 国产女人18毛片水真多成人如厕 | 久久女同性恋中文字幕| 制服丝袜亚洲播放| 欧美日韩国产片| 91浏览器打开| 91首页免费视频| 97精品视频在线观看自产线路二 | 国产剧情一区在线| 麻豆成人免费电影| 毛片一区二区三区| 久久福利资源站| 久久精品国产**网站演员| 久久狠狠亚洲综合| 国产原创一区二区| 精品一区二区日韩| 国产99精品视频| 成人精品国产免费网站| 91丝袜美腿高跟国产极品老师 | 亚洲欧洲国产日本综合| 亚洲视频一区二区免费在线观看| 一区二区三区免费在线观看| 1024精品合集| 日韩精品免费专区| 国产精品一区二区三区乱码| av在线综合网| 精品乱人伦小说| 一区二区三区中文免费| 免费久久精品视频| 成人av第一页| 91精品国产91久久综合桃花| 精品日韩一区二区三区| 久久久久久久久久久久久女国产乱 | 在线电影一区二区三区| 欧美精品三级在线观看| 国产日产精品一区| 日韩在线播放一区二区| 国产iv一区二区三区| 91麻豆精品国产91久久久久久 | 亚洲精品一区二区三区四区高清 | 色综合久久综合中文综合网| 欧美日韩一级二级三级| 欧美国产成人精品| 久久丁香综合五月国产三级网站 | 国产一区二区三区四| 8v天堂国产在线一区二区| 亚洲一级二级三级| 欧美在线播放高清精品| 亚洲欧美另类在线| 欧美性一二三区| 美女在线观看视频一区二区| 日韩一区二区免费在线电影| 国产不卡视频在线观看| 亚洲老司机在线| 欧美一级高清片| 99国产精品久久久久久久久久久| 亚洲精品欧美专区| 欧美成人aa大片| 欧美日韩一级黄| 成人免费av网站| 国产欧美日韩一区二区三区在线观看 | 日韩一区精品字幕| 欧美不卡一二三| 不卡视频免费播放| 亚洲欧美日韩久久| 久久在线免费观看| 石原莉奈在线亚洲二区| 久久网这里都是精品| gogogo免费视频观看亚洲一| 国产精品家庭影院| 在线91免费看| 国产精品一区2区| 亚洲影视资源网| 国产欧美日本一区二区三区| 色欲综合视频天天天| 精品一二线国产| 亚洲精品ww久久久久久p站| 欧美久久免费观看| 色综合天天狠狠| 国产精品亚洲第一| 亚洲国产三级在线| 国产精品欧美久久久久一区二区| 欧美日韩综合色| 91亚洲精品久久久蜜桃网站| 毛片不卡一区二区| 亚洲高清视频的网址| 亚洲欧美日韩一区| 亚洲欧美在线aaa| 久久一留热品黄| 欧美精品电影在线播放| 欧美日韩精品福利| 91黄色免费版| 99久久精品国产观看| 国产精一品亚洲二区在线视频| 亚洲sss视频在线视频| 亚洲欧洲在线观看av| 国产精品美女www爽爽爽| 国产精品午夜在线| 国产精品久久久久毛片软件| 国产精品久久久久久久久搜平片 | 紧缚奴在线一区二区三区| 五月开心婷婷久久|