I have a Objective-C Application which lets me get the status of a
PPP connection! I am new to Objective-C and ask you for help
solving this:
Actually, when I enter "./PPPConnect -s" I will get the status of the
connection
I want to get the sent and received bytes and the connection time.
I found the SCNetworkConnection API - the following should help me
solving this, but I have no idea how I can
adapt my file:
The EndResult should be:
In Terminal:
when I enter "./PPPConnect -t" - it shall show me the Connection time
when I enter "./PPPConnect -i" - the Incoming bytes
when I enter "./PPPConnect -o" - the Outgoing bytes
I do not want you write this for me, but any hints/advices are welcome!
For the sent/received bytes:
SCNetworkConnectionCopyStatistics
CFDictionaryRef SCNetworkConnectionCopyStatistics (
SCNetworkConnectionRef connection );
Parameters
connection
The SCNetworkConnection to obtained statistics from.
Return Value
Returns the statistics dictionary. If NULL is returned, the error can
be retrieved using the SCError function.
Discussion
Returns the statistics of the SCNetworkConnection. A statistic
dictionary contains specific dictionaries with statistics for each
subcomponent of the service.
For example, a statistics dictionary will contain the following sub-
dictionaries, keys, and values:
PPP : BytesIn :
PPP : BytesOut : Contains the number of bytes going up into
(or coming out of) the network stack for
any networking protocol without the PPP
headers and trailers.
PPP : PacketsIn :
PPP : PacketsOut : Contains the number of packets going up into
(or coming out of) the network stack for
any networking protocol without the PPP
headers and trailers.
PPP : ErrorsIn :
PPP : ErrorsOut : Contains the number of errors going up into
(or coming out of) the network stack for
any networking protocol without the PPP
headers and trailers.
The statistics dictionary may be extended in the future to contain
additional information.
Availability
Introduced in Mac OS X v10.3.
For the ConnectTime:
CFDictionaryRef SCNetworkConnectionCopyExtendedStatus (
SCNetworkConnectionRef connection );
Parameters
connection
The SCNetworkConnection to obtain status from.
Return Value
Returns the status dictionary. If NULL is returned, the error can be
retrieved using the SCError function.
Discussion
Returns the extended status of the connection. An extended status
dictionary contains specific dictionaries describing the status for
each subcomponent of the service.
For example, a status dictionary will contain the following sub-
dictionaries, keys, and values:
IPv4 : Addresses : the assigned IP address.
PPP : Status : the PPP-specific status of type
SCNetworkConnectionPPPStatus.
LastCause : Available when the status is "Disconnected"
and contains the last error associated with
connecting or disconnecting.
ConnectTime : the time when the connection was
established.