Imported Upstream version 1.0.10
[platform/upstream/lksctp-tools.git] / src / withsctp / checksctp.c
1 /* Does this host have SCTP?
2  *
3  * Copyright 2003 La Monte HP Yarroll <piggy@acm.org>
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  *
9  *    1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer. 
11  *    2. Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer in the documentation and/or other materials provided with
14  * the distribution.
15  *    3. The name of the author may not be used to endorse or promote
16  * products derived from this software without specific prior written
17  * permission.
18  * 
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
27  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
29  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
30  */
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <sys/socket.h>
34 #include <netinet/in.h>
35
36 /* IPPROTO_SCTP SHOULD be defined in
37  * /usr/include/linux/in.h but probably isn't.
38  * It is an enum element, not a #define, so we can't easily check.
39  */
40 #define SHOULD_IPPROTO_SCTP 132
41
42 main()
43 {
44     int fd;
45
46     fd = socket(PF_INET, SOCK_STREAM, SHOULD_IPPROTO_SCTP);
47
48     if (fd <= 0) {
49         perror("checksctp");
50         exit(1);
51     } else {
52         fprintf(stderr, "SCTP supported\n");
53     }
54
55     close(fd);
56     exit(0);
57 }