1 #if !defined __recvbuff_h
10 #include "ntp_types.h"
13 #include <isc/result.h>
16 * recvbuf memory management
18 #define RECV_INIT 10 /* 10 buffers initially */
19 #define RECV_LOWAT 3 /* when we're down to three buffers get more */
20 #define RECV_INC 5 /* get 5 more at a time */
21 #define RECV_TOOMANY 40 /* this is way too many buffers */
23 #if defined HAVE_IO_COMPLETION_PORT
24 # include "ntp_iocompletionport.h"
25 #include "ntp_timer.h"
27 # define RECV_BLOCK_IO() EnterCriticalSection(&RecvCritSection)
28 # define RECV_UNBLOCK_IO() LeaveCriticalSection(&RecvCritSection)
30 /* Return the event which is set when items are added to the full list
32 extern HANDLE get_recv_buff_event P((void));
34 # define RECV_BLOCK_IO()
35 # define RECV_UNBLOCK_IO()
40 * Format of a recvbuf. These are used by the asynchronous receive
41 * routine to store incoming packets and related information.
45 * the maximum length NTP packet contains the NTP header, one Autokey
46 * request, one Autokey response and the MAC. Assuming certificates don't
47 * get too big, the maximum packet length is set arbitrarily at 1000.
49 #define RX_BUFF_SIZE 1000 /* hail Mary */
52 typedef struct recvbuf recvbuf_t;
55 ISC_LINK(recvbuf_t) link;
57 struct sockaddr_storage X_recv_srcadr;
58 caddr_t X_recv_srcclock;
59 struct peer *X_recv_peer;
61 #define recv_srcadr X_from_where.X_recv_srcadr
62 #define recv_srcclock X_from_where.X_recv_srcclock
63 #define recv_peer X_from_where.X_recv_peer
64 #if defined HAVE_IO_COMPLETION_PORT
67 struct sockaddr_storage srcadr; /* where packet came from */
69 int src_addr_len; /* source address length */
70 struct interface *dstadr; /* interface datagram arrived thru */
71 SOCKET fd; /* fd on which it was received */
72 int msg_flags; /* Flags received about the packet */
73 l_fp recv_time; /* time of arrival */
74 void (*receiver) P((struct recvbuf *)); /* routine to receive buffer */
75 int recv_length; /* number of octets received */
77 struct pkt X_recv_pkt;
78 u_char X_recv_buffer[RX_BUFF_SIZE];
81 #define recv_pkt recv_space.X_recv_pkt
82 #define recv_buffer recv_space.X_recv_buffer
85 extern void init_recvbuff P((int));
87 /* freerecvbuf - make a single recvbuf available for reuse
89 extern void freerecvbuf P((struct recvbuf *));
91 /* Get a free buffer (typically used so an async
92 * read can directly place data into the buffer
94 * The buffer is removed from the free list. Make sure
95 * you put it back with freerecvbuf() or
97 extern struct recvbuf *get_free_recv_buffer P((void)); /* signal safe - no malloc */
98 extern struct recvbuf *get_free_recv_buffer_alloc P((void)); /* signal unsafe - may malloc */
100 /* Add a buffer to the full list
102 extern void add_full_recv_buffer P((struct recvbuf *));
104 /*extern void process_recv_buffers P((void)); */
106 /* number of recvbufs on freelist */
107 extern u_long free_recvbuffs P((void));
108 extern u_long full_recvbuffs P((void));
109 extern u_long total_recvbuffs P((void));
110 extern u_long lowater_additions P((void));
112 /* Returns the next buffer in the full list.
115 extern struct recvbuf *get_full_recv_buffer P((void));
118 * Checks to see if there are buffers to process
120 extern isc_boolean_t has_full_recv_buffer P((void));
122 #endif /* defined __recvbuff_h */