Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

util.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Include dependency graph for util.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Classes

struct  ltstr

Defines

#define myattribute(x)
#define ASSERT(x)
#define DEBUG_MSG(x...)
#define DEBUG_fputs(x...)
#define padded_sizeof(x)   (pad_size(sizeof(x)))

Typedefs

typedef unsigned int uint32
typedef unsigned short uint16
typedef unsigned char uint8

Functions

char * copy_string (const char *s)
int streq (const char *s1, const char *s2)
int expand_escape (const char *&s)
char * skip_whitespace (char *s)
const char * skip_whitespace (const char *s)
char * skip_whitespace (char *s, char *end_of_s)
const char * skip_whitespace (const char *s, const char *end_of_s)
char * skip_digits (char *s)
char * get_word (char *&s)
void get_word (int length, const char *s, int &pwlen, const char *&pw)
void to_upper (char *s)
const char * strchr_n (const char *s, const char *end_of_s, char ch)
const char * strrchr_n (const char *s, const char *end_of_s, char ch)
int decode_hex (char ch)
unsigned char encode_hex (int h)
int strcasecmp_n (int s_len, const char *s, const char *t)
const char * strpbrk_n (size_t len, const char *s, const char *charset)
int atoi_n (int len, const char *s, const char **end, int base, int &result)
int fputs (int len, const char *s, FILE *fp)
bool is_printable (const char *s, int len)
const char * fmt (const char *format,...) myattribute((format(printf
void fmt (int &len, const char *&b, const char *format,...) myattribute((format(printf
const char * fmt_access_time (double time)
void hash_md5 (size_t size, const unsigned char *bytes, unsigned char digest[16])
void hmac_md5 (size_t size, const unsigned char *bytes, unsigned char digest[16])
const char * md5_digest_print (const unsigned char digest[16])
void init_random_seed ()
void message (const char *msg)
void warn (const char *msg)
void warn (const char *msg, const char *addl)
void error (const char *msg)
void error (const char *msg, const char *addl)
void error (const char *msg, uint32 addl)
void run_time (const char *msg)
void run_time (const char *fmt, BroObj *obj)
void run_time (const char *fmt, const char *arg)
void run_time (const char *fmt, const char *arg1, const char *arg2)
void internal_error (const char *fmt,...) myattribute((volatile
void format (printf, 1, 2)))
void pinpoint ()
int int_list_cmp (const void *v1, const void *v2)
const char * bro_path ()
const char * bro_prefixes ()
FILE * search_for_file (const char *filename, const char *ext, const char **full_filename)
double current_time ()
int min (int a, int b)
int max (int a, int b)
size_t pad_size (size_t size)
void out_of_memory (const char *where)
void * safe_realloc (void *ptr, size_t size)
void * safe_malloc (size_t size)

Variables

uint8 shared_hmac_md5_key [16]
int hmac_key_set
double network_time


Define Documentation

#define ASSERT  ) 
 

Definition at line 45 of file util.h.

Referenced by PacketSortGlobalPQ::Add(), TCP_TracePacket::Append(), TCP_TracePacket::AppendData(), MIME_Entity::BeginChildEntity(), MIME_Mail::BeginEntity(), HTTP_Entity::Deliver(), TCP_Contents_DCE_RPC::Deliver(), dispatch_next_packet(), TCP_RewriterEndpoint::DoWriteData(), MIME_Entity::EndChildEntity(), TCP_TracePacket::Finish(), TCP_TracePacket::GetAck(), TCP_TracePacket::GetSeq(), TCP_TracePacket::GetTCP_Flag(), MIME_Entity::NewHeader(), TCP_TracePacket::SetAck(), TCP_TracePacket::SetSeq(), and TCP_TracePacket::SetTCP_Flag().

#define DEBUG_fputs x...   ) 
 

Definition at line 47 of file util.h.

Referenced by MIME_Entity::DebugPrintHeaders().

#define DEBUG_MSG x...   ) 
 

Definition at line 46 of file util.h.

Referenced by PacketSortConnPQ::Add(), TCP_TracePacket::AppendData(), TCP_TracePacket::AppendTCPHeader(), MIME_Entity::CheckBoundaryDelimiter(), MIME_Entity::DebugPrintHeaders(), main(), net_finish(), PacketSortElement::PacketSortElement(), AnonymizeIPAddr_A50::PreservePrefix(), and TCP_RewriterEndpoint::PushPacket().

#define myattribute  ) 
 

Definition at line 32 of file util.h.

#define padded_sizeof  )     (pad_size(sizeof(x)))
 

Definition at line 186 of file util.h.

Referenced by DataBlock::DataBlock(), DFA_State_Cache::GetStats(), StatsLogger::Log(), SubNetVal::MemoryAllocation(), RecordVal::MemoryAllocation(), TableVal::MemoryAllocation(), ListVal::MemoryAllocation(), PatternVal::MemoryAllocation(), StringVal::MemoryAllocation(), AddrVal::MemoryAllocation(), Val::MemoryAllocation(), UDP_Connection::MemoryAllocation(), TypeList::MemoryAllocation(), BroType::MemoryAllocation(), TCP_Connection::MemoryAllocation(), NetSessions::MemoryAllocation(), RE_Matcher::MemoryAllocation(), Specific_RE_Matcher::MemoryAllocation(), NFA_Machine::MemoryAllocation(), BaseList::MemoryAllocation(), ICMP_Connection::MemoryAllocation(), HashKey::MemoryAllocation(), Dictionary::MemoryAllocation(), DFA_Machine::MemoryAllocation(), Connection::MemoryAllocation(), CompositeHash::MemoryAllocation(), CCL::MemoryAllocation(), BroString::MemoryAllocation(), EquivClass::Size(), DFA_State::Size(), NFA_State::TotalMemoryAllocation(), and DataBlock::~DataBlock().


Typedef Documentation

typedef unsigned short uint16
 

Definition at line 52 of file util.h.

Referenced by RemoteSerializer::AddPeer(), EventHandler::AddRemoteHandler(), SSL_Interpreter::analyzeCertificate(), SSLv3_Interpreter::analyzeCiphers(), SSL_RecordBuilder::analyzeSSLRecordFormat(), ConnID::BuildConnKey(), buildHash(), SSLv3_HandshakeRecord::checkClientHello(), SSLv3_HandshakeRecord::checkServerHello(), SSLv2_Interpreter::ClientHelloRecord(), SSLv2_Interpreter::ClientMasterKeyRecord(), RemoteSerializer::Connect(), SSLv3_Endpoint::Deliver(), SSLv3_Interpreter::DeliverSSLv3_Record(), SerialObj::DoSerialize(), SSLv3_Endpoint::ExtractVersion(), SSL_Interpreter::fire_ssl_conn_alert(), SSL_Interpreter::fire_ssl_conn_attempt(), SSL_Interpreter::fire_ssl_conn_established(), SSL_Interpreter::fire_ssl_conn_server_reply(), IP_Hdr::FragField(), getval(), HashKey::HashBytes(), IP_Hdr::HdrLen(), IP_Hdr::ID4(), SocketComm::Listen(), RemoteSerializer::Listen(), RemoteSerializer::LookupPeer(), SSL_ConnectionProxy::NewSSLRecord(), NextIP_ID(), TCP_Connection::NextPacket(), IP_Hdr::PayloadLen(), FileSerializer::PrepareForWriting(), RemoteSerializer::RaiseEvent(), XMLSerializationFormat::Read(), BinarySerializationFormat::Read(), FileSerializer::ReadHeader(), EventHandler::Receiver::Receiver(), RemoteSerializer::RemovePeer(), EventHandler::RemoveRemoteHandler(), RemoteSerializer::Request(), RemoteSerializer::SendCall(), RemoteSerializer::SendCaptureFilter(), sendCMsg(), RemoteSerializer::SendConnection(), SocketComm::SendError(), RemoteSerializer::SendID(), PersistenceSerializer::SendState(), SSLv2_Interpreter::ServerHelloRecord(), RemoteSerializer::SetAcceptState(), SSLv3_AlertRecord::SSLv3_AlertRecord(), SSLv3_ApplicationRecord::SSLv3_ApplicationRecord(), SSLv3_ChangeCipherRecord::SSLv3_ChangeCipherRecord(), SSLv3_HandshakeRecord::SSLv3_HandshakeRecord(), SSLv3_Record::SSLv3_Record(), IP_Hdr::TotalLen(), SerialObj::Unserialize(), XMLSerializationFormat::Write(), and BinarySerializationFormat::Write().

uint32
 

Definition at line 51 of file util.h.

Referenced by TCP_Endpoint::AckSeq(), PacketSortConnPQ::Add(), ODesc::Add(), PacketFilter::AddDst(), FragReassembler::AddFragment(), Rule::AddPattern(), addr_eq(), addr_port_canon_lt(), addr_to_class(), addr_to_net(), AddrVal::AddrVal(), PacketFilter::AddSrc(), SSL_Interpreter::analyzeCertificate(), SSLv3_Interpreter::analyzeCiphers(), SSLv2_Interpreter::analyzeCiphers(), bi_ffs(), MutableVal::Bind(), SSL_ConnectionProxy::BuildCipherDict(), ConnID::BuildConnKey(), Discarder::BuildHeader(), CertStore::CertStore(), PortmapperInterp::CheckPort(), ChunkedIOFd::ChunkAvailable(), SSLv2_Interpreter::ClientMasterKeyRecord(), Val::CoerceToUnsigned(), CompositeHash::ComputeSingletonHash(), SubNetVal::Contains(), copy_addr(), TCP_Contents::DataPending(), Base64Decoder::Decode(), TCP_Contents_RPC::Deliver(), RPC_Interpreter::DeliverRPC(), SSLv3_Interpreter::DeliverSSLv3_Record(), DNS_Mapping::DNS_Mapping(), DNS_Mgr_Request::DNS_Mgr_Request(), RuleConditionPayloadSize::DoMatch(), NetSessions::DoNextPacket(), ArithCoerceExpr::DoSimplify(), dotted_addr(), dotted_net(), dotted_net6(), dotted_to_addr(), IP_Hdr::DstAddr(), IP_Hdr::DstAddr4(), SerializationFormat::EndWrite(), error(), extract_XDR_uint32(), ChunkedIOFd::ExtractChunk(), SSLv3_Record::ExtractInt24(), DNS_Interpreter::ExtractLong(), PortmapperInterp::ExtractMapping(), SSL_Interpreter::fire_ssl_conn_established(), PacketSortPQ::FixDown(), ChunkedIOFd::FlushWriteBuffer(), BinaryExpr::Fold(), Val::ForceAsUInt(), FragReassembler::FragReassembler(), get_map_result(), TCP_TracePacket::GetAck(), TCP_TracePacket::GetSeq(), getval(), HashKey::HashBytes(), HashKey::HashKey(), icmp_checksum(), id_to_uint(), SubNetVal::Init(), AddrVal::Init(), DNS_Mapping::Init(), init_random_seed(), Val::InternalUnsigned(), ip2a(), NetSessions::IsLikelyServerPort(), TCP_Connection::IsReuse(), TCP_Endpoint::LastSeq(), load_mapping_table(), DNS_Mgr::LookupAddr(), make_prefix(), SubNetVal::Mask(), mask_addr(), AddrVal::MemoryAllocation(), NetVal::NetVal(), NetSessions::NewConn(), FTP_Conn::NewLine(), SSLv2_Interpreter::NewSSLRecord(), NetSessions::NextFragment(), ICMP_Unreach::NextICMP(), NextIP_ID(), TCP_Connection::NextPacket(), NetSessions::NextPacket(), Discarder::NextPacket(), NetSessions::NextPacketSecondary(), TCP_RewriterEndpoint::NextSeq(), ones_complement_checksum(), Connection::OrigAddr(), Connection::OrigPort(), TCP_Connection::OrigSeq(), PacketSortElement::PacketSortElement(), parse_dotted(), DNS_Interpreter::ParseRR_A(), DNS_Interpreter::ParseRR_SOA(), HTTP_Conn::ParseVersion(), PktInterfaceSrc::PktInterfaceSrc(), PortVal::Port(), PortVal::PortVal(), FileSerializer::PrepareForWriting(), AnonymizeIPAddr_A50::PreservePrefix(), RPC_CallInfo::Proc(), RPC_CallInfo::Program(), ChunkedIOFd::PutIntoWriteBuffer(), rand32(), raw_bytes_to_addr(), XMLSerializationFormat::Read(), BinarySerializationFormat::Read(), FileSerializer::ReadHeader(), Reassembler::Reassembler(), recover_val(), DNS_Mapping::ReqAddr(), DNS_Mgr_Request::ReqAddr(), Connection::RespAddr(), Connection::RespPort(), TCP_Connection::RespSeq(), PortmapperInterp::RPC_BuildReply(), RPC_CallInfo::RPC_CallInfo(), RuleConditionPayloadSize::RuleConditionPayloadSize(), RuleHdrTest::RuleHdrTest(), seq_between(), seq_delta(), SSLv2_Interpreter::ServerHelloRecord(), TCP_TracePacket::SetAck(), TCP_TracePacket::SetSeq(), skip_XDR_opaque_auth(), IP_Hdr::SrcAddr(), IP_Hdr::SrcAddr4(), SerializationFormat::StartRead(), TCP_Endpoint::StartSeq(), SubNetVal::SubNetVal(), tcp_checksum(), TCP_Reassembler::TCP_Reassembler(), to_v4_addr(), udp_checksum(), Connection::UnparsedVersionFoundEvent(), Val::Val(), PortVal::ValDescribe(), TCP_Endpoint::ValidChecksum(), X509_Cert::verify(), X509_Cert::verifyChain(), RPC_CallInfo::Version(), Connection::VersionFoundEvent(), XMLSerializationFormat::Write(), BinarySerializationFormat::Write(), ChunkedIOFd::Write(), and ChunkedIOFd::WriteChunk().

typedef unsigned char uint8
 

Definition at line 53 of file util.h.

Referenced by SSL_RecordBuilder::addSegment(), SSL_Interpreter::analyzeCertificate(), SSL_RecordBuilder::analyzeSSLRecordFormat(), AnonymizeIPAddr_PrefixMD5::anonymize(), AnonymizeIPAddr_RandomMD5::anonymize(), bi_ffs(), SSLv3_HandshakeRecord::checkClientHello(), SSLv3_HandshakeRecord::checkServerHello(), SSLv3_Interpreter::DeliverSSLv3_Record(), SSLv3_Endpoint::ExtractContentType(), getval(), HashKey::HashBytes(), SSLv2_Interpreter::NewSSLRecord(), SSLv3_AlertRecord::SSLv3_AlertRecord(), SSLv3_ChangeCipherRecord::SSLv3_ChangeCipherRecord(), and SSLv3_HandshakeRecord::SSLv3_HandshakeRecord().


Function Documentation

int atoi_n int  len,
const char *  s,
const char **  end,
int  base,
int &  result
 

Definition at line 278 of file util.cc.

Referenced by HTTP_Entity::Deliver(), and HTTP_Entity::SubmitHeader().

00279         {
00280         int n = 0;
00281         int neg = 0;
00282 
00283         if ( len > 0 && *s == '-' )
00284                 {
00285                 neg = 1;
00286                 --len; ++s;
00287                 }
00288 
00289         int i;
00290         for ( i = 0; i < len; ++i )
00291                 {
00292                 unsigned int d;
00293 
00294                 if ( isdigit(s[i]) )
00295                         d = s[i] - '0';
00296 
00297                 else if ( s[i] >= 'a' && s[i] < 'a' - 10 + base )
00298                         d = s[i] - 'a' + 10;
00299 
00300                 else if ( s[i] >= 'A' && s[i] < 'A' - 10 + base )
00301                         d = s[i] - 'A' + 10;
00302 
00303                 else if ( i > 0 )
00304                         break;
00305 
00306                 else
00307                         return 0;
00308 
00309                 n = n * base + d;
00310                 }
00311 
00312         if ( neg )
00313                 result = -n;
00314         else
00315                 result = n;
00316 
00317         if ( end )
00318                 *end = s + i;
00319 
00320         return 1;
00321         }

const char* bro_path  ) 
 

Definition at line 590 of file util.cc.

Referenced by search_for_file(), and usage().

00591         {
00592         const char* path = getenv("BROPATH");
00593         if ( ! path )
00594                 path = ".:policy:policy/local:policy/sigs:" LIBDEST;
00595 
00596         return path;
00597         }

const char* bro_prefixes  ) 
 

Definition at line 599 of file util.cc.

References loop_over_list, and prefixes.

Referenced by usage().

00600         {
00601         int len = 1;    // room for \0
00602         loop_over_list(prefixes, i)
00603                 len += strlen(prefixes[i]) + 1;
00604 
00605         char* p = new char[len];
00606 
00607         loop_over_list(prefixes, j)
00608                 if ( j == 0 )
00609                         strcpy(p, prefixes[j]);
00610                 else
00611                         {
00612                         strcat(p, ":");
00613                         strcat(p, prefixes[j]);
00614                         }
00615 
00616         return p;
00617         }

char* copy_string const char *  s  ) 
 

Definition at line 50 of file util.cc.

Referenced by EnumType::AddName(), EnumType::AddNamesFrom(), Rule::AddPattern(), Rule::AddRequires(), LoginConn::AddUserText(), begin_func(), BroFile::BroFile(), BuiltinFunc::BuiltinFunc(), DNS_Mapping::DNS_Mapping(), DNS_Mgr_Request::DNS_Mgr_Request(), PktSrc::DumpCurrentPacket(), EventHandler::EventHandler(), FieldExpr::FieldExpr(), Scope::GenerateTemporary(), ID::ID(), DNS_Mapping::Init(), install_ID(), AssignExpr::IsRecordElement(), main(), merge_types(), open_file(), FileSerializer::OpenFile(), PktFileSrc::PktFileSrc(), PktInterfaceSrc::PktInterfaceSrc(), PersistenceSerializer::ReadAll(), RecordConstructorExpr::RecordConstructorExpr(), PersistenceSerializer::Register(), Rule::Rule(), RuleActionEvent::RuleActionEvent(), RuleHdrTest::RuleHdrTest(), search_for_file(), BroFile::SetAttrs(), BroFile::SetDefaultRotation(), PersistenceSerializer::SetDir(), Serializer::SetErrorDescr(), and PersistenceSerializer::WriteConfig().

00051         {
00052         char* c = new char[strlen(s)+1];
00053         strcpy(c, s);
00054         return c;
00055         }

double current_time  ) 
 

Definition at line 667 of file util.cc.

References double, and internal_error().

Referenced by ChunkedIOFd::ChunkedIOFd(), dispatch_next_packet(), ChunkedIOFd::FlushWriteBuffer(), DNS_Mapping::Init(), init_builtin_funcs(), StatsLogger::Log(), ChunkedIOFd::OptionalFlush(), and watchdog().

00668         {
00669         struct timeval tv;
00670         if ( gettimeofday(&tv, 0) < 0 )
00671                 internal_error("gettimeofday failed in current_time()");
00672 
00673         return double(tv.tv_sec) + double(tv.tv_usec) / 1e6;
00674         }

int decode_hex char  ch  ) 
 

Definition at line 216 of file util.cc.

Referenced by MIME_Entity::DecodeQuotedPrintable(), and unescape_URI().

00217         {
00218         if ( ch >= '0' && ch <= '9' )
00219                 return ch - '0';
00220 
00221         if ( ch >= 'A' && ch <= 'F' )
00222                 return ch - 'A' + 10;
00223 
00224         if ( ch >= 'a' && ch <= 'f' )
00225                 return ch - 'a' + 10;
00226 
00227         return -1;
00228         }

unsigned char encode_hex int  h  ) 
 

Definition at line 230 of file util.cc.

References internal_error().

Referenced by escape_URI_char().

00231         {
00232         static const char hex[16] = {
00233                 '0', '1', '2', '3', '4', '5', '6', '7', '8',
00234                 '9', 'A', 'B', 'C', 'D', 'E', 'F'
00235         };
00236 
00237         if  ( h < 0 || h >= 16 )
00238                 {
00239                 internal_error("illegal value for encode_hex: %d", h);
00240                 return 'X';
00241                 }
00242 
00243         return hex[h];
00244         }

void error const char *  msg,
uint32  addl
 

Definition at line 510 of file util.cc.

References nerr, pinpoint(), and uint32.

Referenced by AddrVal::AddrVal(), BroFile::BroFile(), ChunkedIOFd::ChunkedIOFd(), dotted_to_addr(), RecordType::Init(), RemoteSerializer::Init(), BroFile::InitEncrypt(), is_assignable(), load_mapping_table(), lookup_ID(), mask_addr(), NetVal::NetVal(), parse_dotted(), BinarySerializationFormat::Read(), SerializationFormat::ReadData(), RuleMatcher::ReadFiles(), same_stmt(), same_type(), and TypeDecl::TypeDecl().

00511         {
00512         pinpoint();
00513         fprintf(stderr, "error: %s - %u\n", msg, addl);
00514         ++nerr;
00515         }

void error const char *  msg,
const char *  addl
 

Definition at line 503 of file util.cc.

References nerr, and pinpoint().

00504         {
00505         pinpoint();
00506         fprintf(stderr, "error: %s %s\n", msg, addl);
00507         ++nerr;
00508         }

void error const char *  msg  ) 
 

Definition at line 496 of file util.cc.

References nerr, and pinpoint().

00497         {
00498         pinpoint();
00499         fprintf(stderr, "error: %s\n", msg);
00500         ++nerr;
00501         }

int expand_escape const char *&  s  ) 
 

Definition at line 62 of file util.cc.

References warn().

00063         {
00064         switch ( *(s++) ) {
00065         case 'b': return '\b';
00066         case 'f': return '\f';
00067         case 'n': return '\n';
00068         case 'r': return '\r';
00069         case 't': return '\t';
00070         case 'a': return '\a';
00071         case 'v': return '\v';
00072 
00073         case '0': case '1': case '2': case '3': case '4':
00074         case '5': case '6': case '7':
00075                 { // <octal>{1,3}
00076                 --s;    // put back the first octal digit
00077                 const char* start = s;
00078 
00079                 // Don't increment inside loop control
00080                 // because if isdigit() is a macro it might
00081                 // expand into multiple increments ...
00082 
00083                 // Here we define a maximum length for escape sequence
00084                 // to allow easy handling of string like: "^H0" as
00085                 // "\0100".
00086 
00087                 for ( int len = 0; len < 3 && isascii(*s) && isdigit(*s);
00088                       ++s, ++len)
00089                         ;
00090 
00091                 int result;
00092                 if ( sscanf(start, "%3o", &result) != 1 )
00093                         {
00094                         warn("bad octal escape: ", start);
00095                         result = 0;
00096                         }
00097 
00098                 return result;
00099                 }
00100 
00101         case 'x':
00102                 { /* \x<hex> */
00103                 const char* start = s;
00104 
00105                 // Look at most 2 characters, so that "\x0ddir" -> "^Mdir".
00106                 for ( int len = 0; len < 2 && isascii(*s) && isxdigit(*s);
00107                       ++s, ++len);
00108 
00109                 int result;
00110                 if ( sscanf(start, "%2x", &result) != 1 )
00111                         {
00112                         warn("bad hexadecimal escape: ", start);
00113                         result = 0;
00114                         }
00115 
00116                 return result;
00117                 }
00118 
00119         default:
00120                 return s[-1];
00121         }
00122         }

void fmt int &  len,
const char *&  b,
const char *  format,
... 
 

Referenced by SocketComm::AcceptConnection(), RemoteSerializer::AddPeer(), SSL_Interpreter::analyzeCertificate(), VectorVal::Assign(), BroFile::BroFile(), PersistenceSerializer::CheckDir(), StateAccess::CheckOld(), StateAccess::CheckOldSet(), PersistenceSerializer::CheckTimestamp(), ChunkedIOFd::ChunkedIOFd(), RemoteSerializer::Connect(), Base64Decoder::Decode(), MIME_Entity::DecodeQuotedPrintable(), StateAccess::Describe(), DNS_Mgr::DNS_Mgr(), Base64Decoder::Done(), NetSessions::DoNextPacket(), PktSrc::DumpCurrentPacket(), RuleMatcher::DumpStats(), BroFile::FinishEncrypt(), RemoteSerializer::Fork(), TCP_Rewriter::Funeral(), HTTP_Conn::HTTP_Reply(), HTTP_Conn::HTTP_Request(), SerialObj::Instantiate(), SocketComm::Listen(), RemoteSerializer::Listen(), StatsLogger::Log(), Logger::Log(), SocketComm::LogStats(), RemoteSerializer::LogStats(), PrefixTable::Lookup(), FileSerializer::OpenFile(), RemoteSerializer::Poll(), BroFile::Postprocess(), FileSerializer::PrepareForWriting(), AnonymizeIPAddr_A50::PreservePrefix(), PersistenceSerializer::Proceed(), RemoteSerializer::ProcessCaptureFilterMsg(), RemoteSerializer::ProcessErrorMsg(), SocketComm::ProcessParentMessage(), SocketComm::ProcessRemoteMessage(), RemoteSerializer::ProcessRequestMsg(), RemoteSerializer::ProcessStatsMsg(), TCP_RewriterEndpoint::PushPacket(), PersistenceSerializer::ReadAll(), FileSerializer::ReadHeader(), TCP_Reassembler::RecordGap(), PersistenceSerializer::Register(), TCP_Rewriter::ReleaseSlot(), NetSessions::Remove(), StateAccess::Replay(), EventPlayer::Replay(), RemoteSerializer::Request(), BroFile::Rotate(), StatsLogger::SegmentProfile(), RemoteSerializer::SendAccess(), RemoteSerializer::SendCall(), RemoteSerializer::SendCaptureFilter(), RemoteSerializer::SendConnection(), SocketComm::SendError(), RemoteSerializer::SendID(), PersistenceSerializer::SerializeState(), Serializer::StartSerialization(), RemoteSerializer::StopListening(), HTTP_Conn::Undelivered(), Val::Unserialize(), BroType::Unserialize(), Serializer::Unserialize(), ID::Unserialize(), Func::Unserialize(), Serializer::UnserializeCall(), XMLSerializationFormat::Write(), BroFile::Write(), PersistenceSerializer::WriteConfig(), TCP_RewriteSlot::WriteData(), TCP_RewriterEndpoint::WriteData(), XMLSerializationFormat::WriteEncodedString(), and TCP_RewriterEndpoint::~TCP_RewriterEndpoint().

const char* fmt const char *  format,
... 
 

const char* fmt_access_time double  time  ) 
 

Definition at line 366 of file util.cc.

Referenced by Stmt::AccessStats(), and TableVal::Describe().

00367         {
00368         static char buf[256];
00369         time_t time = (time_t) t;
00370         strftime(buf, sizeof(buf), "%d/%m-%H:%M", localtime(&time));
00371         return buf;
00372         }

void format printf  ,
,
 

int fputs int  len,
const char *  s,
FILE *  fp
 

Definition at line 323 of file util.cc.

Referenced by cryptcat(), doone(), main(), Rule::PrintDebug(), and Serializer::Warning().

00324         {
00325         for ( int i = 0; i < len; ++i )
00326                 if ( fputc(s[i], fp) == EOF )
00327                         return EOF;
00328         return 0;
00329         }

void get_word int  length,
const char *  s,
int &  pwlen,
const char *&  pw
 

Definition at line 174 of file util.cc.

Referenced by FTP_Conn::NewLine().

00175         {
00176         pw = s;
00177 
00178         int len = 0;
00179         while ( len < length && *s && ! isspace(*s) )
00180                 {
00181                 ++s;
00182                 ++len;
00183                 }
00184 
00185         pwlen = len;
00186         }

char* get_word char *&  s  ) 
 

Definition at line 159 of file util.cc.

References skip_whitespace().

00160         {
00161         char* w = s;
00162         while ( *s && ! isspace(*s) )
00163                 ++s;
00164 
00165         if ( *s )
00166                 {
00167                 *s = '\0';      // terminate the word
00168                 s = skip_whitespace(s+1);
00169                 }
00170 
00171         return w;
00172         }

void hash_md5 size_t  size,
const unsigned char *  bytes,
unsigned char  digest[16]
 

Definition at line 374 of file util.cc.

References md5_append(), md5_finish(), and md5_init().

Referenced by hmac_md5(), init_random_seed(), and main().

00375         {
00376         md5_state_s h;
00377         md5_init(&h);
00378         md5_append(&h, bytes, size);
00379         md5_finish(&h, digest);
00380         }

void hmac_md5 size_t  size,
const unsigned char *  bytes,
unsigned char  digest[16]
 

Definition at line 399 of file util.cc.

References hash_md5(), hmac_key_set, internal_error(), and shared_hmac_md5_key.

Referenced by AnonymizeIPAddr_PrefixMD5::anonymize(), AnonymizeIPAddr_RandomMD5::anonymize(), HashKey::HashBytes(), and init_random_seed().

00400         {
00401         if ( ! hmac_key_set )
00402                 internal_error("HMAC-MD5 invoked before the HMAC key is set");
00403 
00404         hash_md5(size, bytes, digest);
00405 
00406         for ( int i = 0; i < 16; ++i )
00407                 digest[i] ^= shared_hmac_md5_key[i];
00408 
00409         hash_md5(16, digest, digest);
00410         }

void init_random_seed  ) 
 

Definition at line 412 of file util.cc.

References hash_md5(), hmac_key_set, hmac_md5(), internal_error(), shared_hmac_md5_key, and uint32.

Referenced by main().

00413         {
00414         static const int bufsiz = 16;
00415         uint32 buf[bufsiz];
00416         int pos = 0;    // accumulates entropy
00417 
00418         // Gather up some entropy.
00419         gettimeofday((struct timeval *)(buf + pos), 0);
00420         pos += sizeof(struct timeval) / sizeof(uint32);
00421 
00422 #if defined(O_NONBLOCK)
00423         int fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
00424 #elif defined(O_NDELAY)
00425         int fd = open("/dev/random", O_RDONLY | O_NDELAY);
00426 #else
00427         int fd = open("/dev/random", O_RDONLY);
00428 #endif
00429 
00430         if ( fd >= 0 )
00431                 {
00432                 int amt = read(fd, buf + pos, sizeof(uint32) * (bufsiz - pos));
00433                 close(fd);
00434 
00435                 if ( amt > 0 )
00436                         pos += (amt / sizeof(uint32));
00437                 }
00438 
00439         if ( pos < bufsiz )
00440                 {
00441                 buf[pos++] = getpid();
00442 
00443                 if ( pos < bufsiz )
00444                         buf[pos++] = getuid();
00445                 }
00446 
00447         uint32 result = 0;
00448         for ( int i = 0; i < pos; ++i )
00449                 {
00450                 result ^= buf[i];
00451                 result = (result << 1) | (result >> 31);
00452                 }
00453         srandom(result);
00454 
00455         if ( ! hmac_key_set )
00456                 {
00457                 hash_md5(sizeof(buf), (u_char*) buf, shared_hmac_md5_key);
00458                 hmac_key_set = 1;
00459                 }
00460 
00461 #ifdef USE_UHASH
00462         if ( UHASH_KEY_SIZE % 16 != 0 )
00463                 internal_error("uhash key size must be multiply of 16");
00464 
00465         uint32 buf2[5];
00466         hash_md5(sizeof(buf), (const u_char*) buf, (u_char*) buf2);
00467 
00468         for ( int i = 0; i < UHASH_KEY_SIZE; i += 16 )
00469                 {
00470                 buf2[4] = i;
00471                 hmac_md5(sizeof(buf2), (const unsigned char*) buf2, uhash_key + i);
00472                 }
00473 #endif
00474         }

int int_list_cmp const void *  v1,
const void *  v2
 

Definition at line 577 of file util.cc.

Referenced by CCL::Sort(), and DFA_Machine::StateSetToDFA_State().

00578         {
00579         int i1 = *(int *) v1;
00580         int i2 = *(int *) v2;
00581 
00582         if ( i1 < i2 )
00583                 return -1;
00584         else if ( i1 == i2 )
00585                 return 0;
00586         else
00587                 return 1;
00588         }

void internal_error const char *  fmt,
... 
volatile
 

Referenced by CQ_TimerMgr::Add(), PQ_TimerMgr::Add(), ODesc::AddBytes(), anonymize_ip(), TypeList::Append(), TCP_TracePacket::AppendIPHeader(), TCP_TracePacket::AppendLinkHeader(), TCP_TracePacket::AppendTCPHeader(), bad_ref(), BuiltinFunc::BuiltinFunc(), check_and_promote(), TCP_Rewriter::CleanUpEmptyPlaceHolders(), RloginConn::ClientUserName(), DNS_Mgr::CompareMappings(), Specific_RE_Matcher::CompileSet(), CompositeHash::ComputeSingletonHash(), CQ_TimerMgr::CQ_TimerMgr(), current_time(), DataBlock::DataBlock(), TCP_Endpoint::DataSent(), dbg_backtrace_internal(), dbg_cmd_break(), dbg_cmd_break_set_state(), dbg_cmd_frame(), dbg_eval_expr(), dbg_execute_command(), dbg_handle_debug_input(), DbgWatch::DbgWatch(), Base64Decoder::Decode(), MIME_Entity::DecodeBase64(), Stmt::DecrBPCount(), TableVal::Delete(), TCP_ContentLine::Deliver(), TCP_Contents_RPC::Deliver(), RPC_Interpreter::DeliverRPC(), TableVal::Describe(), StateAccess::Describe(), EventMgr::Dispatch(), DNS_Mgr::DNS_Mgr(), RloginEndpoint::DoDeliver(), TableVal::DoExpire(), RuleConditionPayloadSize::DoMatch(), NetSessions::DoNextPacket(), BuiltinFunc::DoUnserialize(), TCP_Rewriter::DumpPacket(), PacketDumper::DumpPacket(), NetSessions::DumpPacket(), encode_hex(), TableVal::ExpandAndInit(), extract_next_packet(), BroObj::Fatal(), RecordType::FieldDecl(), BroFile::File(), AnonymizeIPAddr_A50::find_node(), NetSessions::FindConnection(), PacketSortGlobalPQ::FindConnPQ(), Dictionary::FinishChangeSize(), MIME_Entity::FinishDecodeBase64(), flatten_type(), TCP_RewriterEndpoint::Flush(), flush_rewriter_packet(), ChunkedIOFd::FlushWriteBuffer(), RemoteSerializer::Fork(), TCP_RewriterEndpoint::GenerateFIN(), get_map_result(), get_src_pkt_writer(), get_trace_rewriter(), getval(), hmac_md5(), TCP_Rewriter::HoldPacket(), how_many_lines_in(), HTTP_Conn::HTTP_RequestLine(), init_random_seed(), RuleMatcher::InitEndpoint(), NetSessions::Insert(), PrefixTable::Insert(), BroFile::InsertAtBeginning(), install_ID(), NetSessions::Internal(), internal_list_val(), internal_type(), internal_val(), DNS_Mgr::LoadCache(), PersistenceSerializer::LogAccess(), PrefixTable::Lookup(), DNS_Mgr::LookupAddr(), DNS_Mgr::LookupHost(), make_constant(), AnonymizeIPAddr_A50::make_peer(), max_type(), maximize_num_fds(), merge_types(), BroFile::MoveToBeginning(), AnonymizeIPAddr_A50::new_node_block(), NetSessions::NewConn(), LoginConn::NewLine(), SSLv2_Interpreter::NewSSLRecord(), NetSessions::NextFragment(), TCP_Rewriter::NextPacket(), ODesc::OutOfMemory(), PacketDumper::PacketDumper(), parse_dotted(), parse_location_string(), RemoteSerializer::Poll(), pop_scope(), ODesc::PopIndent(), pre_execute_stmt(), AnonymizeIPAddr::PreservePrefix(), DbgBreakpoint::PrintHitMsg(), SocketComm::ProcessParentMessage(), SocketComm::ProcessRemoteMessage(), BroFile::PurgeCache(), TCP_RewriterEndpoint::PushPacket(), XMLSerializationFormat::Read(), TCP_Reassembler::RecordBlock(), TCP_Reassembler::RecordGap(), recover_val(), CompositeHash::RecoverOneVal(), CompositeHash::RecoverVals(), TelnetOption::RecvOption(), TelnetAuthenticateOption::RecvSubOption(), TelnetEncryptOption::RecvSubOption(), TCP_Rewriter::ReleaseNextPacket(), NetSessions::Remove(), PrefixTable::Remove(), StateAccess::Replay(), DbgBreakpoint::Reset(), DNS_Mgr::Resolve(), same_atomic_val(), same_expr(), same_val(), Scope::Scope(), Func::Serialize(), TCP_RewriterEndpoint::SetNextPacket(), HTTP_Endpoint::SetPlainDelivery(), DbgBreakpoint::ShouldBreak(), sig_handler(), CompositeHash::SingleTypeKeySize(), CompositeHash::SingleValHash(), Dictionary::StartChangeSize(), MIME_Entity::StartDecodeBase64(), StmtLocMapping::StartsAfter(), MIME_Mail::SubmitData(), HTTP_Message::SubmitData(), MIME_Mail::SubmitEvent(), HTTP_Message::SubmitEvent(), BroFile::Suspend(), to_v4_addr(), BroFile::Unlink(), ID::Unserialize(), Val::ValDescribe(), ChunkedIOFd::WriteChunk(), Connection::~Connection(), MIME_Entity::~MIME_Entity(), MIME_Message::~MIME_Message(), and TCP_RewriterEndpoint::~TCP_RewriterEndpoint().

bool is_printable const char *  s,
int  len
 

Definition at line 331 of file util.cc.

Referenced by Connection::UnparsedVersionFoundEvent(), and Connection::VersionFoundEvent().

00332         {
00333         while ( --len >= 0 )
00334                 if ( ! isprint(*s++) )
00335                         return false;
00336         return true;
00337         }

int max int  a,
int  b
[inline]
 

Definition at line 145 of file util.h.

Referenced by Discarder::BuildData(), and Reassembler::TrimToSeq().

00146         {
00147         return a > b ? a : b;
00148         }

const char* md5_digest_print const unsigned char  digest[16]  ) 
 

Definition at line 382 of file util.cc.

Referenced by main().

00383         {
00384         static char digest_print[256];
00385 
00386         for ( int i = 0; i < 16; ++i )
00387                 snprintf(digest_print + i * 2, 3, "%02x", digest[i]);
00388 
00389         return digest_print;
00390         }

void message const char *  msg  ) 
 

Definition at line 476 of file util.cc.

References pinpoint().

Referenced by termination_signal().

00477         {
00478         pinpoint();
00479         fprintf(stderr, "%s\n", msg);
00480         }

int min int  a,
int  b
[inline]
 

Definition at line 140 of file util.h.

Referenced by Reassembler::AddAndCheck(), Bstr_cmp(), Discarder::BuildData(), NetSessions::DoNextPacket(), DNS_Mgr::Resolve(), GnutellaConn::SendEvents(), BroFile::Write(), and ChunkedIOFd::Write().

00141         {
00142         return a < b ? a : b;
00143         }

void out_of_memory const char *  where  ) 
 

Definition at line 676 of file util.cc.

Referenced by bro_new_handler(), safe_malloc(), and safe_realloc().

00677         {
00678         fprintf( stderr, "bro: out of memory in %s.\n", where );
00679         abort();
00680         }

size_t pad_size size_t  size  )  [inline]
 

Definition at line 172 of file util.h.

Referenced by DataBlock::DataBlock(), DFA_State_Cache::GetStats(), AddrVal::MemoryAllocation(), NetSessions::MemoryAllocation(), Specific_RE_Matcher::MemoryAllocation(), BaseList::MemoryAllocation(), HashKey::MemoryAllocation(), Dictionary::MemoryAllocation(), CompositeHash::MemoryAllocation(), BroString::MemoryAllocation(), EquivClass::Size(), DFA_State::Size(), and DataBlock::~DataBlock().

00173         {
00174         // We emulate glibc here (values measured on Linux i386).
00175         // FIXME: We should better copy the portable value definitions from glibc.
00176         if ( size == 0 )
00177                 return 0;       // glibc allocated 16 bytes anyway.
00178 
00179         const int pad = 8;
00180         if ( size < 12 )
00181                 return 2 * pad;
00182 
00183         return ((size+3) / pad + 1) * pad;
00184         }

void pinpoint  ) 
 

Definition at line 565 of file util.cc.

References filename, line_number, and network_time.

Referenced by error(), internal_error(), message(), run_time(), and warn().

00566         {
00567         if ( network_time > 0.0 )
00568                 fprintf(stderr, "%.6f ", network_time);
00569         else
00570                 {
00571                 if ( filename )
00572                         fprintf(stderr, "%s, ", filename);
00573                 fprintf(stderr, "line %d: ", line_number);
00574                 }
00575         }

void run_time const char *  fmt,
const char *  arg1,
const char *  arg2
 

Definition at line 540 of file util.cc.

References fmt, nruntime, and pinpoint().

Referenced by builtin_run_time(), BroString::CheckString(), Specific_RE_Matcher::Compile(), Specific_RE_Matcher::CompileSet(), dispatch_next_packet(), RuleConditionEval::DoMatch(), PktSrc::DumpCurrentPacket(), BroFile::File(), BroFile::FinishEncrypt(), TCP_Rewriter::Funeral(), PersistenceSerializer::GotStateAccess(), PersistenceSerializer::GotTimer(), RemoteSerializer::GotTimer(), NetSessions::HeartBeat(), Base64Decoder::IllegalEncoding(), SerialObj::Instantiate(), BroFile::Postprocess(), AnonymizeIPAddr_A50::PreservePrefix(), TCP_Rewriter::ReleaseSlot(), StateAccess::Replay(), FileSerializer::ReportError(), TCP_Rewriter::ReserveSlot(), BroFile::Rotate(), run_time(), BroFile::Seek(), BroFile::SetBuf(), TCP_Reassembler::SetContentsFile(), BroFile::Suspend(), RemoteSerializer::UnknownID(), Func::Unserialize(), watchdog(), BroFile::Write(), TCP_RewriteSlot::WriteData(), and TCP_RewriterEndpoint::WriteData().

00541         {
00542         pinpoint();
00543         fprintf(stderr, "run-time error: ");
00544         fprintf(stderr, fmt, arg1, arg2);
00545         fprintf(stderr, "\n");
00546         ++nruntime;
00547         }

void run_time const char *  fmt,
const char *  arg
 

Definition at line 531 of file util.cc.

References fmt, nruntime, and pinpoint().

00532         {
00533         pinpoint();
00534         fprintf(stderr, "run-time error: ");
00535         fprintf(stderr, fmt, arg);
00536         fprintf(stderr, "\n");
00537         ++nruntime;
00538         }

void run_time const char *  fmt,
BroObj obj
 

Definition at line 524 of file util.cc.

References BroObj::Describe(), ODesc::Description(), fmt, and run_time().

00525         {
00526         ODesc d;
00527         obj->Describe(&d);
00528         run_time(fmt, d.Description());
00529         }

void run_time const char *  msg  ) 
 

Definition at line 517 of file util.cc.

References nruntime, and pinpoint().

00518         {
00519         pinpoint();
00520         fprintf(stderr, "run-time error: %s\n", msg);
00521         ++nruntime;
00522         }

void* safe_malloc size_t  size  )  [inline]
 

Definition at line 202 of file util.h.

References out_of_memory().

Referenced by BaseList::BaseList(), dbg_handle_debug_input(), ODesc::ODesc(), and BaseList::operator=().

00203         {
00204         void* ptr = malloc(size);
00205         if ( ! ptr )
00206                 out_of_memory("malloc");
00207 
00208         return ptr;
00209         }

void* safe_realloc void *  ptr,
size_t  size
[inline]
 

Definition at line 190 of file util.h.

References out_of_memory().

Referenced by ODesc::Grow(), and BaseList::resize().

00191         {
00192         if ( ! size )
00193                 return 0;
00194 
00195         ptr = realloc(ptr, size);
00196         if ( ! ptr )
00197                 out_of_memory("realloc");
00198 
00199         return ptr;
00200         }

FILE* search_for_file const char *  filename,
const char *  ext,
const char **  full_filename
 

Definition at line 627 of file util.cc.

References bro_path(), copy_string(), filename, and open_file().

Referenced by parse_location_string(), and RuleMatcher::ReadFiles().

00629         {
00630         if ( filename[0] == '/' || filename[0] == '.' )
00631                 return open_file(filename, full_filename);
00632 
00633         char path[1024], full_filename_buf[1024];
00634         strcpy(path, bro_path());
00635 
00636         char* dir_beginning = path;
00637         char* dir_ending = path;
00638         int more = *dir_beginning != '\0';
00639 
00640         while ( more )
00641                 {
00642                 while ( *dir_ending && *dir_ending != ':' )
00643                         ++dir_ending;
00644 
00645                 if ( *dir_ending == ':' )
00646                         *dir_ending = '\0';
00647                 else
00648                         more = 0;
00649 
00650                 sprintf(full_filename_buf, "%s/%s", dir_beginning, filename);
00651                 if ( access(full_filename_buf, R_OK) == 0 )
00652                         return open_file(full_filename_buf, full_filename);
00653 
00654                 sprintf(full_filename_buf, "%s/%s.%s", dir_beginning, filename, ext);
00655                 if ( access(full_filename_buf, R_OK) == 0 )
00656                         return open_file(full_filename_buf, full_filename);
00657 
00658                 dir_beginning = ++dir_ending;
00659                 }
00660 
00661         if ( full_filename )
00662                 *full_filename = copy_string(filename);
00663 
00664         return 0;
00665         }

char* skip_digits char *  s  ) 
 

Definition at line 152 of file util.cc.

00153         {
00154         while ( *s && isdigit(*s) )
00155                 ++s;
00156         return s;
00157         }

const char* skip_whitespace const char *  s,
const char *  end_of_s
 

Definition at line 145 of file util.cc.

Referenced by get_word(), HTTP_Conn::HTTP_ReplyLine(), IdentConn::NewLine(), FTP_Conn::NewLine(), FingerConn::NewLine(), IdentConn::ParseInt(), HTTP_Conn::ParseRequest(), and HTTP_Conn::PrefixWordMatch().

00146         {
00147         while ( s < end_of_s && (*s == ' ' || *s == '\t') )
00148                 ++s;
00149         return s;
00150         }

char* skip_whitespace char *  s,
char *  end_of_s
 

Definition at line 138 of file util.cc.

00139         {
00140         while ( s < end_of_s && (*s == ' ' || *s == '\t') )
00141                 ++s;
00142         return s;
00143         }

const char* skip_whitespace const char *  s  ) 
 

Definition at line 131 of file util.cc.

00132         {
00133         while ( *s == ' ' || *s == '\t' )
00134                 ++s;
00135         return s;
00136         }

char* skip_whitespace char *  s  ) 
 

Definition at line 124 of file util.cc.

00125         {
00126         while ( *s == ' ' || *s == '\t' )
00127                 ++s;
00128         return s;
00129         }

int strcasecmp_n int  s_len,
const char *  s,
const char *  t
 

Definition at line 257 of file util.cc.

Referenced by HTTP_Conn::ExpectReplyMessageBody(), HTTP_Conn::HTTP_Header(), MIME_Entity::LookupMIMEHeaderName(), MIME_Entity::ParseContentEncoding(), MIME_Entity::ParseContentType(), MIME_Entity::ParseParameter(), strcasecmp_n(), and HTTP_Entity::SubmitHeader().

00258         {
00259         if ( ! b )
00260                 return -1;
00261 
00262         int i;
00263         for ( i = 0; i < b_len; ++i )
00264                 {
00265                 char c1 = islower(b[i]) ? toupper(b[i]) : b[i];
00266                 char c2 = islower(t[i]) ? toupper(t[i]) : t[i];
00267 
00268                 if ( c1 < c2 )
00269                         return -1;
00270 
00271                 if ( c1 > c2 )
00272                         return 1;
00273                 }
00274 
00275         return t[i] != '\0';
00276         }

const char* strchr_n const char *  s,
const char *  end_of_s,
char  ch
 

Definition at line 198 of file util.cc.

Referenced by IdentConn::NewLine(), and FingerConn::NewLine().

00199         {
00200         for ( ; s < end_of_s; ++s )
00201                 if ( *s == ch )
00202                         return s;
00203 
00204         return 0;
00205         }

int streq const char *  s1,
const char *  s2
 

Definition at line 57 of file util.cc.

Referenced by dbg_execute_command(), PktSrc::DumpCurrentPacket(), FieldExpr::FieldExpr(), RecordType::FieldOffset(), load_mapping_table(), lookup_global_symbols_regex(), make_full_var_name(), LoginConn::MatchesTypeahead(), merge_types(), same_type(), LoginConn::SetEnv(), BroObj::SetLocationInfo(), and TraceState::SetTraceFile().

00058         {
00059         return ! strcmp(s1, s2);
00060         }

const char* strpbrk_n size_t  len,
const char *  s,
const char *  charset
 

Definition at line 248 of file util.cc.

00249         {
00250         for ( const char* p = s; p < s + len; ++p )
00251                 if ( strchr(charset, *p) )
00252                         return p;
00253 
00254         return 0;
00255         }

const char* strrchr_n const char *  s,
const char *  end_of_s,
char  ch
 

Definition at line 207 of file util.cc.

00208         {
00209         for ( --end_of_s; end_of_s >= s; --end_of_s )
00210                 if ( *end_of_s == ch )
00211                         return end_of_s;
00212 
00213         return 0;
00214         }

void to_upper char *  s  ) 
 

Definition at line 188 of file util.cc.

00189         {
00190         while ( *s )
00191                 {
00192                 if ( islower(*s) )
00193                         *s = toupper(*s);
00194                 ++s;
00195                 }
00196         }

void warn const char *  msg,
const char *  addl
 

Definition at line 489 of file util.cc.

References nwarn, and pinpoint().

Referenced by MIME_Entity::CheckBoundaryDelimiter(), DNS_Mgr::DNS_Mgr(), expand_escape(), TCP_Rewriter::Funeral(), ConversionSerializer::GotID(), ConversionSerializer::GotStateAccess(), load_mapping_table(), DNS_Mgr::LookupAddr(), DNS_Mgr::LookupHost(), RemoteSerializer::SendCall(), RemoteSerializer::SendConnection(), RemoteSerializer::SendID(), RemoteSerializer::SetAcceptState(), and SMTP_Conn::UnexpectedCommand().

00490         {
00491         pinpoint();
00492         fprintf(stderr, "warning: %s %s\n", msg, addl);
00493         ++nwarn;
00494         }

void warn const char *  msg  ) 
 

Definition at line 482 of file util.cc.

References nwarn, and pinpoint().

00483         {
00484         pinpoint();
00485         fprintf(stderr, "warning: %s\n", msg);
00486         ++nwarn;
00487         }


Variable Documentation

int hmac_key_set
 

Definition at line 97 of file util.h.

Referenced by hmac_md5(), init_random_seed(), and main().

double network_time
 

Definition at line 135 of file util.h.

Referenced by FragReassembler::AddFragment(), TCP_TracePacket::AppendData(), BackDoorAnalyzer::BackDoorAnalyzer(), BroFile::BroFile(), StatsTimer::Dispatch(), dispatch_next_packet(), TableVal::DoExpire(), RuleConditionPayloadSize::DoMatch(), TCP_Rewriter::DumpPacket(), Connection::EnableStatusUpdateTimer(), ScheduleExpr::Eval(), RuleMatcher::EvalRuleConditions(), ExprListStmt::Exec(), RuleMatcher::ExecRulePurely(), RemoteSerializer::GotEvent(), RuleMatcher::InitEndpoint(), TableVal::InitTimer(), BroFile::InstallRotateTimer(), InterConnAnalyzer::InterConnAnalyzer(), Logger::Log(), StatsLogger::Log(), TraceState::LogTrace(), TableVal::Lookup(), RuleMatcher::Match(), TCP_Connection::NextPacket(), EventPlayer::NextTimestamp(), BroObj::PinPoint(), pinpoint(), RemoteSerializer::Poll(), BroFile::Postprocess(), PersistenceSerializer::Proceed(), TCP_RewriterEndpoint::PushPacket(), Stmt::RegisterAccess(), TCP_RewriterEndpoint::Reset(), BroFile::Rotate(), TCP_RewriterEndpoint::ScheduleFlush(), StatsLogger::SegmentProfile(), Serializer::Serialize(), Connection::SetInactivityTimeout(), Connection::SetLifetime(), Connection::StatusUpdateTimer(), TableEntryVal::TableEntryVal(), X509_Cert::verify(), X509_Cert::verifyChain(), Connection::Weird(), and NetSessions::Weird().

unsigned char shared_hmac_md5_key[16]
 

Definition at line 93 of file util.h.

Referenced by hmac_md5(), init_random_seed(), and main().


Generated on Sat May 1 15:29:45 2004 for bro_docs.8a82 by doxygen 1.3.6