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
|
547
|
34 void
|
|
35 linux_kernel();
|
448
|
36
|
542
|
37 int
|
448
|
38 main()
|
|
39 {
|
|
40 struct temp temp2 = { .c = 5, .e=99 };
|
542
|
41 #ifdef WRONG
|
|
42 struct temp temp5 = { 1,2,3,4,5,6,7,8};
|
|
43 struct temp temp6 = { 1,2,3,4,5,6};
|
|
44 #else
|
|
45 struct temp temp5 = { 1,2,3,4,5,6,7};
|
|
46 struct temp temp6 = { 1,2,3,4,5,6,7};
|
|
47 struct temp temp8 = { 1,2,3,4,{5,6},7};
|
|
48 #endif
|
|
49 printf("#0042:1: %d\n",temp1.a);
|
|
50 printf("#0043:1: %d\n",temp1.e);
|
|
51 printf("#0044:1: %d\n",temp1.b);
|
|
52 printf("#0045:2: %d\n",temp2.c);
|
|
53 printf("#0046:2: %d\n",temp2.e);
|
|
54 printf("#0047:2: %d\n",temp2.b);
|
|
55 printf("#0048:2: %d\n",(void*)temp3.c==b);
|
|
56 printf("#0049:2: %d\n",temp3.c==(int)b);
|
|
57 printf("#0050:2: %d\n",temp3.a==(int)&b);
|
|
58 printf("#0051:2: %d\n",temp4.m.j);
|
|
59 printf("#0051:2: %d\n",temp5.m.j);
|
547
|
60 linux_kernel();
|
448
|
61 return 0;
|
|
62 }
|
547
|
63
|
|
64 typedef unsigned int __u32;
|
|
65 typedef unsigned short __u16;
|
|
66 typedef unsigned char __u8;
|
|
67 typedef unsigned int u32;
|
|
68 typedef unsigned short u16;
|
|
69 typedef unsigned char u8;
|
|
70 struct in6_addr { char hoge[128]; };
|
|
71
|
|
72 struct flowi {
|
|
73 int oif;
|
|
74 int iif;
|
|
75
|
|
76 union {
|
|
77 struct {
|
|
78 __u32 daddr;
|
|
79 __u32 saddr;
|
|
80 __u32 fwmark;
|
|
81 __u8 tos;
|
|
82 __u8 scope;
|
|
83 } ip4_u;
|
|
84
|
|
85 struct {
|
|
86 struct in6_addr daddr;
|
|
87 struct in6_addr saddr;
|
|
88 __u32 flowlabel;
|
|
89 } ip6_u;
|
|
90
|
|
91 struct {
|
|
92 __u16 daddr;
|
|
93 __u16 saddr;
|
|
94 __u32 fwmark;
|
|
95 __u8 scope;
|
|
96 } dn_u;
|
|
97 } nl_u;
|
|
98 __u8 proto;
|
|
99 __u8 flags;
|
|
100 union {
|
|
101 struct {
|
|
102 __u16 sport;
|
|
103 __u16 dport;
|
|
104 } ports;
|
|
105
|
|
106 struct {
|
|
107 __u8 type;
|
|
108 __u8 code__;
|
|
109 } icmpt;
|
|
110
|
|
111 struct {
|
|
112 __u16 sport;
|
|
113 __u16 dport;
|
|
114
|
|
115 __u8 objnum;
|
|
116 __u8 objnamel;
|
|
117 __u8 objname[16];
|
|
118 } dnports;
|
|
119
|
|
120 __u32 spi;
|
|
121 } uli_u;
|
|
122 } __attribute__((__aligned__(32/8)));
|
|
123
|
|
124
|
|
125 static __inline__ __attribute__((always_inline)) __attribute__((always_inline))
|
|
126 int ip_route_connect(/* struct rtable **rp, */ u32 dst,
|
|
127 u32 src, u32 tos, int oif, u8 protocol,
|
|
128 u16 sport, u16 dport /*, struct sock *sk */)
|
|
129 {
|
|
130 struct flowi fl = { .oif = oif,
|
|
131 .nl_u = { .ip4_u = { .daddr = dst,
|
|
132 .saddr = src,
|
|
133 .tos = tos } },
|
|
134 .proto = protocol,
|
|
135 .uli_u = { .ports =
|
|
136 { .sport = sport,
|
|
137 .dport = dport } } };
|
|
138
|
|
139 printf("%d %d\n",fl.oif,fl.uli_u.ports.dport);
|
|
140 }
|
|
141
|
|
142 void
|
|
143 linux_kernel()
|
|
144 {
|
|
145 ip_route_connect(1,2,3,4,5,6,7);
|
|
146 }
|
|
147
|
|
148 // end
|