int Active_ForceDropAction(Packet *p) { if ( !IsIP(p) ) return 0; // explicitly drop packet Active_ForceDropPacket(); switch ( GET_IPH_PROTO(p) ) { case IPPROTO_TCP: case IPPROTO_UDP: Active_DropSession(); _Active_ForceIgnoreSession(p); } return 0; }
HeapString IPAddress::IPString() const { if (IsIP()) { HeapString str(INET_ADDRSTRLEN + 5); ::inet_ntop(AF_INET, (void*)&mAddress.sin_addr, str.c_str(), static_cast<socklen_t>(INET_ADDRSTRLEN)); str.ForceUpdateLength(); return str; } else { HeapString str(INET6_ADDRSTRLEN + 5); ::inet_ntop(AF_INET, (void*)&mAddress6.sin6_addr, str.c_str(), static_cast<socklen_t>(INET_ADDRSTRLEN)); str.ForceUpdateLength(); return str; } }
void Active_KillSession (Packet* p, EncodeFlags* pf) { EncodeFlags flags = pf ? *pf : ENC_FLAG_FWD; if ( !IsIP(p) ) return; switch ( GET_IPH_PROTO(p) ) { case IPPROTO_TCP: Active_SendReset(p, 0); if ( flags & ENC_FLAG_FWD ) Active_SendReset(p, ENC_FLAG_FWD); break; default: if ( Active_PacketForceDropped() ) Active_SendUnreach(p, ENC_UNR_FW); else Active_SendUnreach(p, ENC_UNR_PORT); break; } }
bool SelectSIPAccount(CString number, pjsua_acc_id &acc_id, pj_str_t &pj_uri) { SIPURI sipuri; ParseSIPURI(number, &sipuri); if (pjsua_acc_is_valid(account) && pjsua_acc_is_valid(account_local)) { acc_id = account; if (accountSettings.account.domain != sipuri.domain) { int pos = sipuri.domain.Find(_T(":")); CString domainWithoutPort = RemovePort(sipuri.domain); if (domainWithoutPort.CompareNoCase(_T("localhost"))==0 || IsIP(domainWithoutPort)) { acc_id = account_local; } } } else if (pjsua_acc_is_valid(account)) { acc_id = account; } else if (pjsua_acc_is_valid(account_local)) { acc_id = account_local; } else { return false; } pj_uri = StrToPjStr ( GetSIPURI(number, acc_id == account_local, acc_id == account_local) ); return true; }