Annotation of embedaddon/ntp/include/recvbuff.h, revision 1.1

1.1     ! misho       1: #ifndef RECVBUFF_H
        !             2: #define RECVBUFF_H
        !             3: 
        !             4: #ifdef HAVE_CONFIG_H
        !             5: # include <config.h>
        !             6: #endif
        !             7: 
        !             8: #include "ntp.h"
        !             9: #include "ntp_fp.h"
        !            10: #include "ntp_lists.h"
        !            11: 
        !            12: #include <isc/result.h>
        !            13: 
        !            14: /*
        !            15:  * recvbuf memory management
        !            16:  */
        !            17: #define RECV_INIT      10      /* 10 buffers initially */
        !            18: #define RECV_LOWAT     3       /* when we're down to three buffers get more */
        !            19: #define RECV_INC       5       /* get 5 more at a time */
        !            20: #define RECV_TOOMANY   40      /* this is way too many buffers */
        !            21: 
        !            22: #if defined HAVE_IO_COMPLETION_PORT
        !            23: # include "ntp_iocompletionport.h"
        !            24: #include "ntp_timer.h"
        !            25: 
        !            26: # define RECV_BLOCK_IO()       EnterCriticalSection(&RecvCritSection)
        !            27: # define RECV_UNBLOCK_IO()     LeaveCriticalSection(&RecvCritSection)
        !            28: 
        !            29: /*  Return the event which is set when items are added to the full list
        !            30:  */
        !            31: extern HANDLE  get_recv_buff_event (void);
        !            32: #else
        !            33: # define RECV_BLOCK_IO()       
        !            34: # define RECV_UNBLOCK_IO()     
        !            35: #endif
        !            36: 
        !            37: 
        !            38: /*
        !            39:  * Format of a recvbuf.  These are used by the asynchronous receive
        !            40:  * routine to store incoming packets and related information.
        !            41:  */
        !            42: 
        !            43: /*
        !            44:  *  the maximum length NTP packet contains the NTP header, one Autokey
        !            45:  *  request, one Autokey response and the MAC. Assuming certificates don't
        !            46:  *  get too big, the maximum packet length is set arbitrarily at 1000.
        !            47:  */   
        !            48: #define        RX_BUFF_SIZE    1000            /* hail Mary */
        !            49: 
        !            50: 
        !            51: typedef struct recvbuf recvbuf_t;
        !            52: 
        !            53: struct recvbuf {
        !            54:        ISC_LINK(recvbuf_t)     link;   /* next in list */
        !            55:        union {
        !            56:                sockaddr_u X_recv_srcadr;
        !            57:                caddr_t X_recv_srcclock;
        !            58:                struct peer *X_recv_peer;
        !            59:        } X_from_where;
        !            60: #define recv_srcadr    X_from_where.X_recv_srcadr
        !            61: #define        recv_srcclock   X_from_where.X_recv_srcclock
        !            62: #define recv_peer      X_from_where.X_recv_peer
        !            63: #ifndef HAVE_IO_COMPLETION_PORT
        !            64:        sockaddr_u srcadr;              /* where packet came from */
        !            65: #else
        !            66:        int recv_srcadr_len;            /* filled in on completion */
        !            67: #endif
        !            68:        endpt * dstadr;                 /* address pkt arrived on */
        !            69:        SOCKET  fd;                     /* fd on which it was received */
        !            70:        int msg_flags;                  /* Flags received about the packet */
        !            71:        l_fp recv_time;                 /* time of arrival */
        !            72:        void (*receiver) (struct recvbuf *); /* routine to receive buffer */
        !            73:        int recv_length;                /* number of octets received */
        !            74:        union {
        !            75:                struct pkt X_recv_pkt;
        !            76:                u_char X_recv_buffer[RX_BUFF_SIZE];
        !            77:        } recv_space;
        !            78: #define        recv_pkt        recv_space.X_recv_pkt
        !            79: #define        recv_buffer     recv_space.X_recv_buffer
        !            80:        int used;                       /* reference count */
        !            81: };
        !            82: 
        !            83: extern void    init_recvbuff   (int);
        !            84: 
        !            85: /* freerecvbuf - make a single recvbuf available for reuse
        !            86:  */
        !            87: extern void    freerecvbuf (struct recvbuf *);
        !            88: 
        !            89: /*  Get a free buffer (typically used so an async
        !            90:  *  read can directly place data into the buffer
        !            91:  *
        !            92:  *  The buffer is removed from the free list. Make sure
        !            93:  *  you put it back with freerecvbuf() or 
        !            94:  */
        !            95: extern struct recvbuf *get_free_recv_buffer (void); /* signal safe - no malloc */
        !            96: extern struct recvbuf *get_free_recv_buffer_alloc (void); /* signal unsafe - may malloc */
        !            97: 
        !            98: /*   Add a buffer to the full list
        !            99:  */
        !           100: extern void    add_full_recv_buffer     (struct recvbuf *);
        !           101: 
        !           102: /*extern       void    process_recv_buffers     (void); */
        !           103: 
        !           104: /* number of recvbufs on freelist */
        !           105: extern u_long free_recvbuffs (void);           
        !           106: extern u_long full_recvbuffs (void);           
        !           107: extern u_long total_recvbuffs (void);
        !           108: extern u_long lowater_additions (void);
        !           109:                
        !           110: /*  Returns the next buffer in the full list.
        !           111:  *
        !           112:  */
        !           113: extern struct recvbuf *get_full_recv_buffer (void);
        !           114: 
        !           115: /*
        !           116:  * Checks to see if there are buffers to process
        !           117:  */
        !           118: extern isc_boolean_t has_full_recv_buffer (void);
        !           119: 
        !           120: #endif /* RECVBUFF_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>