|
@@ -154,7 +154,7 @@ int inet_aton ( const char *cp, struct in_addr *inp ) {
|
154
|
154
|
int j;
|
155
|
155
|
for(j = 0; j <= 3; j++) {
|
156
|
156
|
digits_start = p;
|
157
|
|
- val = strtoul(p, &p, 10);
|
|
157
|
+ val = strtoul(p, ( char ** ) &p, 10);
|
158
|
158
|
if ((p == digits_start) || (val > 255)) return 0;
|
159
|
159
|
if ( ( j < 3 ) && ( *(p++) != '.' ) ) return 0;
|
160
|
160
|
ip = (ip << 8) | val;
|
|
@@ -175,100 +175,11 @@ unsigned long strtoul(const char *p, char **endp, int base)
|
175
|
175
|
p++;
|
176
|
176
|
}
|
177
|
177
|
if (endp)
|
178
|
|
- *endp = p;
|
|
178
|
+ *endp = ( char * ) p;
|
179
|
179
|
return(ret);
|
180
|
180
|
|
181
|
181
|
}
|
182
|
182
|
|
183
|
|
-
|
184
|
|
-#if DEBUG_UTILS
|
185
|
|
-
|
186
|
|
-void pause ( void ) {
|
187
|
|
- printf ( "\nPress a key" );
|
188
|
|
- getchar();
|
189
|
|
- printf ( "\r \r" );
|
190
|
|
-}
|
191
|
|
-
|
192
|
|
-void more ( void ) {
|
193
|
|
- printf ( "---more---" );
|
194
|
|
- getchar();
|
195
|
|
- printf ( "\r \r" );
|
196
|
|
-}
|
197
|
|
-
|
198
|
|
-/* Produce a paged hex dump of the specified data and length */
|
199
|
|
-void hex_dump ( const char *data, const unsigned int len ) {
|
200
|
|
- unsigned int index;
|
201
|
|
- for ( index = 0; index < len; index++ ) {
|
202
|
|
- if ( ( index % 16 ) == 0 ) {
|
203
|
|
- printf ( "\n" );
|
204
|
|
- }
|
205
|
|
- if ( ( index % 368 ) == 352 ) {
|
206
|
|
- more();
|
207
|
|
- }
|
208
|
|
- if ( ( index % 16 ) == 0 ) {
|
209
|
|
- printf ( "%X [%X] : %hX :", data + index,
|
210
|
|
- virt_to_phys ( data + index ), index );
|
211
|
|
- }
|
212
|
|
- printf ( " %hhX", data[index] );
|
213
|
|
- }
|
214
|
|
- printf ( "\n" );
|
215
|
|
-}
|
216
|
|
-
|
217
|
|
-#define GUARD_SYMBOL ( ( 'M' << 24 ) | ( 'I' << 16 ) | ( 'N' << 8 ) | 'E' )
|
218
|
|
-/* Fill a region with guard markers. We use a 4-byte pattern to make
|
219
|
|
- * it less likely that check_region will find spurious 1-byte regions
|
220
|
|
- * of non-corruption.
|
221
|
|
- */
|
222
|
|
-void guard_region ( void *region, size_t len ) {
|
223
|
|
- uint32_t offset = 0;
|
224
|
|
-
|
225
|
|
- len &= ~0x03;
|
226
|
|
- for ( offset = 0; offset < len ; offset += 4 ) {
|
227
|
|
- *((uint32_t *)(region + offset)) = GUARD_SYMBOL;
|
228
|
|
- }
|
229
|
|
-}
|
230
|
|
-
|
231
|
|
-/* Check a region that has been guarded with guard_region() for
|
232
|
|
- * corruption.
|
233
|
|
- */
|
234
|
|
-int check_region ( void *region, size_t len ) {
|
235
|
|
- uint8_t corrupted = 0;
|
236
|
|
- uint8_t in_corruption = 0;
|
237
|
|
- uint32_t offset = 0;
|
238
|
|
- uint32_t test = 0;
|
239
|
|
-
|
240
|
|
- len &= ~0x03;
|
241
|
|
- for ( offset = 0; offset < len ; offset += 4 ) {
|
242
|
|
- test = *((uint32_t *)(region + offset)) = GUARD_SYMBOL;
|
243
|
|
- if ( ( in_corruption == 0 ) &&
|
244
|
|
- ( test != GUARD_SYMBOL ) ) {
|
245
|
|
- /* Start of corruption */
|
246
|
|
- if ( corrupted == 0 ) {
|
247
|
|
- corrupted = 1;
|
248
|
|
- printf ( "Region %#x-%#x (physical %#x-%#x) "
|
249
|
|
- "corrupted\n",
|
250
|
|
- region, region + len,
|
251
|
|
- virt_to_phys ( region ),
|
252
|
|
- virt_to_phys ( region + len ) );
|
253
|
|
- }
|
254
|
|
- in_corruption = 1;
|
255
|
|
- printf ( "--- offset %#x ", offset );
|
256
|
|
- } else if ( ( in_corruption != 0 ) &&
|
257
|
|
- ( test == GUARD_SYMBOL ) ) {
|
258
|
|
- /* End of corruption */
|
259
|
|
- in_corruption = 0;
|
260
|
|
- printf ( "to offset %#x", offset );
|
261
|
|
- }
|
262
|
|
-
|
263
|
|
- }
|
264
|
|
- if ( in_corruption != 0 ) {
|
265
|
|
- printf ( "to offset %#x (end of region)\n", len-1 );
|
266
|
|
- }
|
267
|
|
- return corrupted;
|
268
|
|
-}
|
269
|
|
-
|
270
|
|
-#endif /* DEBUG_UTILS */
|
271
|
|
-
|
272
|
183
|
/*
|
273
|
184
|
* Local variables:
|
274
|
185
|
* c-basic-offset: 8
|