Functions

The following functions are available globally.

  • get current host time in nanoseconds

    Declaration

    Objective-C

    extern uint64_t getTimeInNanoseconds()

    Swift

    func getTimeInNanoseconds() -> UInt64

    Return Value

    current host time in nanoseconds

  • get current host time in milliseconds

    Declaration

    Objective-C

    extern int64_t getUptimeInMilliseconds()

    Swift

    func getUptimeInMilliseconds() -> Int64

    Return Value

    current host time in milliseconds

  • calculate difference between two timeval timestamps

    Declaration

    Objective-C

    extern long timevaldiff(struct timeval *t1, struct timeval *t2)

    Swift

    func timevaldiff(_ t1: UnsafeMutablePointer

    Parameters

    t1

    a struct timeval parameter

    t2

    a struct timeval parameter

    Return Value

    difference between two timeval timestamps

  • Returns a dotted decimal string for the specified address (a (struct sockaddr) within the address NSData).

    Declaration

    Objective-C

    extern NSString *DisplayAddressForAddress(NSData *address)

    Swift

    func DisplayAddressForAddress(_ address: Data!) -> String!

    Parameters

    address

    an address structure

    Return Value

    string

  • Returns a human readable string for the given data.

    Declaration

    Objective-C

    extern NSString *DisplayStringFromData(NSData *data)

    Swift

    func DisplayStringFromData(_ data: Data!) -> String!

    Parameters

    data

    binary data

    Return Value

    string

  • Returns hex representation of contents of ‘data’

    Declaration

    Objective-C

    extern NSString *DisplayHexStringFromData(NSData *data)

    Swift

    func DisplayHexStringFromData(_ data: Data!) -> String!

    Parameters

    data

    binary data

    Return Value

    hex string

  • Given an NSError, returns a short error string that we can print, handling some special cases.

    Declaration

    Objective-C

    extern NSString *DisplayErrorFromError(NSError *error)

    Swift

    func DisplayErrorFromError(_ error: Error!) -> String!

    Parameters

    error

    an NSError instance

    Return Value

    string