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