1/*- 2 * Copyright (c) 2006 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 *
| 1/*- 2 * Copyright (c) 2006 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 *
|
26 * $FreeBSD: head/tools/regression/netipx/ipxsocket/ipxsocket.c 157139 2006-03-26 01:58:39Z rwatson $
| 26 * $FreeBSD: head/tools/regression/netipx/ipxsocket/ipxsocket.c 157146 2006-03-26 15:49:35Z rwatson $
|
27 */ 28 29/* 30 * Simple regression test to open and then immediately close various types of
| 27 */ 28 29/* 30 * Simple regression test to open and then immediately close various types of
|
31 * PF_IPX sockets.
| 31 * PF_IPX sockets. Run with various waits in order to make sure that the 32 * various IPX/SPX timers have a chance to walk the pcb lists and hit the 33 * sockets.
|
32 */ 33 34#include <sys/types.h> 35#include <sys/socket.h> 36 37#include <netipx/ipx.h> 38 39#include <err.h> 40#include <unistd.h> 41
| 34 */ 35 36#include <sys/types.h> 37#include <sys/socket.h> 38 39#include <netipx/ipx.h> 40 41#include <err.h> 42#include <unistd.h> 43
|
| 44static int 45maybe_sleep(int sec) 46{ 47 48 if (sec == 0) 49 return (0); 50 return (sleep(sec)); 51} 52
|
42int 43main(int argc, char *argv[]) 44{
| 53int 54main(int argc, char *argv[]) 55{
|
45 int s;
| 56 int delay, s;
|
46
| 57
|
47 s = socket(PF_IPX, SOCK_DGRAM, 0); 48 if (s < 0) 49 warn("socket(PF_IPX, SOCK_DGRAM, 0)"); 50 else 51 close(s);
| 58 for (delay = 0; delay < 5; delay++) { 59 s = socket(PF_IPX, SOCK_DGRAM, 0); 60 if (s < 0) 61 warn("socket(PF_IPX, SOCK_DGRAM, 0)"); 62 else { 63 maybe_sleep(delay); 64 close(s); 65 }
|
52
| 66
|
53 s = socket(PF_IPX, SOCK_STREAM, 0); 54 if (s < 0) 55 warn("socket(PF_IPX, SOCK_STREAM, 0)"); 56 else 57 close(s);
| 67 s = socket(PF_IPX, SOCK_STREAM, 0); 68 if (s < 0) 69 warn("socket(PF_IPX, SOCK_STREAM, 0)"); 70 else { 71 maybe_sleep(delay); 72 close(s); 73 }
|
58
| 74
|
59 s = socket(PF_IPX, SOCK_SEQPACKET, 0); 60 if (s < 0) 61 warn("socket(PF_IPX, SOCK_SEQPACKET, 0)"); 62 else 63 close(s);
| 75 s = socket(PF_IPX, SOCK_SEQPACKET, 0); 76 if (s < 0) 77 warn("socket(PF_IPX, SOCK_SEQPACKET, 0)"); 78 else { 79 maybe_sleep(delay); 80 close(s); 81 }
|
64
| 82
|
65 s = socket(PF_IPX, SOCK_RAW, 0); 66 if (s < 0) 67 warn("socket(PF_IPX, SOCK_RAW, 0)"); 68 else 69 close(s);
| 83 s = socket(PF_IPX, SOCK_RAW, 0); 84 if (s < 0) 85 warn("socket(PF_IPX, SOCK_RAW, 0)"); 86 else { 87 maybe_sleep(delay); 88 close(s); 89 } 90 }
|
70 71 return (0); 72}
| 91 92 return (0); 93}
|