| 1085 | } |
| 1086 | |
| 1087 | static int |
| 1088 | pf_setup_pfsync_matching(struct pf_kruleset *rs) |
| 1089 | { |
| 1090 | MD5_CTX ctx; |
| 1091 | struct pf_krule *rule; |
| 1092 | int rs_cnt; |
| 1093 | u_int8_t digest[PF_MD5_DIGEST_LENGTH]; |
| 1094 | |
| 1095 | MD5Init(&ctx); |
| 1096 | for (rs_cnt = 0; rs_cnt < PF_RULESET_MAX; rs_cnt++) { |
| 1097 | /* XXX PF_RULESET_SCRUB as well? */ |
| 1098 | if (rs_cnt == PF_RULESET_SCRUB) |
| 1099 | continue; |
| 1100 | |
| 1101 | if (rs->rules[rs_cnt].inactive.ptr_array) |
| 1102 | free(rs->rules[rs_cnt].inactive.ptr_array, M_TEMP); |
| 1103 | rs->rules[rs_cnt].inactive.ptr_array = NULL; |
| 1104 | |
| 1105 | if (rs->rules[rs_cnt].inactive.rcount) { |
| 1106 | rs->rules[rs_cnt].inactive.ptr_array = |
| 1107 | malloc(sizeof(caddr_t) * |
| 1108 | rs->rules[rs_cnt].inactive.rcount, |
| 1109 | M_TEMP, M_NOWAIT); |
| 1110 | |
| 1111 | if (!rs->rules[rs_cnt].inactive.ptr_array) |
| 1112 | return (ENOMEM); |
| 1113 | } |
| 1114 | |
| 1115 | TAILQ_FOREACH(rule, rs->rules[rs_cnt].inactive.ptr, |
| 1116 | entries) { |
| 1117 | pf_hash_rule(&ctx, rule); |
| 1118 | (rs->rules[rs_cnt].inactive.ptr_array)[rule->nr] = rule; |
| 1119 | } |
| 1120 | } |
| 1121 | |
| 1122 | MD5Final(digest, &ctx); |
| 1123 | memcpy(V_pf_status.pf_chksum, digest, sizeof(V_pf_status.pf_chksum)); |
| 1124 | return (0); |
| 1125 | } |
| 1126 | |
| 1127 | static int |
| 1128 | pf_addr_setup(struct pf_kruleset *ruleset, struct pf_addr_wrap *addr, |
no test coverage detected