1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
diff --git a/lib/ftchash.c b/lib/ftchash.c
index 9cc7efa..28bafbf 100644
--- a/lib/ftchash.c
+++ b/lib/ftchash.c
@@ -326,7 +326,7 @@ void *ftchash_foreach(struct ftchash *ft
(char*)ftch->traverse_chunk->base+ftch->traverse_chunk->next) {
ret = ftch->traverse_rec;
- (char*)ftch->traverse_rec += ftch->d_size;
+ ftch->traverse_rec = vpadd(ftch->traverse_rec, ftch->d_size);
return ret;
} else {
diff --git a/lib/ftio.c b/lib/ftio.c
index f6c739c..1082416 100644
--- a/lib/ftio.c
+++ b/lib/ftio.c
@@ -2267,7 +2267,7 @@ int readn(register int fd, register void
break;
nleft -= nread;
- (char*)ptr += nread;
+ ptr = vpadd(ptr, nread);
}
return (nbytes - nleft);
} /* readn */
@@ -2292,7 +2292,7 @@ int writen(register int fd, register voi
return(nwritten); /* error */
nleft -= nwritten;
- (char*)ptr += nwritten;
+ ptr = vpadd(ptr,nwritten);
}
return(nbytes - nleft);
} /* writen */
diff --git a/lib/ftlib.h b/lib/ftlib.h
index f91ad0a..66bf2f3 100644
--- a/lib/ftlib.h
+++ b/lib/ftlib.h
@@ -152,7 +152,6 @@ #define FT_PDU_V8_11_MAXFLOWS 44 /* max
#define FT_PDU_V8_12_MAXFLOWS 44 /* max records in V8 DST_PREFIX_TOS packet */
#define FT_PDU_V8_13_MAXFLOWS 35 /* max records in V8 PREFIX_TOS packet */
#define FT_PDU_V8_14_MAXFLOWS 35 /* max records in V8 PREFIX_PORT_TOS packet */
-
#define FT_PDU_V8_1_VERSION 2 /* version of AS packet */
#define FT_PDU_V8_2_VERSION 2 /* version of PROTO PORT packet */
#define FT_PDU_V8_3_VERSION 2 /* version of SRC PREFIX packet */
@@ -3029,6 +3028,8 @@ #ifndef IN_CLASSD_SSM
#define IN_CLASSD_SSM(i) (((u_int32_t)(i) & 0xff000000) == 0xe8000000)
#endif /* IN_CLASSD_SSM */
+void *vpadd(const void* v, const int change);
+
/* MACHINE DEPENDANT */
#define fmt_uint fmt_uint32
diff --git a/lib/fttlv.c b/lib/fttlv.c
index 7035813..330a783 100644
--- a/lib/fttlv.c
+++ b/lib/fttlv.c
@@ -68,10 +68,10 @@ int fttlv_enc_uint32(void *buf, int buf_
}
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&v, buf, 4);
@@ -107,10 +107,10 @@ int fttlv_enc_uint16(void *buf, int buf_
}
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&v, buf, 2);
@@ -145,10 +145,10 @@ int fttlv_enc_uint8(void *buf, int buf_s
}
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&v, buf, 1);
@@ -183,10 +183,10 @@ int fttlv_enc_str(void *buf, int buf_siz
}
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(v, buf, len);
@@ -230,16 +230,16 @@ int fttlv_enc_ifname(void *buf, int buf_
return -1;
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&ip, buf, 4);
- (char*)buf += 4;
+ buf = vpadd(buf, 4);
bcopy(&ifIndex, buf, 2);
- (char*)buf += 2;
+ buf = vpadd(buf, 2);
bcopy(name, buf, n);
@@ -287,19 +287,19 @@ int fttlv_enc_ifalias(void *buf, int buf
}
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&ip, buf, 4);
- (char*)buf += 4;
+ buf = vpadd(buf, 4);
bcopy(&entries, buf, 2);
- (char*)buf += 2;
+ buf = vpadd(buf, 2);
bcopy(ifIndex_list, buf, esize);
- (char*)buf += esize;
+ buf = vpadd(buf, esize);
bcopy(name, buf, n);
diff --git a/lib/support.c b/lib/support.c
index a32ffe7..2e1db9f 100644
--- a/lib/support.c
+++ b/lib/support.c
@@ -736,3 +736,8 @@ int udp_cksum(struct ip *ip, struct udph
return sum;
} /* udp_cksum */
+// void pointer add
+
+void * vpadd(const void *v, const int change) {
+ return (void *) (((char*) v) + change);
+}
|