0472a86a2ad35fe16f34a98b6404272b1c8e049a
[openafs.git] / src / rx / rx_user.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 /* rx_user.c contains routines specific to the user space UNIX implementation of rx */
11
12 #include <afsconfig.h>
13 #include <afs/param.h>
14
15 RCSID("$Header$");
16
17 # include <sys/types.h>
18 # include <errno.h>
19 # include <signal.h>
20 #ifdef AFS_NT40_ENV
21 # include <WINNT/syscfg.h>
22 #else
23 # include <sys/socket.h>
24 # include <sys/file.h>
25 # include <netdb.h>
26 # include <sys/stat.h>
27 # include <netinet/in.h>
28 # include <sys/time.h>
29 # include <net/if.h>
30 # include <sys/ioctl.h>
31 #endif
32 # include <fcntl.h>
33 #if !defined(AFS_AIX_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
34 # include <sys/syscall.h>
35 #endif
36 #include <afs/afs_args.h>
37 #include <afs/afsutil.h>
38 #ifdef HAVE_STRING_H
39 #include <string.h>
40 #else
41 #ifdef HAVE_STRINGS_H
42 #include <strings.h>
43 #endif
44 #endif
45
46 #ifndef IPPORT_USERRESERVED
47 /* If in.h doesn't define this, define it anyway.  Unfortunately, defining
48    this doesn't put the code into the kernel to restrict kernel assigned
49    port numbers to numbers below IPPORT_USERRESERVED...  */
50 #define IPPORT_USERRESERVED 5000
51 # endif
52
53 #ifndef AFS_NT40_ENV
54 # include <sys/time.h>
55 #endif
56 # include "rx.h"
57 # include "rx_globals.h"
58
59 #ifdef AFS_PTHREAD_ENV
60 #include <assert.h>
61
62 /*
63  * The rx_if_init_mutex mutex protects the following global variables:
64  * Inited
65  */
66
67 pthread_mutex_t rx_if_init_mutex;
68 #define LOCK_IF_INIT assert(pthread_mutex_lock(&rx_if_init_mutex)==0);
69 #define UNLOCK_IF_INIT assert(pthread_mutex_unlock(&rx_if_init_mutex)==0);
70
71 /*
72  * The rx_if_mutex mutex protects the following global variables:
73  * myNetFlags
74  * myNetMTUs
75  * myNetMasks
76  */
77
78 pthread_mutex_t rx_if_mutex;
79 #define LOCK_IF assert(pthread_mutex_lock(&rx_if_mutex)==0);
80 #define UNLOCK_IF assert(pthread_mutex_unlock(&rx_if_mutex)==0);
81 #else
82 #define LOCK_IF_INIT
83 #define UNLOCK_IF_INIT
84 #define LOCK_IF
85 #define UNLOCK_IF
86 #endif /* AFS_PTHREAD_ENV */
87
88
89 /*
90  * Make a socket for receiving/sending IP packets.  Set it into non-blocking
91  * and large buffering modes.  If port isn't specified, the kernel will pick
92  * one.  Returns the socket (>= 0) on success.  Returns OSI_NULLSOCKET on
93  * failure. Port must be in network byte order. 
94  */
95 osi_socket rxi_GetUDPSocket(u_short port)
96 {
97     int binds, code=0;
98     osi_socket socketFd = OSI_NULLSOCKET;
99     struct sockaddr_in taddr;
100     char *name = "rxi_GetUDPSocket: ";
101     int greedy=0;
102
103 #if !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
104     if (ntohs(port) >= IPPORT_RESERVED && ntohs(port) < IPPORT_USERRESERVED) {
105 /*      (osi_Msg "%s*WARNING* port number %d is not a reserved port number.  Use port numbers above %d\n", name, port, IPPORT_USERRESERVED);
106 */ ;
107     }
108     if (ntohs(port) > 0 && ntohs(port) < IPPORT_RESERVED && geteuid() != 0) {
109         (osi_Msg "%sport number %d is a reserved port number which may only be used by root.  Use port numbers above %d\n", name, ntohs(port), IPPORT_USERRESERVED);
110         goto error;
111     }
112 #endif
113     socketFd = socket(AF_INET, SOCK_DGRAM, 0);
114
115     if (socketFd < 0) {
116         perror("socket");
117         goto error;
118     }
119
120     taddr.sin_addr.s_addr = 0;
121     taddr.sin_family = AF_INET;
122     taddr.sin_port = (u_short)port;
123 #define MAX_RX_BINDS 10
124     for (binds=0; binds<MAX_RX_BINDS; binds++) {
125       if (binds) rxi_Delay (10);
126       code = bind(socketFd, (struct sockaddr *) &taddr, sizeof(taddr));
127       if (!code) break;
128     }
129     if (code) {
130       perror("bind");
131       (osi_Msg "%sbind failed\n", name);
132       goto error;
133     }
134
135 #if !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
136     /*
137      * Set close-on-exec on rx socket 
138      */
139     fcntl(socketFd, F_SETFD, 1);
140 #endif
141
142     /* Use one of three different ways of getting a socket buffer expanded to
143      * a reasonable size.
144      */
145     {
146         int len1, len2;
147
148         len1 = 32766;
149         len2 = rx_UdpBufSize;
150 #ifndef AFS_DJGPP_ENV
151         greedy = 
152           (setsockopt(socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2,
153                       sizeof(len2)) >= 0);
154         if (!greedy) {
155           len2=32766;  /* fall back to old size... uh-oh! */
156         }
157
158         greedy =
159           (setsockopt(socketFd, SOL_SOCKET, SO_SNDBUF, (char *)&len1,
160                       sizeof(len1)) >= 0) &&
161           (setsockopt(socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2,
162                       sizeof(len2)) >= 0);
163 #endif /* AFS_DJGPP_ENV */
164     }
165
166 #ifndef AFS_DJGPP_ENV
167     if (!greedy)
168         (osi_Msg "%s*WARNING* Unable to increase buffering on socket\n", name);
169 #endif /* AFS_DJGPP_ENV */
170     if (rxi_Listen(socketFd) < 0) {
171         goto error;
172     }
173
174     return socketFd;
175
176 error:
177 #ifdef AFS_NT40_ENV
178     if (socketFd >= 0) closesocket(socketFd);
179 #else
180     if (socketFd >= 0) close(socketFd);
181 #endif
182
183     MUTEX_ENTER(&rx_stats_mutex);
184     rx_stats.socketGreedy = greedy;
185     MUTEX_EXIT(&rx_stats_mutex);
186     return OSI_NULLSOCKET;
187 }
188
189 void osi_Panic(msg, a1, a2, a3)
190     char *msg;
191 {
192     (osi_Msg "Fatal Rx error: ");
193     (osi_Msg msg, a1, a2, a3);
194     fflush(stderr);
195     fflush(stdout);
196     afs_abort();
197 }
198
199 /*
200  * osi_AssertFailU() -- used by the osi_Assert() macro.
201  */
202
203 void osi_AssertFailU(const char *expr, const char *file, int line)
204 {
205     osi_Panic("assertion failed: %s, file: %s, line: %d\n", expr, file, line);
206 }
207
208 #ifdef  AFS_AIX32_ENV
209 #ifndef osi_Alloc
210 static const char memZero;
211 char * osi_Alloc(x)
212     afs_int32 x; 
213 {
214     /* 
215      * 0-length allocs may return NULL ptr from osi_kalloc, so we special-case
216      * things so that NULL returned iff an error occurred 
217      */
218     if (x == 0) return &memZero;
219     return ((char *) malloc(x));
220 }
221
222 osi_Free(x, size)
223     char *x;
224     afs_int32 size; 
225 {
226     if (x == &memZero) return;
227     free((char *)x);
228 }
229 #endif
230 #endif /* AFS_AIX32_ENV */
231
232 #define ADDRSPERSITE    16
233
234
235 afs_uint32 rxi_NetAddrs[ADDRSPERSITE]; /* host order */
236 static int myNetMTUs[ADDRSPERSITE];
237 static int myNetMasks[ADDRSPERSITE];
238 static int myNetFlags[ADDRSPERSITE];
239 u_int rxi_numNetAddrs;
240 static int Inited = 0;
241
242 #if defined(AFS_NT40_ENV) || defined(AFS_DJGPP_ENV)
243 int rxi_getaddr(void)
244 {
245     if (rxi_numNetAddrs > 0)
246         return htonl(rxi_NetAddrs[0]);
247     else
248         return 0;
249 }
250
251 /* 
252 ** return number of addresses 
253 ** and the addresses themselves in the buffer
254 ** maxSize - max number of interfaces to return.
255 */
256 int rx_getAllAddr (afs_int32 *buffer, int maxSize)
257 {
258     int count = 0;
259     for (count = 0; count < rxi_numNetAddrs && maxSize > 0; count++, maxSize--)
260         buffer[count] = htonl(rxi_NetAddrs[count]);
261
262     return count;
263 }
264
265 #endif
266
267 #ifdef AFS_NT40_ENV
268
269 void rx_GetIFInfo(void)
270 {
271     LOCK_IF_INIT
272     if (Inited) {
273         UNLOCK_IF_INIT
274         return;
275     }
276     else {
277         u_int maxsize;
278         u_int rxsize;
279         int npackets, ncbufs;
280         afs_uint32 i;
281
282         Inited = 1;
283         UNLOCK_IF_INIT
284         rxi_numNetAddrs = ADDRSPERSITE;
285
286         LOCK_IF
287         (void) syscfg_GetIFInfo(&rxi_numNetAddrs, rxi_NetAddrs,
288                                 myNetMasks, myNetMTUs, myNetFlags);
289
290         for (i=0; i<rxi_numNetAddrs; i++) {
291             rxsize = rxi_AdjustIfMTU(myNetMTUs[i] - RX_IPUDP_SIZE);
292             maxsize = rxi_nRecvFrags*rxsize + (rxi_nRecvFrags-1)*UDP_HDR_SIZE;
293             maxsize = rxi_AdjustMaxMTU(rxsize, maxsize);
294             if (rx_maxReceiveSize < maxsize)  {
295                 rx_maxReceiveSize = MIN( RX_MAX_PACKET_SIZE, maxsize);
296                 rx_maxReceiveSize = MIN( rx_maxReceiveSize,
297                                          rx_maxReceiveSizeUser);
298             }
299
300         }
301         UNLOCK_IF
302         ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
303         if (ncbufs > 0) {
304             ncbufs = ncbufs / RX_CBUFFERSIZE;
305             npackets = rx_initSendWindow -1;
306             rxi_MorePackets(npackets*(ncbufs+1));
307         }
308     }
309 }
310     
311 #endif
312
313 static afs_uint32 fudge_netmask(addr) 
314 afs_uint32 addr;
315 {
316 afs_uint32 msk;
317
318     if (IN_CLASSA(addr)) msk = IN_CLASSA_NET;
319     else if (IN_CLASSB(addr)) msk = IN_CLASSB_NET;
320     else if (IN_CLASSC(addr)) msk = IN_CLASSC_NET;
321     else msk = 0;
322
323 return msk;
324 }
325
326
327
328 #if !defined(AFS_AIX_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DJGPP_ENV)
329 int rxi_syscall(a3, a4, a5)
330 afs_uint32 a3, a4;
331 void * a5;
332 {
333   afs_uint32 rcode;
334   void (*old)();
335         
336   old = (void (*)())signal(SIGSYS, SIG_IGN);    
337
338 #if defined(AFS_SGI_ENV)
339   rcode = afs_syscall(a3, a4, a5);
340 #else
341   rcode = syscall (AFS_SYSCALL, 28 /* AFSCALL_CALL */, a3, a4, a5);
342 #endif /* AFS_SGI_ENV */
343
344   signal(SIGSYS, old);  
345
346 return rcode;
347 }
348 #endif /* AFS_AIX_ENV */
349
350 #ifndef AFS_NT40_ENV
351 void rx_GetIFInfo()
352 {
353     int     s;
354     int     i, j, len, res;
355 #ifndef AFS_DJGPP_ENV
356     struct ifconf   ifc;
357     struct ifreq    ifs[ADDRSPERSITE];
358     struct ifreq *ifr;
359 #ifdef  AFS_AIX41_ENV
360     char buf[BUFSIZ], *cp, *cplim;
361 #endif
362     struct sockaddr_in *a;
363 #endif /* AFS_DJGPP_ENV */
364
365     LOCK_IF_INIT
366     if (Inited) {
367       UNLOCK_IF_INIT
368       return;
369     }
370     Inited = 1;
371     UNLOCK_IF_INIT
372
373     LOCK_IF
374     rxi_numNetAddrs = 0;
375     memset(rxi_NetAddrs, 0, sizeof(rxi_NetAddrs));
376     memset(myNetFlags, 0, sizeof(myNetFlags));
377     memset(myNetMTUs, 0, sizeof(myNetMTUs));
378     memset(myNetMasks, 0, sizeof(myNetMasks));
379     UNLOCK_IF
380
381     s = socket(AF_INET, SOCK_DGRAM, 0);
382     if (s < 0) return;
383
384 #ifndef AFS_DJGPP_ENV
385 #ifdef  AFS_AIX41_ENV
386     ifc.ifc_len = sizeof (buf);
387     ifc.ifc_buf = buf;
388     ifr = ifc.ifc_req;
389 #else
390     ifc.ifc_len = sizeof(ifs);
391     ifc.ifc_buf = (caddr_t) &ifs[0];
392     memset(&ifs[0], 0, sizeof(ifs));
393 #endif 
394     res = ioctl(s, SIOCGIFCONF, &ifc);
395     if (res < 0) {
396       /* fputs(stderr, "ioctl error IFCONF\n"); */
397       close(s);
398       return;
399     }
400
401     LOCK_IF
402
403 #ifdef  AFS_AIX41_ENV
404 #define size(p) MAX((p).sa_len, sizeof(p))
405     cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
406     for (cp = buf; cp < cplim ;
407          cp += sizeof(ifr->ifr_name) + MAX(a->sin_len, sizeof(*a))) {
408         if (rxi_numNetAddrs >= ADDRSPERSITE)
409             break;
410
411         ifr = (struct ifreq *)cp;
412 #else
413     len = ifc.ifc_len / sizeof(struct ifreq);
414     if (len > ADDRSPERSITE)
415       len = ADDRSPERSITE;
416
417     for (i = 0; i < len; ++i) {
418         ifr = &ifs[i];
419         res = ioctl(s, SIOCGIFADDR, ifr);
420 #endif
421         if (res < 0) {
422           /* fputs(stderr, "ioctl error IFADDR\n");
423             perror(ifr->ifr_name);   */
424           continue;
425         }
426         a = (struct sockaddr_in *) &ifr->ifr_addr;
427         if (a->sin_family != AF_INET) continue;
428         rxi_NetAddrs[rxi_numNetAddrs] = ntohl(a->sin_addr.s_addr);
429         if (rxi_NetAddrs[rxi_numNetAddrs] == 0x7f000001) {
430           /* we don't really care about "localhost" */
431           continue;
432         }
433         for (j=0; j < rxi_numNetAddrs; j++) {
434            if (rxi_NetAddrs[j] == rxi_NetAddrs[rxi_numNetAddrs])
435               break;
436         }
437         if (j < rxi_numNetAddrs) continue;
438
439         /* fprintf(stderr, "if %s addr=%x\n", ifr->ifr_name,
440                 rxi_NetAddrs[rxi_numNetAddrs]); */
441
442 #ifdef SIOCGIFFLAGS
443         res = ioctl(s, SIOCGIFFLAGS, ifr);
444         if (res == 0) {
445             myNetFlags[rxi_numNetAddrs] = ifr->ifr_flags;
446 #ifdef IFF_LOOPBACK
447             /* Handle aliased loopbacks as well. */
448             if (ifr->ifr_flags & IFF_LOOPBACK)
449                 continue;
450 #endif
451             /* fprintf(stderr, "if %s flags=%x\n", 
452                     ifr->ifr_name, ifr->ifr_flags); */
453         }
454         else { /*
455           fputs(stderr, "ioctl error IFFLAGS\n");
456           perror(ifr->ifr_name); */
457         }
458 #endif /* SIOCGIFFLAGS */
459
460 #if !defined(AFS_AIX_ENV)  && !defined(AFS_LINUX20_ENV)
461         /* this won't run on an AIX system w/o a cache manager */
462         rxi_syscallp = rxi_syscall;
463 #endif
464
465         /* If I refer to kernel extensions that aren't loaded on AIX, the 
466          * program refuses to load and run, so I simply can't include the 
467          * following code.  Fortunately, AIX is the one operating system in
468          * which the subsequent ioctl works reliably. */
469         if (rxi_syscallp) {
470           if ((*rxi_syscallp)( 20 /*AFSOP_GETMTU*/,  
471                               htonl(rxi_NetAddrs[rxi_numNetAddrs]),
472                               &(myNetMTUs[rxi_numNetAddrs]))) {
473             /* fputs(stderr, "syscall error GETMTU\n");
474                perror(ifr->ifr_name); */
475             myNetMTUs[rxi_numNetAddrs] = 0;
476           }
477           if ((*rxi_syscallp)(42 /*AFSOP_GETMASK*/,  
478                               htonl(rxi_NetAddrs[rxi_numNetAddrs]),
479                               &(myNetMasks[rxi_numNetAddrs]))) {
480             /* fputs(stderr, "syscall error GETMASK\n");
481                perror(ifr->ifr_name); */
482             myNetMasks[rxi_numNetAddrs] = 0;
483           }
484           else myNetMasks[rxi_numNetAddrs] = ntohl( myNetMasks[rxi_numNetAddrs]);
485            /* fprintf(stderr, "if %s mask=0x%x\n", 
486              ifr->ifr_name, myNetMasks[rxi_numNetAddrs]);*/
487         }
488
489         if (myNetMTUs[rxi_numNetAddrs] == 0) {
490           myNetMTUs[rxi_numNetAddrs] = OLD_MAX_PACKET_SIZE + RX_IPUDP_SIZE;
491 #ifdef SIOCGIFMTU
492           res = ioctl(s, SIOCGIFMTU, ifr);
493           if ((res == 0) && (ifr->ifr_metric > 128))  { /* sanity check */
494             myNetMTUs[rxi_numNetAddrs] = ifr->ifr_metric;
495             /* fprintf(stderr, "if %s mtu=%d\n", 
496                     ifr->ifr_name, ifr->ifr_metric); */
497           }
498           else {
499             /* fputs(stderr, "ioctl error IFMTU\n");
500                perror(ifr->ifr_name); */
501           }
502 #endif
503         }
504
505         if (myNetMasks[rxi_numNetAddrs] == 0) {
506           myNetMasks[rxi_numNetAddrs] = fudge_netmask(rxi_NetAddrs[rxi_numNetAddrs]);
507 #ifdef SIOCGIFNETMASK
508           res = ioctl(s, SIOCGIFNETMASK, ifr);
509           if ((res == 0)) {
510             a = (struct sockaddr_in *) &ifr->ifr_addr;
511             myNetMasks[rxi_numNetAddrs] = ntohl(a->sin_addr.s_addr);
512             /* fprintf(stderr, "if %s subnetmask=0x%x\n", 
513                     ifr->ifr_name, myNetMasks[rxi_numNetAddrs]); */
514           }
515           else {
516             /* fputs(stderr, "ioctl error IFMASK\n");
517                perror(ifr->ifr_name); */
518           }
519 #endif
520         }
521
522         if (rxi_NetAddrs[rxi_numNetAddrs] != 0x7f000001) { /* ignore lo0 */
523            int maxsize;
524            maxsize = rxi_nRecvFrags*(myNetMTUs[rxi_numNetAddrs] - RX_IP_SIZE);
525            maxsize -= UDP_HDR_SIZE; /* only the first frag has a UDP hdr */
526            if (rx_maxReceiveSize < maxsize) 
527                 rx_maxReceiveSize = MIN( RX_MAX_PACKET_SIZE, maxsize);
528            ++rxi_numNetAddrs;
529         }
530     }
531     UNLOCK_IF
532     close(s);
533
534     /* have to allocate at least enough to allow a single packet to reach its
535      * maximum size, so ReadPacket will work.  Allocate enough for a couple
536      * of packets to do so, for good measure */
537     {
538       int npackets, ncbufs;
539
540       rx_maxJumboRecvSize = RX_HEADER_SIZE
541                             + rxi_nDgramPackets * RX_JUMBOBUFFERSIZE
542                             + (rxi_nDgramPackets-1) * RX_JUMBOHEADERSIZE;
543       rx_maxJumboRecvSize = MAX(rx_maxJumboRecvSize, rx_maxReceiveSize);
544       ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
545       if (ncbufs > 0) {
546         ncbufs = ncbufs / RX_CBUFFERSIZE;
547         npackets = rx_initSendWindow -1;
548         rxi_MorePackets(npackets*(ncbufs+1));
549       }
550     }
551 #else /* AFS_DJGPP_ENV */
552     close(s);
553     return;
554 #endif /* AFS_DJGPP_ENV */
555 }
556 #endif /* AFS_NT40_ENV */
557
558 /* Called from rxi_FindPeer, when initializing a clear rx_peer structure,
559  * to get interesting information.
560  * Curiously enough, the rx_peerHashTable_lock currently protects the
561  * Inited variable (and hence rx_GetIFInfo). When the fs suite uses
562  * pthreads, this issue will need to be revisited.
563  */
564
565 void rxi_InitPeerParams(struct rx_peer *pp)
566 {
567     afs_uint32 ppaddr;
568     u_short rxmtu;
569     int ix;
570
571
572
573     LOCK_IF_INIT
574     if (!Inited) {
575         UNLOCK_IF_INIT
576         /*
577          * there's a race here since more than one thread could call
578          * rx_GetIFInfo.  The race stops in rx_GetIFInfo.
579          */
580         rx_GetIFInfo();
581     } else {
582         UNLOCK_IF_INIT
583     }
584
585 #ifdef ADAPT_MTU
586     /* try to second-guess IP, and identify which link is most likely to
587      * be used for traffic to/from this host. */
588     ppaddr = ntohl(pp->host);
589
590     pp->ifMTU = 0;
591     pp->timeout.sec = 2;
592     pp->rateFlag = 2;   /* start timing after two full packets */
593     /* I don't initialize these, because I presume they are bzero'd... 
594      * pp->burstSize pp->burst pp->burstWait.sec pp->burstWait.usec
595      * pp->timeout.usec */
596   
597     LOCK_IF
598     for (ix = 0; ix < rxi_numNetAddrs; ++ix) {
599       if ((rxi_NetAddrs[ix] & myNetMasks[ix]) == (ppaddr & myNetMasks[ix])) {
600 #ifdef IFF_POINTOPOINT
601         if (myNetFlags[ix] & IFF_POINTOPOINT) 
602            pp->timeout.sec = 4;
603 #endif /* IFF_POINTOPOINT */
604         rxmtu = myNetMTUs[ix] - RX_IPUDP_SIZE;
605         if ( rxmtu < RX_MIN_PACKET_SIZE ) 
606           rxmtu = RX_MIN_PACKET_SIZE ;
607         if (pp->ifMTU < rxmtu) 
608           pp->ifMTU = MIN(rx_MyMaxSendSize, rxmtu);
609       }
610     }
611     UNLOCK_IF
612
613     if (!pp->ifMTU) { /* not local */
614         pp->timeout.sec = 3;
615         pp->ifMTU = RX_REMOTE_PACKET_SIZE;
616     }
617 #else /* ADAPT_MTU */
618     pp->rateFlag = 2;   /* start timing after two full packets */
619     pp->timeout.sec = 2;
620     pp->ifMTU = OLD_MAX_PACKET_SIZE;
621 #endif /* ADAPT_MTU */
622     pp->ifMTU = rxi_AdjustIfMTU(pp->ifMTU);
623     pp->maxMTU = OLD_MAX_PACKET_SIZE;  /* for compatibility with old guys */
624     pp->natMTU = MIN((int)pp->ifMTU, OLD_MAX_PACKET_SIZE); 
625     pp->maxDgramPackets = MIN(rxi_nDgramPackets,
626                               rxi_AdjustDgramPackets(RX_MAX_FRAGS, pp->ifMTU));
627     pp->ifDgramPackets = MIN(rxi_nDgramPackets,
628                              rxi_AdjustDgramPackets(RX_MAX_FRAGS, pp->ifMTU));
629     pp->maxDgramPackets = 1;
630     /* Initialize slow start parameters */
631     pp->MTU = MIN(pp->natMTU, pp->maxMTU);
632     pp->cwind = 1;
633     pp->nDgramPackets = 1;
634     pp->congestSeq = 0;
635 }
636
637 /* Don't expose jumobgram internals. */
638 void rx_SetNoJumbo(void)
639 {
640     rx_maxReceiveSize = OLD_MAX_PACKET_SIZE;
641     rxi_nSendFrags = rxi_nRecvFrags = 1;
642 }