blob: c75032e8fc4d4dc8d6f9ecdc7256229b5e5622b9 [file] [log] [blame]
mridge949c5b12006-01-03 23:01:28 +00001/*
2 *
3 * Copyright (c) International Business Machines Corp., 2001
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Wanlong Gao4548c6c2012-10-19 18:03:36 +080017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
mridge949c5b12006-01-03 23:01:28 +000018 */
19
20/*
21 * Test Name: asapi_07
22 *
23 * Test Description:
24 * These tests are for the "Advanced Sockets API" (RFC 3542)
25 * Section 20, ancillary data macros and structure definitions
26 *
27 * Usage: <for command-line>
28 * asapi_07
29 *
30 * HISTORY
31 * 04/2005 written by David L Stevens
32 *
33 * RESTRICTIONS:
34 * None.
35 *
36 */
37
38#include <stdio.h>
39#include <unistd.h>
40#include <errno.h>
41
42#include <sys/wait.h>
43
44#include <netinet/in.h>
45#include <netinet/ip6.h>
46#include <netinet/icmp6.h>
47
48#include "test.h"
mridge949c5b12006-01-03 23:01:28 +000049#include "runcc.h"
50
Wanlong Gao354ebb42012-12-07 10:10:04 +080051char *TCID = "asapi_07"; /* Test program identifier. */
mridge949c5b12006-01-03 23:01:28 +000052
Garrett Cooper2c282152010-12-16 00:55:50 -080053void setup(void);
54void cleanup(void);
mridge949c5b12006-01-03 23:01:28 +000055
Garrett Cooper2c282152010-12-16 00:55:50 -080056void adatet(void);
57void adatft(void);
mridge949c5b12006-01-03 23:01:28 +000058
Wanlong Gao354ebb42012-12-07 10:10:04 +080059int main(int argc, char *argv[])
mridge949c5b12006-01-03 23:01:28 +000060{
Wanlong Gao354ebb42012-12-07 10:10:04 +080061 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020062 const char *msg;
mridge949c5b12006-01-03 23:01:28 +000063
64 /* Parse standard options given to run the test. */
Garrett Cooper2c282152010-12-16 00:55:50 -080065 if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
Garrett Cooper53740502010-12-16 00:04:01 -080066 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
mridge949c5b12006-01-03 23:01:28 +000067
68 setup();
69
70 for (lc = 0; TEST_LOOPING(lc); ++lc) {
71 adatet();
72 }
73
74 cleanup();
Garrett Cooper2c282152010-12-16 00:55:50 -080075
Garrett Cooper3483b6e2010-12-17 03:24:08 -080076 tst_exit();
mridge949c5b12006-01-03 23:01:28 +000077}
78
79enum ttype { EXISTS, ALIAS, VALUE, DEFINED };
80
81struct etent {
Wanlong Gao354ebb42012-12-07 10:10:04 +080082 char *et_tname; /* test name */
83 int et_type; /* test type */
84 char *et_incl; /* include file list */
85 char *et_struct; /* structure name */
86 char *et_field; /* field name */
87 char *et_offset; /* field offset */
mridge949c5b12006-01-03 23:01:28 +000088 union {
Wanlong Gao354ebb42012-12-07 10:10:04 +080089 char *fu_value; /* field size or value */
90 char *fu_dname; /* #define name */
mridge949c5b12006-01-03 23:01:28 +000091 } ftun;
92#define et_value ftun.fu_value
93#define et_dname ftun.fu_dname
94} etab[] = {
95/* existence checks, RFC 3542 sections 5, 20 */
Wanlong Gao354ebb42012-12-07 10:10:04 +080096 {
97 "msghdr msg_name", EXISTS, SOCKET_H, "msghdr", "msg_name", NULL, {
98 "sizeof(void *)"}}, {
99 "msghdr msg_namelen", EXISTS, SOCKET_H, "msghdr",
100 "msg_namelen", NULL, {
101 "sizeof(socklen_t)"}}, {
102 "msghdr msg_iov", EXISTS, SOCKET_H, "msghdr", "msg_iov", NULL, {
103 "sizeof(struct iovec *)"}}, {
104 "msghdr msg_iovlen", EXISTS, SOCKET_H, "msghdr",
105 "msg_iovlen", NULL, {
Simon Xu0e853512013-12-05 10:11:58 +0800106 "sizeof(size_t)"}}, {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800107 "msghdr msg_control", EXISTS, SOCKET_H, "msghdr",
108 "msg_control", NULL, {
109 "sizeof(void *)"}}, {
110 "msghdr msg_controllen", EXISTS, SOCKET_H, "msghdr",
111 "msg_controllen", NULL, {
Simon Xu0e853512013-12-05 10:11:58 +0800112 "sizeof(size_t)"}}, {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800113 "msghdr msg_flags", EXISTS, SOCKET_H, "msghdr",
114 "msg_flags", NULL, {
115 "sizeof(int)"}}, {
116 "cmsghdr cmsg_len", EXISTS, SOCKET_H, "cmsghdr",
117 "cmsg_len", NULL, {
Simon Xu0e853512013-12-05 10:11:58 +0800118 "sizeof(size_t)"}}, {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800119 "cmsghdr cmsg_level", EXISTS, SOCKET_H, "cmsghdr",
120 "cmsg_level", NULL, {
121 "sizeof(int)"}}, {
122 "cmsghdr cmsg_type", EXISTS, SOCKET_H, "cmsghdr",
123 "cmsg_type", NULL, {
124 "sizeof(int)"}}, {
125 "CMSG_DATA", DEFINED, SOCKET_H, "CMSG_DATA", NULL, NULL, {
126 0}}, {
127 "CMSG_NXTHDR", DEFINED, SOCKET_H, "CMSG_NXTHDR", NULL, NULL, {
128 0}}, {
129 "CMSG_FIRSTHDR", DEFINED, SOCKET_H, "CMSG_FIRSTHDR", NULL, NULL, {
130 0}}, {
131 "CMSG_SPACE", DEFINED, SOCKET_H, "CMSG_SPACE", NULL, NULL, {
132 0}}, {
133 "CMSG_LEN", DEFINED, SOCKET_H, "CMSG_LEN", NULL, NULL, {
1340}},};
mridge949c5b12006-01-03 23:01:28 +0000135
136#define ETCOUNT (sizeof(etab)/sizeof(etab[0]))
137
138/* existence tests */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800139void adatet(void)
mridge949c5b12006-01-03 23:01:28 +0000140{
Wanlong Gao354ebb42012-12-07 10:10:04 +0800141 int i;
mridge949c5b12006-01-03 23:01:28 +0000142
Wanlong Gao354ebb42012-12-07 10:10:04 +0800143 for (i = 0; i < ETCOUNT; ++i) {
mridge949c5b12006-01-03 23:01:28 +0000144 switch (etab[i].et_type) {
145 case EXISTS:
146 structcheck(etab[i].et_tname, etab[i].et_incl,
Wanlong Gao354ebb42012-12-07 10:10:04 +0800147 etab[i].et_struct, etab[i].et_field,
148 etab[i].et_offset, etab[i].et_value);
mridge949c5b12006-01-03 23:01:28 +0000149 break;
150 case ALIAS:
151 aliascheck(etab[i].et_tname, etab[i].et_incl,
Wanlong Gao354ebb42012-12-07 10:10:04 +0800152 etab[i].et_struct, etab[i].et_field,
153 etab[i].et_dname);
mridge949c5b12006-01-03 23:01:28 +0000154 break;
155 case VALUE:
156 valuecheck(etab[i].et_tname, etab[i].et_incl,
Wanlong Gao354ebb42012-12-07 10:10:04 +0800157 etab[i].et_struct, etab[i].et_dname);
mridge949c5b12006-01-03 23:01:28 +0000158 break;
159 case DEFINED:
160 funccheck(etab[i].et_tname, etab[i].et_incl,
Wanlong Gao354ebb42012-12-07 10:10:04 +0800161 etab[i].et_struct);
mridge949c5b12006-01-03 23:01:28 +0000162 break;
163 default:
Garrett Cooper2c282152010-12-16 00:55:50 -0800164 tst_resm(TBROK, "invalid type %d", etab[i].et_type);
mridge949c5b12006-01-03 23:01:28 +0000165 break;
166 }
167 }
168}
169
Wanlong Gao354ebb42012-12-07 10:10:04 +0800170void setup(void)
mridge949c5b12006-01-03 23:01:28 +0000171{
Wanlong Gao354ebb42012-12-07 10:10:04 +0800172 TEST_PAUSE; /* if -P option specified */
mridge949c5b12006-01-03 23:01:28 +0000173}
174
Wanlong Gao354ebb42012-12-07 10:10:04 +0800175void cleanup(void)
mridge949c5b12006-01-03 23:01:28 +0000176{
mridge949c5b12006-01-03 23:01:28 +0000177}
178
Chris Dearmanec6edca2012-10-17 19:54:01 -0700179int TST_TOTAL = ETCOUNT;