identification_type identify_flow (flow_table_t::iterator it_flows, const u_int16_t dport, const u_char * payload) { identification_table_t::iterator it_lower; identification_table_t::iterator it_upper; bool recent_lower, recent_upper, certain_lower, certain_upper; recent_lower = recent_upper = certain_lower = certain_upper = false; uint i; // check ports // if dport in port list, it's certain P2P for (i=0; i<port_num; i++) { if (dport == ports[i]) { #if DEBUG >= 2 cout << "port_match " << dport << "\n"; #endif update_flow(it_flows, true); //update_flow(it_flows, false); it_flows->second.id_type = port_match; return (port_match); } } // check the payload // if we find a signature, it's certain P2P for (i=0; i<sig_num; i++) { if (memcmp(payload,signatures[i],4) == 0) { #if DEBUG >= 2 cout << "payload_match " << payload << "\n"; #endif update_flow(it_flows, true); //update_flow(it_flows, false); it_flows->second.id_type = payload_match; return (payload_match); } } // get {recent,certain}_{lower,upper} it_lower = services.find(*(it_flows->first.lower)); it_upper = services.find(*(it_flows->first.upper)); //struct timeval tv_delta; if (it_lower != services.end()) { certain_lower = it_lower->second.certain; long delta = abs(it_flows->second.touched.tv_sec - it_lower->second.touched.tv_sec); recent_lower = certain_lower ? delta <= optargs->t_long : delta <= optargs->t_short; } if (it_upper != services.end()) { certain_lower = it_upper->second.certain; long delta = abs(it_flows->second.touched.tv_sec - it_upper->second.touched.tv_sec); recent_lower = certain_lower ? delta <= optargs->t_long : delta <= optargs->t_short; } #if DEBUG >= 2 cout << "(recent_certain) " << recent_lower << certain_lower << recent_upper << certain_upper << endl; #endif // protocol dependent identification TCP if (it_flows->first.ip_p == IPPROTO_TCP) { if (recent_lower || recent_upper) { #if DEBUG >= 2 cout << "tcp_certain\n"; #endif update_flow(it_flows, true); it_flows->second.id_type = tcp_certain; return (tcp_certain); } else { it_flows->second.flow_type = type_nonp2p; #if DEBUG >= 2 cout << "tcp_none\n"; #endif it_flows->second.id_type = tcp_none; return (tcp_none); } } // protocol dependent identification UDP if (it_flows->first.ip_p == IPPROTO_UDP) { if ((recent_lower && certain_lower) || (recent_upper && certain_upper)) { #if DEBUG >= 2 cout << "udp_certain\n"; #endif update_flow(it_flows, true); it_flows->second.id_type = udp_certain; return (udp_certain); } #if DEBUG >= 2 cout << "udp_uncertain\n"; #endif update_flow(it_flows, false); it_flows->second.id_type = udp_uncertain; return (udp_uncertain); } // if we reach this point, we can't identify the flow as P2P #if DEBUG >= 2 cout << "no_match\n"; #endif it_flows->second.flow_type = type_nonp2p; it_flows->second.id_type = no_match; return (no_match); }
/* * Handle "p_ptr->update" */ void update_stuff(void) { /* Update stuff */ if (!p_ptr->update) return; if (p_ptr->update & (PU_BONUS)) { p_ptr->update &= ~(PU_BONUS); update_bonuses(); } if (p_ptr->update & (PU_TORCH)) { p_ptr->update &= ~(PU_TORCH); calc_torch(); } if (p_ptr->update & (PU_HP)) { p_ptr->update &= ~(PU_HP); calc_hitpoints(); } if (p_ptr->update & (PU_MANA)) { p_ptr->update &= ~(PU_MANA); calc_mana(); } if (p_ptr->update & (PU_SPELLS)) { p_ptr->update &= ~(PU_SPELLS); calc_spells(); } /* Character is not ready yet, no screen updates */ if (!character_generated) return; /* Character is in "icky" mode, no screen updates */ if (character_icky) return; if (p_ptr->update & (PU_FORGET_VIEW)) { p_ptr->update &= ~(PU_FORGET_VIEW); forget_view(); } if (p_ptr->update & (PU_UPDATE_VIEW)) { p_ptr->update &= ~(PU_UPDATE_VIEW); update_view(); } if (p_ptr->update & (PU_FORGET_FLOW)) { p_ptr->update &= ~(PU_FORGET_FLOW); forget_flow(); } if (p_ptr->update & (PU_UPDATE_FLOW)) { p_ptr->update &= ~(PU_UPDATE_FLOW); update_flow(); } if (p_ptr->update & (PU_DISTANCE)) { p_ptr->update &= ~(PU_DISTANCE); p_ptr->update &= ~(PU_MONSTERS); update_monsters(TRUE); } if (p_ptr->update & (PU_MONSTERS)) { p_ptr->update &= ~(PU_MONSTERS); update_monsters(FALSE); } if (p_ptr->update & (PU_PANEL)) { p_ptr->update &= ~(PU_PANEL); event_signal(EVENT_PLAYERMOVED); } }