Check-in [52fcd859c7]
Overview
SHA1:52fcd859c7f8e51580f2fa751830db32382aafc6
Date: 2009-05-24 21:00:59
User: rmiller
Comment:A little defensive programming...
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2009-06-01
03:32
[576df9e8bd] Test commit, ignore. (user: rkeene, tags: trunk)
2009-05-24
21:00
[52fcd859c7] A little defensive programming... (user: rmiller, tags: trunk)
18:29
[d4b45fb52e] Change to uint8_t per Julien. (user: rmiller, tags: trunk)
Changes

Modified packetbl.c from [b3fcc2e443] to [cd3b07c2c0].

1367
1368
1369
1370
1371
1372
1373

1374
1375
1376
1377
1378
1379
1380
....
1386
1387
1388
1389
1390
1391
1392
1393

1394
1395





1396
1397
1398
1399
1400
1401
1402
....
1422
1423
1424
1425
1426
1427
1428


1429
1430





1431
1432
1433
1434
1435
1436





1437
1438
1439
1440
1441
1442
1443
 *   without aborting.
 *
 */
int check_packet_list(const struct packet_info *ip, struct config_entry *list) {

	struct config_entry *wltmp = NULL;
	unsigned int ip_proc;


	if (ip == NULL || list == NULL) {
		return 0;
	}

	ip_proc = ip->b1 << 24;
	ip_proc |= ip->b2 << 16;
................................................................................
	while (1) {
		uint32_t p = 0;

		p = ip_proc;
		p &= wltmp->cidr.processed;

		if (p == wltmp->cidr.ip) {
			snprintf(msgbuf, sizeof(msgbuf), "%hhu.%hhu.%hhu.%hhu %x/%d",

				ip->b1, ip->b2, ip->b3, ip->b4,
				wltmp->cidr.ip, wltmp->cidr.network);





			return 1;
		}

		if (wltmp->next == NULL) {
			break;
		}

................................................................................
 *   This function takes the data in the parameter "ip" and stores an ASCII
 *   representation in the global variable "msgbuf."
 *   It must be able to cope with "ip" being NULL.
 *
 */
static void get_ip_string(const struct packet_info *ip) {



	if (ip == NULL) {
		sprintf(msgbuf, "-");





		return;
	}

	snprintf(msgbuf, sizeof(msgbuf), "%hhu.%hhu.%hhu.%hhu:%d.%d", ip->b1, 
		ip->b2, ip->b3, ip->b4,
		ip->s_port,ip->d_port);





	return;
}

#ifdef USE_SOCKSTAT
/*
 * SYNOPSIS:
 *   void *pbl_sockstat_thread(







>







 







|
>
|
|
>
>
>
>
>







 







>
>

|
>
>
>
>
>



|
|
|
>
>
>
>
>







1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
....
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
....
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
 *   without aborting.
 *
 */
int check_packet_list(const struct packet_info *ip, struct config_entry *list) {

	struct config_entry *wltmp = NULL;
	unsigned int ip_proc;
	int rv;

	if (ip == NULL || list == NULL) {
		return 0;
	}

	ip_proc = ip->b1 << 24;
	ip_proc |= ip->b2 << 16;
................................................................................
	while (1) {
		uint32_t p = 0;

		p = ip_proc;
		p &= wltmp->cidr.processed;

		if (p == wltmp->cidr.ip) {
			rv = snprintf(msgbuf, sizeof(msgbuf), 
					"%hhu.%hhu.%hhu.%hhu %x/%d",
					ip->b1, ip->b2, ip->b3, ip->b4,
					wltmp->cidr.ip, wltmp->cidr.network);
			if (rv < 0) {
				syslog(LOG_ERR, "snprintf failed at line %d: %s",
					__LINE__, strerror(errno));
				exit (1);
			}
			return 1;
		}

		if (wltmp->next == NULL) {
			break;
		}

................................................................................
 *   This function takes the data in the parameter "ip" and stores an ASCII
 *   representation in the global variable "msgbuf."
 *   It must be able to cope with "ip" being NULL.
 *
 */
static void get_ip_string(const struct packet_info *ip) {

	int rv;
	
	if (ip == NULL) {
		rv = sprintf(msgbuf, "-");
		if (rv < 0) {	
			syslog(LOG_ERR, "sprintf failed in line %d: %s",
				__LINE__, strerror(errno));
			exit(1);
		}
		return;
	}

	rv = snprintf(msgbuf, sizeof(msgbuf), "%hhu.%hhu.%hhu.%hhu:%d.%d", 
			ip->b1, ip->b2, ip->b3, ip->b4,
			ip->s_port,ip->d_port);
		if (rv < 0) {
			syslog(LOG_ERR, "snprintf failed in line %d: %s",
				__LINE__, strerror(errno));
			exit(1);
		}
	return;
}

#ifdef USE_SOCKSTAT
/*
 * SYNOPSIS:
 *   void *pbl_sockstat_thread(