2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #ifndef _RX_PROTOTYPES_H
11 #define _RX_PROTOTYPES_H
15 #ifndef AFS_PTHREAD_ENV
16 extern int (*registerProgram
) (PROCESS
, char *);
17 extern int (*swapNameProgram
) (PROCESS
, const char *, char *);
20 extern int (*rx_justReceived
) (struct rx_packet
*, struct sockaddr_in
*);
21 extern int (*rx_almostSent
) (struct rx_packet
*, struct sockaddr_in
*);
23 extern void rx_rto_setPeerTimeoutSecs(struct rx_peer
*, int secs
);
25 extern int rx_Init(u_int port
);
26 extern int rx_InitHost(u_int host
, u_int port
);
28 extern void rx_DebugOnOff(int on
);
29 extern void rx_StatsOnOff(int on
);
30 extern void rx_StartClientThread(void);
32 extern void rx_StartServer(int donateMe
);
33 extern struct rx_connection
*rx_NewConnection(afs_uint32 shost
,
34 u_short sport
, u_short sservice
,
35 struct rx_securityClass
37 int serviceSecurityIndex
);
38 extern void rx_SetConnDeadTime(struct rx_connection
*conn
,
40 extern void rx_SetConnHardDeadTime(struct rx_connection
*conn
, int seconds
);
41 extern void rx_SetConnIdleDeadTime(struct rx_connection
*conn
, int seconds
);
42 extern void rxi_DestroyConnection(struct rx_connection
*conn
);
43 extern void rx_GetConnection(struct rx_connection
*conn
);
44 extern void rx_DestroyConnection(struct rx_connection
*conn
);
45 extern struct rx_call
*rx_NewCall(struct rx_connection
*conn
);
46 extern int rxi_GetCallNumberVector(struct rx_connection
*aconn
,
48 extern int rxi_SetCallNumberVector(struct rx_connection
*aconn
,
50 extern struct rx_service
*rx_NewService(u_short port
, u_short serviceId
,
52 struct rx_securityClass
55 afs_int32(*serviceProc
) (struct
58 extern struct rx_service
*rx_NewServiceHost(afs_uint32 host
, u_short port
,
61 struct rx_securityClass
64 afs_int32(*serviceProc
) (struct
67 extern void rxi_ServerProc(int threadID
, struct rx_call
*newcall
,
68 osi_socket
* socketp
);
69 extern void rx_WakeupServerProcs(void);
70 extern struct rx_call
*rx_GetCall(int tno
, struct rx_service
*cur_service
,
71 osi_socket
* socketp
);
72 extern void rx_SetArrivalProc(struct rx_call
*call
,
73 void (*proc
) (struct rx_call
*
77 void * handle
, int arg
);
78 extern afs_int32
rx_EndCall(struct rx_call
*call
, afs_int32 rc
);
79 extern void rx_InterruptCall(struct rx_call
*call
, afs_int32 error
);
80 extern void rx_Finalize(void);
81 extern void *rxi_Alloc(size_t size
);
82 extern void rxi_Free(void *addr
, size_t size
);
83 extern void rxi_CallError(struct rx_call
*call
, afs_int32 error
);
84 extern void rx_SetConnSecondsUntilNatPing(struct rx_connection
*conn
,
86 extern int rxs_Release(struct rx_securityClass
*aobj
);
88 extern void rx_PrintTheseStats(FILE * file
, struct rx_statistics
*s
, int size
,
89 afs_int32 freePackets
, char version
);
90 extern void rx_PrintStats(FILE * file
);
91 extern void rx_PrintPeerStats(FILE * file
, struct rx_peer
*peer
);
93 extern afs_int32
rx_GetServerDebug(osi_socket socket
, afs_uint32 remoteAddr
,
94 afs_uint16 remotePort
,
95 struct rx_debugStats
*stat
,
96 afs_uint32
* supportedValues
);
97 extern afs_int32
rx_GetServerStats(osi_socket socket
, afs_uint32 remoteAddr
,
98 afs_uint16 remotePort
,
99 struct rx_statistics
*stat
,
100 afs_uint32
* supportedValues
);
101 extern afs_int32
rx_GetServerVersion(osi_socket socket
, afs_uint32 remoteAddr
,
102 afs_uint16 remotePort
,
103 size_t version_length
, char *version
);
104 extern afs_int32
rx_GetServerConnections(osi_socket socket
,
105 afs_uint32 remoteAddr
,
106 afs_uint16 remotePort
,
107 afs_int32
* nextConnection
,
109 afs_uint32 debugSupportedValues
,
110 struct rx_debugConn
*conn
,
111 afs_uint32
* supportedValues
);
112 extern afs_int32
rx_GetServerPeers(osi_socket socket
, afs_uint32 remoteAddr
,
113 afs_uint16 remotePort
,
114 afs_int32
* nextPeer
,
115 afs_uint32 debugSupportedValues
,
116 struct rx_debugPeer
*peer
,
117 afs_uint32
* supportedValues
);
118 extern afs_int32
rx_GetLocalPeers(afs_uint32 peerHost
, afs_uint16 peerPort
,
119 struct rx_debugPeer
* peerStats
);
120 extern void shutdown_rx(void);
122 extern int rx_KeyCreate(rx_destructor_t rtn
);
124 extern void rx_SetSpecific(struct rx_connection
*conn
, int key
, void *ptr
);
125 extern void *rx_GetSpecific(struct rx_connection
*conn
, int key
);
126 extern void rx_SetServiceSpecific(struct rx_service
*svc
, int key
, void *ptr
);
127 extern void * rx_GetServiceSpecific(struct rx_service
*svc
, int key
);
128 extern void rx_IncrementTimeAndCount(struct rx_peer
*peer
,
129 afs_uint32 rxInterface
,
130 afs_uint32 currentFunc
,
131 afs_uint32 totalFunc
,
132 struct clock
*queueTime
,
133 struct clock
*execTime
,
134 afs_hyper_t
* bytesSent
,
135 afs_hyper_t
* bytesRcvd
, int isServer
);
136 extern void rx_MarshallProcessRPCStats(afs_uint32 callerVersion
, int count
,
137 rx_function_entry_v1_t
* stats
,
139 extern int rx_RetrieveProcessRPCStats(afs_uint32 callerVersion
,
140 afs_uint32
* myVersion
,
141 afs_uint32
* clock_sec
,
142 afs_uint32
* clock_usec
,
144 afs_uint32
* statCount
,
145 afs_uint32
** stats
);
146 extern int rx_RetrievePeerRPCStats(afs_uint32 callerVersion
,
147 afs_uint32
* myVersion
,
148 afs_uint32
* clock_sec
,
149 afs_uint32
* clock_usec
,
150 size_t * allocSize
, afs_uint32
* statCount
,
151 afs_uint32
** stats
);
152 extern void rx_FreeRPCStats(afs_uint32
* stats
, size_t allocSize
);
153 extern int rx_queryProcessRPCStats(void);
154 extern int rx_queryPeerRPCStats(void);
155 extern void rx_enableProcessRPCStats(void);
156 extern void rx_enablePeerRPCStats(void);
157 extern void rx_disableProcessRPCStats(void);
158 extern void rx_disablePeerRPCStats(void);
159 extern void rx_clearProcessRPCStats(afs_uint32 clearFlag
);
160 extern void rx_clearPeerRPCStats(afs_uint32 clearFlag
);
161 extern void rx_SetRxStatUserOk(int (*proc
) (struct rx_call
* call
));
162 extern int rx_RxStatUserOk(struct rx_call
*call
);
163 extern void rx_ClearProcessRPCStats(afs_int32 rxInterface
);
164 extern void rx_ClearPeerRPCStats(afs_int32 rxInterface
, afs_uint32 peerHost
, afs_uint16 peerPort
);
165 extern void *rx_CopyProcessRPCStats(afs_uint64 op
);
166 extern void *rx_CopyPeerRPCStats(afs_uint64 op
, afs_uint32 peerHost
, afs_uint16 peerPort
);
167 extern void rx_ReleaseRPCStats(void *stats
);
168 extern afs_int32
rx_SetSecurityConfiguration(struct rx_service
*service
,
169 rx_securityConfigVariables type
,
171 extern int rx_GetThreadNum(void);
172 extern int rx_SetThreadNum(void);
174 void rxi_DebugInit(void);
175 void rxi_DebugPrint(char *format
, ...)
176 AFS_ATTRIBUTE_FORMAT(__printf__
, 1, 2);
178 extern int rx_GetNetworkError(struct rx_connection
*conn
, int *err_origin
,
179 int *err_type
, int *err_code
, const char **msg
);
182 #if !defined(clock_Init)
183 extern void clock_Init(void);
185 #if !defined(clock_UnInit)
186 extern int clock_UnInit(void);
188 #if !defined(clock_UpdateTime)
189 extern void clock_UpdateTime(void);
191 #if defined(UKERNEL) && !defined(osi_GetTime)
192 extern int osi_GetTime(struct timeval
*tv
);
199 extern void rxi_DeleteCachedConnections(void);
200 extern struct rx_connection
*rx_GetCachedConnection(unsigned int remoteAddr
,
202 unsigned short service
,
203 struct rx_securityClass
206 extern void rx_ReleaseCachedConnection(struct rx_connection
*conn
);
213 extern int rxevent_nFree
;
214 extern int rxevent_nPosted
;
215 extern struct rxevent
*rxevent_Post(struct clock
*when
, struct clock
*now
,
216 void (*func
) (struct rxevent
*, void *,
218 void *arg
, void *arg1
, int arg2
);
219 extern void shutdown_rxevent(void);
220 extern struct rxepoch
*rxepoch_Allocate(struct clock
*when
);
221 extern void rxevent_Init(int nEvents
, void (*scheduler
) (void));
222 extern int rxevent_RaiseEvents(struct clock
*next
);
228 extern void rxi_setaddr(afs_uint32 x
);
229 extern afs_uint32
rxi_getaddr(void);
230 extern int rx_getAllAddr(afs_uint32
* buffer
, int maxSize
);
231 extern int rx_getAllAddrMaskMtu(afs_uint32 addrBuffer
[],
232 afs_uint32 maskBuffer
[],
233 afs_uint32 mtuBuffer
[],
237 extern int rx_GetMaxReceiveWindow(void);
238 extern int rx_GetMaxSendWindow(void);
239 extern void rx_SetMaxReceiveWindow(int packets
);
240 extern void rx_SetMaxSendWindow(int packets
);
241 extern int rx_GetMinPeerTimeout(void);
242 extern void rx_SetMinPeerTimeout(int msecs
);
247 extern int (*rxk_PacketArrivalProc
) (struct rx_packet
* ahandle
,
248 struct sockaddr_in
* afrom
,
249 struct socket
*arock
,
251 extern int (*rxk_GetPacketProc
) (struct rx_packet
**ahandle
, int asize
);
252 extern afs_int32 afs_termState
;
253 extern int rxk_initDone
;
255 extern int rxk_DelPort(u_short aport
);
256 extern void rxk_shutdownPorts(void);
257 extern osi_socket
rxi_GetUDPSocket(u_short port
);
258 extern osi_socket
rxi_GetHostUDPSocket(u_int host
, u_short port
);
259 extern int osi_utoa(char *buf
, size_t len
, unsigned long val
);
260 extern void rxi_InitPeerParams(struct rx_peer
*pp
);
261 extern void shutdown_rxkernel(void);
262 # ifdef AFS_USERSPACE_IP_ADDR
263 extern int rxi_GetcbiInfo(void);
264 extern afs_int32
rxi_Findcbi(afs_uint32 addr
);
266 extern int rxi_GetIFInfo(void);
269 extern int rxk_FreeSocket(struct socket
*asocket
);
270 extern osi_socket
*rxk_NewSocket(short aport
);
272 extern int rxk_ReadPacket(osi_socket so
, struct rx_packet
*p
, int *host
,
275 extern void *rx_ServerProc(void *);
277 # ifndef AFS_LINUX26_ENV
278 extern void osi_AssertFailK(const char *expr
, const char *file
, int line
) AFS_NORETURN
;
280 extern void rxk_ListenerProc(void);
281 extern void rxk_Listener(void);
283 extern void afs_rxevent_daemon(void);
285 extern rx_ifnet_t
rxi_FindIfnet(afs_uint32 addr
, afs_uint32
* maskp
);
286 extern void osi_StopListener(void);
288 /* ARCH/rx_kmutex.c */
289 # if defined(AFS_LINUX20_ENV)
290 extern void afs_mutex_init(afs_kmutex_t
* l
);
291 extern void afs_mutex_enter(afs_kmutex_t
* l
);
292 extern int afs_mutex_tryenter(afs_kmutex_t
* l
);
293 extern void afs_mutex_exit(afs_kmutex_t
* l
);
294 extern int afs_cv_wait(afs_kcondvar_t
* cv
, afs_kmutex_t
* l
, int sigok
);
295 extern void afs_cv_timedwait(afs_kcondvar_t
* cv
, afs_kmutex_t
* l
,
302 # if !defined(AFS_SGI_ENV)
303 extern int osi_NetSend(osi_socket asocket
, struct sockaddr_in
*addr
,
304 struct iovec
*dvec
, int nvecs
, afs_int32 asize
,
307 # ifdef RXK_UPCALL_ENV
308 extern void rx_upcall(socket_t so
, void *arg
, __unused
int waitflag
);
310 extern int osi_NetReceive(osi_socket so
, struct sockaddr_in
*addr
,
311 struct iovec
*dvec
, int nvecs
, int *lengthp
);
313 # if defined(AFS_SUN510_ENV)
314 extern void osi_StartNetIfPoller(void);
315 extern void osi_NetIfPoller(void);
316 extern void osi_StopNetIfPoller(void);
317 extern struct afs_ifinfo afsifinfo
[ADDRSPERSITE
];
319 extern void osi_StopListener(void);
320 extern int rxi_FindIfMTU(afs_uint32 addr
);
321 # if defined(UKERNEL)
322 extern void rxi_ListenerProc(osi_socket usockp
, int *tnop
,
323 struct rx_call
**newcallp
);
326 # if !defined(RXK_LISTENER_ENV) && !defined(RXK_UPCALL_ENV)
327 extern void rxk_init(void);
330 /* UKERNEL/rx_knet.c */
332 extern void afs_rxevent_daemon(void);
337 extern void rxi_Sleep(void *addr
);
338 extern void rxi_Delay(int seconds
);
339 extern void rxi_InitializeThreadSupport(void);
340 extern void rxi_Wakeup(void *addr
);
341 extern void rxi_StopListener(void);
343 extern void rxi_ReScheduleEvents(void);
345 extern void rxi_InitializeThreadSupport(void);
346 extern void rxi_StartServerProc(void *(*proc
) (void *), int stacksize
);
347 extern void rxi_StartListener(void);
348 extern void *rx_ServerProc(void *);
349 extern int rxi_Listen(osi_socket sock
);
350 extern int rxi_Recvmsg(osi_socket socket
, struct msghdr
*msg_p
, int flags
);
351 extern int rxi_Sendmsg(osi_socket socket
, struct msghdr
*msg_p
, int flags
);
356 extern char *osi_alloc(afs_int32 x
);
359 extern int osi_free(char *x
, afs_int32 size
);
361 extern int hton_syserr_conv(afs_int32 code
);
362 extern int ntoh_syserr_conv(int code
);
366 extern struct multi_handle
*multi_Init(struct rx_connection
**conns
,
368 extern int multi_Select(struct multi_handle
*mh
);
369 extern void multi_Ready(struct rx_call
*call
,
370 void *mh
, int index
);
371 extern void multi_Finalize(struct multi_handle
*mh
);
372 extern void multi_Finalize_Ignore(struct multi_handle
*mh
);
377 extern struct rx_securityClass
*rxnull_NewServerSecurityObject(void);
378 extern struct rx_securityClass
*rxnull_NewClientSecurityObject(void);
382 extern afs_int32
rx_SlowGetInt32(struct rx_packet
*packet
, size_t offset
);
383 extern afs_int32
rx_SlowPutInt32(struct rx_packet
*packet
, size_t offset
,
385 extern afs_int32
rx_SlowReadPacket(struct rx_packet
*packet
,
386 unsigned int offset
, int resid
, char *out
);
387 extern afs_int32
rx_SlowWritePacket(struct rx_packet
*packet
, int offset
,
388 int resid
, char *in
);
389 extern int rxi_RoundUpPacket(struct rx_packet
*p
, unsigned int nb
);
390 extern int rxi_AllocDataBuf(struct rx_packet
*p
, int nb
, int cla_ss
);
391 extern void rxi_MorePackets(int apackets
);
392 #if defined(AFS_PTHREAD_ENV)
393 extern void rxi_MorePacketsTSFPQ(int apackets
, int flush_global
, int num_keep_local
); /* more flexible packet alloc function */
394 extern void rxi_FlushLocalPacketsTSFPQ(void); /* flush all thread-local packets to global queue */
396 extern void rxi_FreeAllPackets(void);
397 extern void rx_CheckPackets(void);
398 extern void rxi_RestoreDataBufs(struct rx_packet
*p
);
399 extern int rxi_TrimDataBufs(struct rx_packet
*p
, int first
);
400 extern void rxi_FreePacket(struct rx_packet
*p
);
401 extern struct rx_packet
*rxi_AllocPacket(int cla_ss
);
402 extern int rxi_AllocPackets(int cla_ss
, int num_pkts
, struct opr_queue
*q
);
403 extern int rxi_FreePackets(int num_pkts
, struct opr_queue
*q
);
404 extern struct rx_packet
*rxi_AllocSendPacket(struct rx_call
*call
,
406 extern int rxi_ReadPacket(osi_socket socket
, struct rx_packet
*p
,
407 afs_uint32
* host
, u_short
* port
);
408 extern struct rx_packet
*rxi_SplitJumboPacket(struct rx_packet
*p
,
409 afs_uint32 host
, short port
,
412 extern int osi_NetSend(osi_socket socket
, void *addr
, struct iovec
*dvec
,
413 int nvecs
, int length
, int istack
);
415 extern struct rx_packet
*rxi_ReceiveDebugPacket(struct rx_packet
*ap
,
417 afs_uint32 ahost
, short aport
,
419 extern struct rx_packet
*rxi_ReceiveVersionPacket(struct rx_packet
420 *ap
, osi_socket asocket
,
422 short aport
, int istack
);
423 extern void rxi_SendPacket(struct rx_call
*call
, struct rx_connection
*conn
,
424 struct rx_packet
*p
, int istack
);
425 extern void rxi_SendPacketList(struct rx_call
*call
,
426 struct rx_connection
*conn
,
427 struct rx_packet
**list
, int len
, int istack
);
428 extern void rxi_SendRawAbort(osi_socket socket
, afs_uint32 host
, u_short port
,
429 afs_int32 error
, struct rx_packet
*source
,
431 extern struct rx_packet
*rxi_SendSpecial(struct rx_call
*call
,
432 struct rx_connection
*conn
,
433 struct rx_packet
*optionalPacket
,
434 int type
, char *data
, int nbytes
,
436 extern void rxi_EncodePacketHeader(struct rx_packet
*p
);
437 extern void rxi_DecodePacketHeader(struct rx_packet
*p
);
438 extern void rxi_PrepareSendPacket(struct rx_call
*call
,
441 extern int rxi_AdjustIfMTU(int mtu
);
442 extern int rxi_AdjustMaxMTU(int mtu
, int peerMaxMTU
);
443 extern int rxi_AdjustDgramPackets(int frags
, int mtu
);
449 extern int rx_NewThreadId(void);
450 extern void rxi_Delay(int sec
);
451 extern void rxi_InitializeThreadSupport(void);
452 extern void rxi_StartServerProc(void *(*proc
) (void *), int stacksize
);
453 #ifndef rxi_ReScheduleEvents
454 extern void rxi_ReScheduleEvents(void);
456 extern void *rx_ServerProc(void *);
457 extern void rxi_StartListener(void);
458 extern int rxi_Listen(osi_socket sock
);
459 extern int rxi_Recvmsg(osi_socket socket
, struct msghdr
*msg_p
, int flags
);
460 extern int rxi_Sendmsg(osi_socket socket
, struct msghdr
*msg_p
, int flags
);
463 extern int rxi_ReadProc(struct rx_call
*call
, char *buf
,
465 extern int rx_ReadProc(struct rx_call
*call
, char *buf
, int nbytes
);
466 extern int rx_ReadProc32(struct rx_call
*call
, afs_int32
* value
);
467 extern int rxi_FillReadVec(struct rx_call
*call
, afs_uint32 serial
);
468 extern int rxi_ReadvProc(struct rx_call
*call
, struct iovec
*iov
, int *nio
,
469 int maxio
, int nbytes
);
470 extern int rx_ReadvProc(struct rx_call
*call
, struct iovec
*iov
, int *nio
,
471 int maxio
, int nbytes
);
472 extern int rxi_WriteProc(struct rx_call
*call
, char *buf
,
474 extern int rx_WriteProc(struct rx_call
*call
, char *buf
, int nbytes
);
475 extern int rx_WriteProc32(struct rx_call
*call
,
477 extern int rx_WritevAlloc(struct rx_call
*call
, struct iovec
*iov
, int *nio
,
478 int maxio
, int nbytes
);
479 extern int rxi_WritevProc(struct rx_call
*call
, struct iovec
*iov
, int nio
,
481 extern int rx_WritevProc(struct rx_call
*call
, struct iovec
*iov
, int nio
,
483 extern void rxi_FlushWrite(struct rx_call
*call
);
484 extern void rxi_FlushWriteLocked(struct rx_call
*call
);
485 extern void rx_FlushWrite(struct rx_call
*call
);
490 extern struct rx_statistics
* rx_GetStatistics(void);
491 extern void rx_FreeStatistics(struct rx_statistics
**);
497 #ifdef AFS_PTHREAD_ENV
498 extern afs_kmutex_t rx_if_init_mutex
;
499 extern afs_kmutex_t rx_if_mutex
;
501 extern osi_socket
rxi_GetUDPSocket(u_short port
);
502 extern void rxi_InitPeerParams(struct rx_peer
*pp
);
503 extern int rxi_HandleSocketError(int socket
);
505 #if defined(AFS_AIX32_ENV) && !defined(KERNEL)
507 extern void *osi_Alloc(afs_int32 x
);
510 extern void osi_Free(void *x
, afs_int32 size
);
512 #endif /* defined(AFS_AIX32_ENV) && !defined(KERNEL) */
514 extern void osi_Panic(char *fmt
, ...) AFS_NORETURN
;
517 extern void rx_GetIFInfo(void);
518 extern void rx_SetNoJumbo(void);
519 extern int rx_SetMaxMTU(int mtu
);
524 /* MISC PROTOTYPES - MOVE TO APPROPRIATE LOCATION LATER */
526 /* EXTERNAL PROTOTYPES - include here cause it causes too many issues to
527 include the afs_prototypes.h file - just make sure they match */
528 #ifndef afs_osi_Alloc
529 extern void *afs_osi_Alloc(size_t x
);
532 extern void afs_osi_Free(void *x
, size_t asize
);
534 #ifndef afs_osi_Wakeup
535 extern int afs_osi_Wakeup(void *event
);
537 #ifndef afs_osi_Sleep
538 extern void afs_osi_Sleep(void *event
);
540 extern unsigned int afs_random(void);
541 extern void osi_linux_rxkreg(void);
543 #endif /* _RX_PROTOTYPES_H */