void JsonIRReader::ReadLvalueReferenceTypes(const JsonObjectRef &tu) { for (auto &&lvalue_reference_type : tu.GetObjects("lvalue_reference_types")) { LvalueReferenceTypeIR lvalue_reference_type_ir; ReadTypeInfo(lvalue_reference_type, &lvalue_reference_type_ir); module_->AddLvalueReferenceType(std::move(lvalue_reference_type_ir)); } }
void JsonIRReader::ReadRvalueReferenceTypes(const JsonObjectRef &tu) { for (auto &&rvalue_reference_type : tu.GetObjects("rvalue_reference_types")) { RvalueReferenceTypeIR rvalue_reference_type_ir; ReadTypeInfo(rvalue_reference_type, &rvalue_reference_type_ir); module_->AddRvalueReferenceType(std::move(rvalue_reference_type_ir)); } }
void JsonIRReader::ReadPointerTypes(const JsonObjectRef &tu) { for (auto &&pointer_type : tu.GetObjects("pointer_types")) { PointerTypeIR pointer_type_ir; ReadTypeInfo(pointer_type, &pointer_type_ir); module_->AddPointerType(std::move(pointer_type_ir)); } }
void JsonIRReader::ReadArrayTypes(const JsonObjectRef &tu) { for (auto &&array_type : tu.GetObjects("array_types")) { ArrayTypeIR array_type_ir; ReadTypeInfo(array_type, &array_type_ir); module_->AddArrayType(std::move(array_type_ir)); } }
FunctionTypeIR JsonIRReader::FunctionTypeJsonToIR(const JsonObjectRef &function_type) { FunctionTypeIR function_type_ir; ReadTypeInfo(function_type, &function_type_ir); ReadFunctionParametersAndReturnType(function_type, &function_type_ir); return function_type_ir; }
void JsonIRReader::ReadBuiltinTypes(const JsonObjectRef &tu) { for (auto &&builtin_type : tu.GetObjects("builtin_types")) { BuiltinTypeIR builtin_type_ir; ReadTypeInfo(builtin_type, &builtin_type_ir); builtin_type_ir.SetSignedness(builtin_type.GetBool("is_unsigned")); builtin_type_ir.SetIntegralType(builtin_type.GetBool("is_integral")); module_->AddBuiltinType(std::move(builtin_type_ir)); } }
EnumTypeIR JsonIRReader::EnumTypeJsonToIR(const JsonObjectRef &enum_type) { EnumTypeIR enum_type_ir; ReadTypeInfo(enum_type, &enum_type_ir); enum_type_ir.SetUnderlyingType(enum_type.GetString("underlying_type")); enum_type_ir.SetAccess(GetAccess(enum_type)); ReadEnumFields(enum_type, &enum_type_ir); ReadTagTypeInfo(enum_type, &enum_type_ir); return enum_type_ir; }
void JsonIRReader::ReadQualifiedTypes(const JsonObjectRef &tu) { for (auto &&qualified_type : tu.GetObjects("qualified_types")) { QualifiedTypeIR qualified_type_ir; ReadTypeInfo(qualified_type, &qualified_type_ir); qualified_type_ir.SetConstness(qualified_type.GetBool("is_const")); qualified_type_ir.SetVolatility(qualified_type.GetBool("is_volatile")); qualified_type_ir.SetRestrictedness( qualified_type.GetBool("is_restricted")); module_->AddQualifiedType(std::move(qualified_type_ir)); } }
RecordTypeIR JsonIRReader::RecordTypeJsonToIR(const JsonObjectRef &record_type) { RecordTypeIR record_type_ir; ReadTypeInfo(record_type, &record_type_ir); ReadTemplateInfo(record_type, &record_type_ir); record_type_ir.SetAccess(GetAccess(record_type)); ReadVTableLayout(record_type, &record_type_ir); ReadRecordFields(record_type, &record_type_ir); ReadBaseSpecifiers(record_type, &record_type_ir); record_type_ir.SetRecordKind(GetRecordKind(record_type)); record_type_ir.SetAnonymity(record_type.GetBool("is_anonymous")); ReadTagTypeInfo(record_type, &record_type_ir); return record_type_ir; }
int DP_Attack_Load_Line(FILE *fp, int line) { uint32_t intf = 0; uint32_t type = 0; char validfilter; //validfilter means an '@' while(!feof(fp)) { if(0 != fscanf(fp,"%c",&validfilter)) { //printf (">> [err] ill-format @ rule-file\n"); //return -1; } if (validfilter != '@') //each rule should begin with an '@' { continue; } if(0 != ReadInterfaceInfo(fp, line, &intf)) { return -1; } #ifdef ATTACK_DEBUG printf("interface is %d\n", intf); #endif if(intf >= OCT_PHY_PORT_MAX) { printf("error interface is %d\n", intf); return -1; } if(intf < OCT_PHY_PORT_MAX) { if(0 != ReadTypeInfo(fp, line, &type)) { return -1; } #ifdef ATTACK_DEBUG printf("type is %d\n", type); #endif if(type == PACKET_DELETE_TYPE) { if(0 != ReadDroppackInfo(fp, line, &attackrule_tmp.pkt_detect_rule.pd[intf].drop_pack)) { return -1; } if(0 != ReadLandInfo(fp, line, &attackrule_tmp.pkt_detect_rule.pd[intf].land)) { return -1; } if(0 != ReadTeardropInfo(fp, line, &attackrule_tmp.pkt_detect_rule.pd[intf].teardrop)) { return -1; } if(0 != ReadPingdeathInfo(fp, line, &attackrule_tmp.pkt_detect_rule.pd[intf].pingdeath)) { return -1; } if(0 != ReadPingdeathvalueInfo(fp, line, &attackrule_tmp.pkt_detect_rule.pd[intf].pingdeath_value)) { return -1; } } else if(type == TRAFFIC_DELETE_TYPE) { if(0 != ReadDroppackInfo(fp, line, &attackrule_tmp.tfc_detect_rule.td[intf].drop_pack)) { return -1; } if(0 != Readflood_pingInfo(fp, line, &attackrule_tmp.tfc_detect_rule.td[intf].flood_ping)) { return -1; } if(0 != Readping_speedInfo(fp, line, &attackrule_tmp.tfc_detect_rule.td[intf].ping_speed)) { return -1; } if(0 != Readflood_udpInfo(fp, line, &attackrule_tmp.tfc_detect_rule.td[intf].flood_udp)) { return -1; } if(0 != Readudp_speedInfo(fp, line, &attackrule_tmp.tfc_detect_rule.td[intf].udp_speed)) { return -1; } if(0 != Readflood_synInfo(fp, line, &attackrule_tmp.tfc_detect_rule.td[intf].flood_syn)) { return -1; } if(0 != Readsyn_speedInfo(fp, line, &attackrule_tmp.tfc_detect_rule.td[intf].syn_speed)) { return -1; } if(0 != Readsyn_countInfo(fp, line, &attackrule_tmp.tfc_detect_rule.td[intf].syn_count)) { return -1; } } else { printf("dp attack load rule type error %d\n", type); } } return 0; } return 0; }