467
|
1 #include <stdio.h>
|
448
|
2
|
|
3 int b[3] = {1,2,3};
|
|
4
|
|
5 struct temp {
|
|
6 int a;
|
|
7 int b;
|
|
8 int c;
|
|
9 int d;
|
542
|
10 struct hoge {
|
|
11 int k;
|
|
12 int j;
|
|
13 } m;
|
448
|
14 int e;
|
|
15 } temp1 = {
|
|
16 // 101,
|
|
17 // 102,
|
|
18 // 103,
|
|
19 // 104,
|
|
20 // 105,
|
|
21 .e = 5,
|
|
22 .a = 3
|
|
23 };
|
|
24
|
|
25 struct temp temp3 = {
|
|
26 .c = (int)&b,
|
|
27 .d = -10,
|
|
28 .a = (int)b
|
|
29 };
|
|
30
|
542
|
31 struct temp temp4 = { 1,2,3,4,5,6,7};
|
|
32 struct temp temp7 = { 1,2,3,4,{5,6},7};
|
448
|
33
|
553
|
34 #if 0
|
|
35 struct temp temp10 = {
|
|
36 .m = (struct hoge){}, // not allowed in global
|
|
37 .c = (int)&b,
|
|
38 };
|
|
39 #endif
|
|
40
|
547
|
41 void
|
|
42 linux_kernel();
|
448
|
43
|
559
|
44 struct test{
|
|
45 int a,b,c;
|
|
46 } huga = {
|
|
47 0,0,0,
|
|
48 };
|
|
49
|
542
|
50 int
|
448
|
51 main()
|
|
52 {
|
|
53 struct temp temp2 = { .c = 5, .e=99 };
|
542
|
54 #ifdef WRONG
|
|
55 struct temp temp5 = { 1,2,3,4,5,6,7,8};
|
|
56 struct temp temp6 = { 1,2,3,4,5,6};
|
|
57 #else
|
|
58 struct temp temp5 = { 1,2,3,4,5,6,7};
|
|
59 struct temp temp6 = { 1,2,3,4,5,6,7};
|
|
60 struct temp temp8 = { 1,2,3,4,{5,6},7};
|
|
61 #endif
|
553
|
62 struct temp temp11 = {
|
|
63 .m = (struct hoge){},
|
|
64 .c = (int)&b,
|
|
65 };
|
|
66 struct temp temp12 = {
|
|
67 .m = (struct hoge){1,3},
|
|
68 .c = (int)&temp4,
|
|
69 };
|
|
70
|
|
71 printf("#0064:1: %d\n",temp1.a);
|
|
72 printf("#0065:1: %d\n",temp1.e);
|
|
73 printf("#0066:1: %d\n",temp1.b);
|
|
74 printf("#0067:2: %d\n",temp2.c);
|
|
75 printf("#0068:2: %d\n",temp2.e);
|
|
76 printf("#0069:2: %d\n",temp2.b);
|
|
77 printf("#0070:2: %d\n",(void*)temp3.c==b);
|
|
78 printf("#0071:2: %d\n",temp3.c==(int)b);
|
|
79 printf("#0072:2: %d\n",temp3.a==(int)&b);
|
|
80 printf("#0073:2: %d\n",temp4.m.j);
|
|
81 printf("#0074:2: %d\n",temp5.m.j);
|
|
82 printf("#0075:2: %d\n",temp11.m.j);
|
|
83 printf("#0076:2: %d\n",temp12.m.k);
|
|
84 printf("#0077:2: %d\n",temp12.m.j);
|
|
85 printf("#0078:2: %d\n",temp11.c==(int)&b);
|
559
|
86 printf("#0068:2: %d\n",temp8.e);
|
|
87 printf("#0068:2: %d\n",temp6.e);
|
547
|
88 linux_kernel();
|
448
|
89 return 0;
|
|
90 }
|
547
|
91
|
|
92 typedef unsigned int __u32;
|
|
93 typedef unsigned short __u16;
|
|
94 typedef unsigned char __u8;
|
|
95 typedef unsigned int u32;
|
|
96 typedef unsigned short u16;
|
|
97 typedef unsigned char u8;
|
|
98 struct in6_addr { char hoge[128]; };
|
|
99
|
|
100 struct flowi {
|
|
101 int oif;
|
|
102 int iif;
|
|
103
|
|
104 union {
|
|
105 struct {
|
|
106 __u32 daddr;
|
|
107 __u32 saddr;
|
|
108 __u32 fwmark;
|
|
109 __u8 tos;
|
|
110 __u8 scope;
|
|
111 } ip4_u;
|
|
112
|
|
113 struct {
|
|
114 struct in6_addr daddr;
|
|
115 struct in6_addr saddr;
|
|
116 __u32 flowlabel;
|
|
117 } ip6_u;
|
|
118
|
|
119 struct {
|
|
120 __u16 daddr;
|
|
121 __u16 saddr;
|
|
122 __u32 fwmark;
|
|
123 __u8 scope;
|
|
124 } dn_u;
|
|
125 } nl_u;
|
|
126 __u8 proto;
|
|
127 __u8 flags;
|
|
128 union {
|
|
129 struct {
|
|
130 __u16 sport;
|
|
131 __u16 dport;
|
|
132 } ports;
|
|
133
|
|
134 struct {
|
|
135 __u8 type;
|
|
136 __u8 code__;
|
|
137 } icmpt;
|
|
138
|
|
139 struct {
|
|
140 __u16 sport;
|
|
141 __u16 dport;
|
|
142
|
|
143 __u8 objnum;
|
|
144 __u8 objnamel;
|
|
145 __u8 objname[16];
|
|
146 } dnports;
|
|
147
|
|
148 __u32 spi;
|
|
149 } uli_u;
|
|
150 } __attribute__((__aligned__(32/8)));
|
|
151
|
|
152
|
|
153 static __inline__ __attribute__((always_inline)) __attribute__((always_inline))
|
559
|
154 void ip_route_connect(/* struct rtable **rp, */ u32 dst,
|
547
|
155 u32 src, u32 tos, int oif, u8 protocol,
|
|
156 u16 sport, u16 dport /*, struct sock *sk */)
|
|
157 {
|
|
158 struct flowi fl = { .oif = oif,
|
|
159 .nl_u = { .ip4_u = { .daddr = dst,
|
|
160 .saddr = src,
|
|
161 .tos = tos } },
|
|
162 .proto = protocol,
|
|
163 .uli_u = { .ports =
|
|
164 { .sport = sport,
|
|
165 .dport = dport } } };
|
|
166
|
553
|
167 printf("#0158:%d %d\n",fl.oif,fl.uli_u.ports.dport);
|
547
|
168 }
|
|
169
|
548
|
170 static
|
559
|
171 void ip_route_connect0(/* struct rtable **rp, */ u32 dst,
|
548
|
172 u32 src, u32 tos, int oif, u8 protocol,
|
|
173 u16 sport, u16 dport /*, struct sock *sk */)
|
|
174 {
|
|
175 struct flowi fl = { .oif = oif,
|
|
176 .iif = 55,
|
|
177 .nl_u = { .ip4_u = { .daddr = dst,
|
|
178 .saddr = 66,
|
|
179 .tos = tos } },
|
|
180 .proto = protocol,
|
|
181 .uli_u = { .ports =
|
|
182 { .sport = sport,
|
|
183 .dport = dport } } };
|
|
184
|
553
|
185 printf("#0176:%d %d\n",fl.oif,fl.uli_u.ports.dport);
|
|
186 printf("#0177:%d %d\n",fl.iif,fl.nl_u.ip4_u.saddr);
|
548
|
187 }
|
|
188
|
547
|
189 void
|
|
190 linux_kernel()
|
|
191 {
|
548
|
192 ip_route_connect0(1,2,3,4,5,6,7);
|
547
|
193 ip_route_connect(1,2,3,4,5,6,7);
|
548
|
194 ip_route_connect(11,12,13,14,15,16,17);
|
547
|
195 }
|
|
196
|
|
197 // end
|