/* The list of known types of default packet. */
static char *_default_packet_types[] = {
"ddos client quota", "ddos server quota",
"blocked ports", "blocked sites",
"ip scan", "port scan",
"ip source route", "icmp flooding",
"ike flooding", "ipsec flooding",
"ip spoofing sites", "syn flooding",
"udp flooding", "tcp syn checking failed",
NULL
};
// 自己寫的函數,用packetTable中的->_msg, 和上面的_default_packet_types裡的元素進行比較,如果相等則跳出,否則繼續循環
boolean pr_get_default_packet_flag_from_msg(PacketFilterMessageTable *packetTable, char **packetType)
{
char *p_msg = NULL;
wgpr_boolean flag = FALSE;
char **type_ptr = NULL;
/* Sanity check */
if (!packetTable) {
return flag;
}
if (packetTable->_tag_id != FWDENY_TAG ||
packetTable->_msg == NULL ||
packetTable->_msg[0] == '\0') {
return flag;
}
p_msg = packetTable->_msg;
for (type_ptr = _default_packet_types; *type_ptr != NULL; type_ptr++) {
if (!strncasecmp(p_msg, *type_ptr, sizeof(*type_ptr) - 1)) {
flag = TRUE;
break;
}
}
*packetType = flag == TRUE ? DEFAULTPACKET : DENIEDPACKET;
return flag;
}
//調用上述函數的代碼片段
if(pr_get_default_packet_flag_from_msg(pk_t, &packetType)){
is_dflt_packet = TRUE;
}