Lines 4418-4423
ipf_matchicmpqueryreply(v, ic, icmp, rev)
Link Here
|
4418 |
} |
4418 |
} |
4419 |
|
4419 |
|
4420 |
|
4420 |
|
|
|
4421 |
/* |
4422 |
* IFNAMES are located in the variable length field starting at |
4423 |
* frentry.fr_names. As pointers within the struct cannot be passed |
4424 |
* to the kernel from ipf(8), an offset is used. An offset of -1 means it |
4425 |
* is unused (invalid). If it is used (valid) it is an offset to the |
4426 |
* character string of an interface name or a comment. The following |
4427 |
* macros will assist those who follow to understand the code. |
4428 |
*/ |
4429 |
#define IPF_IFNAME_VALID(_a) (_a != -1) |
4430 |
#define IPF_IFNAME_INVALID(_a) (_a == -1) |
4431 |
#define IPF_IFNAMES_DIFFERENT(_a) \ |
4432 |
!( (IPF_IFNAME_INVALID(fr1->_a) && \ |
4433 |
IPF_IFNAME_INVALID(fr2->_a)) || \ |
4434 |
(IPF_IFNAME_VALID(fr1->_a) && \ |
4435 |
IPF_IFNAME_VALID(fr2->_a) && \ |
4436 |
!strcmp(FR_NAME(fr1, _a), FR_NAME(fr2, _a)))) |
4437 |
|
4438 |
|
4421 |
/* ------------------------------------------------------------------------ */ |
4439 |
/* ------------------------------------------------------------------------ */ |
4422 |
/* Function: ipf_rule_compare */ |
4440 |
/* Function: ipf_rule_compare */ |
4423 |
/* Parameters: fr1(I) - first rule structure to compare */ |
4441 |
/* Parameters: fr1(I) - first rule structure to compare */ |
Lines 4430-4451
ipf_matchicmpqueryreply(v, ic, icmp, rev)
Link Here
|
4430 |
static int |
4448 |
static int |
4431 |
ipf_rule_compare(frentry_t *fr1, frentry_t *fr2) |
4449 |
ipf_rule_compare(frentry_t *fr1, frentry_t *fr2) |
4432 |
{ |
4450 |
{ |
|
|
4451 |
int i; |
4452 |
|
4433 |
if (fr1->fr_cksum != fr2->fr_cksum) |
4453 |
if (fr1->fr_cksum != fr2->fr_cksum) |
4434 |
return (1); |
4454 |
return (1); |
4435 |
if (fr1->fr_size != fr2->fr_size) |
4455 |
if (fr1->fr_size != fr2->fr_size) |
4436 |
return (2); |
4456 |
return (2); |
4437 |
if (fr1->fr_dsize != fr2->fr_dsize) |
4457 |
if (fr1->fr_dsize != fr2->fr_dsize) |
4438 |
return (3); |
4458 |
return (3); |
4439 |
if (bcmp((char *)&fr1->fr_func, (char *)&fr2->fr_func, FR_CMPSIZ(fr1)) |
4459 |
if (bcmp((char *)&fr1->fr_func, (char *)&fr2->fr_func, FR_CMPSIZ) |
4440 |
!= 0) |
4460 |
!= 0) |
4441 |
return (4); |
4461 |
return (4); |
|
|
4462 |
/* |
4463 |
* XXX: There is still a bug here as different rules with the |
4464 |
* the same interfaces but in a different order will compare |
4465 |
* differently. But since multiple interfaces in a rule doesn't |
4466 |
* work anyway a simple straightforward compare is performed |
4467 |
* here. Ultimately frentry_t creation will need to be |
4468 |
* revisited in ipf_y.y, fixing both issues for good. |
4469 |
*/ |
4470 |
for (i = 0; i < FR_NUM(fr1->fr_ifnames); i++) { |
4471 |
/* |
4472 |
* XXX: It's either the same index or uninitialized. |
4473 |
* We assume this because multiple interfaces |
4474 |
* referenced by the same rule doesn't work anyway. |
4475 |
*/ |
4476 |
if (IPF_IFNAMES_DIFFERENT(fr_ifnames[1])) |
4477 |
return(5); |
4478 |
} |
4479 |
|
4480 |
if (memcmp(&fr1->fr_tif.fd_addr, &fr2->fr_tif.fd_addr, |
4481 |
offsetof(frdest_t, fd_name) - offsetof(frdest_t, fd_addr)) || |
4482 |
IPF_IFNAMES_DIFFERENT(fr_tif.fd_name)) |
4483 |
return (6); |
4484 |
if (memcmp(&fr1->fr_rif.fd_addr, &fr2->fr_rif.fd_addr, |
4485 |
offsetof(frdest_t, fd_name) - offsetof(frdest_t, fd_addr)) || |
4486 |
IPF_IFNAMES_DIFFERENT(fr_rif.fd_name)) |
4487 |
return (7); |
4488 |
if (memcmp(&fr1->fr_dif.fd_addr, &fr2->fr_dif.fd_addr, |
4489 |
offsetof(frdest_t, fd_name) - offsetof(frdest_t, fd_addr)) || |
4490 |
IPF_IFNAMES_DIFFERENT(fr_rif.fd_name)) |
4491 |
return (8); |
4442 |
if (!fr1->fr_data && !fr2->fr_data) |
4492 |
if (!fr1->fr_data && !fr2->fr_data) |
4443 |
return (0); /* move along, nothing to see here */ |
4493 |
return (0); /* move along, nothing to see here */ |
4444 |
if (fr1->fr_data && fr2->fr_data) { |
4494 |
if (fr1->fr_data && fr2->fr_data) { |
4445 |
if (bcmp(fr1->fr_caddr, fr2->fr_caddr, fr1->fr_dsize) == 0) |
4495 |
if (bcmp(fr1->fr_caddr, fr2->fr_caddr, fr1->fr_dsize) == 0) |
4446 |
return (0); /* same */ |
4496 |
return (0); /* same */ |
4447 |
} |
4497 |
} |
4448 |
return (5); |
4498 |
return (9); |
4449 |
} |
4499 |
} |
4450 |
|
4500 |
|
4451 |
|
4501 |
|