bindresvport.c (cf2fcd35ddc6b7d8664356eba6d1b89734aa4cb8) | bindresvport.c (dd50fc213997263fbedc3bba36fd419963d3adfd) |
---|---|
1/* 2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 * unrestricted use provided that this legend is included on all tape 4 * media and as a part of the software program in whole or part. Users 5 * may copy or modify Sun RPC without charge, but are not authorized 6 * to license or distribute it to anyone else except as part of a product or 7 * program developed by the user. 8 * --- 17 unchanged lines hidden (view full) --- 26 * 2550 Garcia Avenue 27 * Mountain View, California 94043 28 */ 29 30#if defined(LIBC_SCCS) && !defined(lint) 31/*static char *sccsid = "from: @(#)bindresvport.c 1.8 88/02/08 SMI";*/ 32/*static char *sccsid = "from: @(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";*/ 33/*from: OpenBSD: bindresvport.c,v 1.7 1996/07/30 16:25:47 downsj Exp */ | 1/* 2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 * unrestricted use provided that this legend is included on all tape 4 * media and as a part of the software program in whole or part. Users 5 * may copy or modify Sun RPC without charge, but are not authorized 6 * to license or distribute it to anyone else except as part of a product or 7 * program developed by the user. 8 * --- 17 unchanged lines hidden (view full) --- 26 * 2550 Garcia Avenue 27 * Mountain View, California 94043 28 */ 29 30#if defined(LIBC_SCCS) && !defined(lint) 31/*static char *sccsid = "from: @(#)bindresvport.c 1.8 88/02/08 SMI";*/ 32/*static char *sccsid = "from: @(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";*/ 33/*from: OpenBSD: bindresvport.c,v 1.7 1996/07/30 16:25:47 downsj Exp */ |
34static char *rcsid = "$Id: bindresvport.c,v 1.4 1996/06/10 00:49:15 jraynard Exp $"; | 34static char *rcsid = "$Id: bindresvport.c,v 1.5 1996/08/12 14:09:46 peter Exp $"; |
35#endif 36 37/* 38 * Copyright (c) 1987 by Sun Microsystems, Inc. 39 * 40 * Portions Copyright(C) 1996, Jason Downs. All rights reserved. 41 */ 42 --- 13 unchanged lines hidden (view full) --- 56 struct sockaddr_in *sin; 57{ 58 int on, old, error; 59 struct sockaddr_in myaddr; 60 int sinlen = sizeof(struct sockaddr_in); 61 62 if (sin == (struct sockaddr_in *)0) { 63 sin = &myaddr; | 35#endif 36 37/* 38 * Copyright (c) 1987 by Sun Microsystems, Inc. 39 * 40 * Portions Copyright(C) 1996, Jason Downs. All rights reserved. 41 */ 42 --- 13 unchanged lines hidden (view full) --- 56 struct sockaddr_in *sin; 57{ 58 int on, old, error; 59 struct sockaddr_in myaddr; 60 int sinlen = sizeof(struct sockaddr_in); 61 62 if (sin == (struct sockaddr_in *)0) { 63 sin = &myaddr; |
64 memset(sin, 0, sizeof(*sin)); 65 sin->sin_len = sizeof(*sin); | 64 memset(sin, 0, sinlen); 65 sin->sin_len = sinlen; |
66 sin->sin_family = AF_INET; 67 } else if (sin->sin_family != AF_INET) { 68 errno = EPFNOSUPPORT; 69 return (-1); 70 } 71 72 if (sin->sin_port == 0) { 73 int oldlen = sizeof(old); --- 4 unchanged lines hidden (view full) --- 78 79 on = IP_PORTRANGE_LOW; 80 error = setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, 81 &on, sizeof(on)); 82 if (error < 0) 83 return(error); 84 } 85 | 66 sin->sin_family = AF_INET; 67 } else if (sin->sin_family != AF_INET) { 68 errno = EPFNOSUPPORT; 69 return (-1); 70 } 71 72 if (sin->sin_port == 0) { 73 int oldlen = sizeof(old); --- 4 unchanged lines hidden (view full) --- 78 79 on = IP_PORTRANGE_LOW; 80 error = setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, 81 &on, sizeof(on)); 82 if (error < 0) 83 return(error); 84 } 85 |
86 error = bind(sd, (struct sockaddr *)sin, sizeof(*sin)); | 86 error = bind(sd, (struct sockaddr *)sin, sinlen); |
87 88 if (sin->sin_port == 0) { 89 int saved_errno = errno; 90 91 if (error) { 92 if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, 93 &old, sizeof(old)) < 0) 94 errno = saved_errno; 95 return (error); 96 } 97 98 if (sin != &myaddr) { | 87 88 if (sin->sin_port == 0) { 89 int saved_errno = errno; 90 91 if (error) { 92 if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, 93 &old, sizeof(old)) < 0) 94 errno = saved_errno; 95 return (error); 96 } 97 98 if (sin != &myaddr) { |
99 int sinlen = sizeof(*sin); 100 | |
101 /* Hmm, what did the kernel assign... */ 102 if (getsockname(sd, (struct sockaddr *)sin, 103 &sinlen) < 0) 104 errno = saved_errno; 105 return (error); 106 } 107 } 108 return (error); 109} | 99 /* Hmm, what did the kernel assign... */ 100 if (getsockname(sd, (struct sockaddr *)sin, 101 &sinlen) < 0) 102 errno = saved_errno; 103 return (error); 104 } 105 } 106 return (error); 107} |