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

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

?? sntpslib.c

?? vxwork源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/* 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.

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品欧美久久久久久动漫| 久久蜜桃香蕉精品一区二区三区| 亚洲三级在线播放| 福利视频网站一区二区三区| 精品国产三级a在线观看| 日韩国产一二三区| 欧美久久高跟鞋激| 日韩成人午夜精品| 在线播放欧美女士性生活| 亚洲第四色夜色| 欧美三级在线看| 五月婷婷色综合| 欧美精品国产精品| 男女性色大片免费观看一区二区| 欧美精品 日韩| 视频一区二区国产| 欧美一级高清片在线观看| 91国产丝袜在线播放| 亚洲欧美日韩在线不卡| 色婷婷激情一区二区三区| 亚洲欧美成aⅴ人在线观看| 94色蜜桃网一区二区三区| 亚洲色图.com| 欧美日韩亚洲另类| 婷婷中文字幕一区三区| 欧美一区二区日韩| 久久se精品一区精品二区| 2020国产精品久久精品美国| 国产电影一区二区三区| 国产精品卡一卡二| 在线影院国内精品| 午夜电影久久久| 精品国产乱码久久久久久牛牛 | 亚洲一区影音先锋| 欧美日韩一区久久| 麻豆久久一区二区| 国产亚洲欧美在线| 色噜噜狠狠色综合欧洲selulu| 亚洲一区二区三区视频在线播放| 91麻豆精品国产91久久久久久| 麻豆freexxxx性91精品| 欧美国产欧美综合| 日本韩国精品在线| 日本强好片久久久久久aaa| 精品国产免费一区二区三区香蕉| 国产东北露脸精品视频| 亚洲精品免费在线播放| 91麻豆精品久久久久蜜臀| 国产精品88av| 一区二区三区四区不卡视频| 69久久99精品久久久久婷婷 | 青青草97国产精品免费观看| 久久久久国产成人精品亚洲午夜| av在线播放不卡| 亚洲 欧美综合在线网络| 精品国产一区二区三区不卡 | 久久久久国产精品人| 91在线观看地址| 免费成人深夜小野草| 国产精品久久久久影院色老大| 欧美性生活久久| 国产一区激情在线| 一区二区三区毛片| 欧美一级高清片在线观看| zzijzzij亚洲日本少妇熟睡| 日韩精品91亚洲二区在线观看| 久久精品一区蜜桃臀影院| 欧美在线观看18| 国产福利91精品| 亚洲二区在线视频| 国产精品污网站| 91精品在线麻豆| 99国产精品99久久久久久| 秋霞午夜鲁丝一区二区老狼| 亚洲视频一二区| 亚洲一区二区三区在线看| 日韩手机在线导航| 91啪在线观看| 国产呦精品一区二区三区网站| 亚洲综合成人在线| 国产欧美一区二区精品久导航 | 日韩欧美一级二级三级久久久| av电影在线不卡| 久久99精品久久久久婷婷| 亚洲激情校园春色| 国产校园另类小说区| 在线播放一区二区三区| 色哟哟一区二区三区| 精品一区二区三区在线播放视频 | 国产精品久久免费看| 日韩欧美在线观看一区二区三区| 99精品一区二区三区| 国产呦萝稀缺另类资源| 肉色丝袜一区二区| 一区二区三区免费| 国产精品无码永久免费888| 欧美va亚洲va香蕉在线| 欧美日韩综合不卡| 91亚洲资源网| 国产成人精品三级麻豆| 美女爽到高潮91| 午夜精品久久久久久久99樱桃| 成人免费在线视频观看| 久久久亚洲精品一区二区三区| 日韩一区二区不卡| 欧美日韩中文精品| 色哟哟一区二区在线观看| 成人av网站在线观看| 国产精品18久久久久久久网站| 性做久久久久久久免费看| 亚洲欧美另类小说| 中文字幕欧美激情一区| 久久久久久久综合| 欧美成人aa大片| 在线成人高清不卡| 欧美群妇大交群中文字幕| 欧美日韩一区在线| 在线观看www91| 色天使色偷偷av一区二区| 99久久精品99国产精品| 岛国一区二区在线观看| 国产真实乱子伦精品视频| 麻豆精品在线观看| 蜜臀a∨国产成人精品| 丝袜美腿亚洲一区| 丝袜诱惑制服诱惑色一区在线观看 | 91精品婷婷国产综合久久| 欧美日韩美女一区二区| 欧美日韩国产免费| 欧美另类变人与禽xxxxx| 欧美性欧美巨大黑白大战| 欧洲国产伦久久久久久久| 色综合天天在线| 色妞www精品视频| 色婷婷亚洲一区二区三区| 一本大道久久a久久精二百| 色av一区二区| 在线精品亚洲一区二区不卡| 在线亚洲+欧美+日本专区| 在线观看视频欧美| 欧美日韩一级黄| 欧美丰满嫩嫩电影| 欧美一区二区三级| 欧美精品一区二区三区视频| 久久一留热品黄| 国产日产欧美一区二区视频| 国产嫩草影院久久久久| 国产精品人人做人人爽人人添 | 亚洲欧洲韩国日本视频| 亚洲天堂2014| 亚洲一区二区视频在线观看| 天天操天天色综合| 麻豆一区二区三区| 国产麻豆视频一区| 99精品在线免费| 欧美亚洲动漫制服丝袜| 欧美福利视频一区| 欧美成人艳星乳罩| 日本一区二区免费在线| 一区在线观看免费| 亚洲一区二区三区国产| 日韩国产成人精品| 国产精品亚洲一区二区三区在线 | 中文幕一区二区三区久久蜜桃| 亚洲私人黄色宅男| 亚洲一区二区在线观看视频 | 午夜天堂影视香蕉久久| 免费观看久久久4p| 成人一区二区三区视频在线观看 | 亚洲欧洲av一区二区三区久久| 一区二区三区在线免费播放 | 日精品一区二区三区| 极品少妇xxxx精品少妇| 丁香五精品蜜臀久久久久99网站| 色狠狠av一区二区三区| 91精品国产色综合久久ai换脸 | 日韩一级免费一区| 国产精品少妇自拍| 亚洲一区在线观看免费观看电影高清| 日韩国产欧美在线播放| 国产91精品免费| 欧美色大人视频| 国产亚洲欧美在线| 亚洲高清视频中文字幕| 国产在线麻豆精品观看| 一本大道久久a久久精二百| 欧美一区二区成人| 国产精品久久久久久久岛一牛影视 | 国产精品每日更新在线播放网址| 一区二区三区视频在线看| 美女视频黄 久久| 99精品桃花视频在线观看| 在线播放91灌醉迷j高跟美女| 国产清纯美女被跳蛋高潮一区二区久久w| 亚洲美女少妇撒尿| 久久精品久久久精品美女| 91猫先生在线| 欧美精品一区二区三区视频| 亚洲一区二区三区视频在线| 国产一区二区精品在线观看|