Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "Revision 4"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:
   
 
Extending the SANA-II network driver specification<br />
 
Extending the SANA-II network driver specification<br />
by [mailto:olsen@amiga.com?subject=SANA-IIR4%20proposal Olaf Barthel]
+
by Olaf Barthel
   
 
(Last updated 02-Mar-2003)
 
(Last updated 02-Mar-2003)
   
== 1. Introduction ==
+
== Introduction ==
   
 
The years have gone by without any substantial changes to the SANA-II standard being made. With good reason, since there was no apparent need to push the envelope and extend the driver specification. The last proposed change came 1997 from Holger Kruse, who suggested that commands should be added to control multicast packet reception for ranges of addresses rather than individual addresses.
 
The years have gone by without any substantial changes to the SANA-II standard being made. With good reason, since there was no apparent need to push the envelope and extend the driver specification. The last proposed change came 1997 from Holger Kruse, who suggested that commands should be added to control multicast packet reception for ranges of addresses rather than individual addresses.
Line 14: Line 14:
 
The following text tries to tie all issues together and will conclude by listing problems which I think still need attention (or in other words, I didn't find a solution myself). Wherever possible, I have tried to provide a rationale for the changes I propose.
 
The following text tries to tie all issues together and will conclude by listing problems which I think still need attention (or in other words, I didn't find a solution myself). Wherever possible, I have tried to provide a rationale for the changes I propose.
   
Please feel free to comment; you can contact me through the [mailto:olsen@amiga.com?subject=SANA-IIR4%20proposal e-mail address] given in the headline of this document. Note that the issues discussed in this document are just a list of proposed changes. No such features are part of any SANA-II specifications, although I'd like to claim that I have tried to implement the majority of the changes listed below in my own software.
+
Please feel free to comment; you can contact me through the [http://www.amigaos.net/contact AmigaOS contact form]. Note that the issues discussed in this document are just a list of proposed changes. No such features are part of any SANA-II specifications, although I'd like to claim that I have tried to implement the majority of the changes listed below in my own software.
   
 
This is a revised version of the original document I put together around October 14, 2001. For a list of changes that have been made since, please see [[#10_changes|section 10]] ('Changes'). This document has been updated and enhanced several times, in response to discussions with Heinz Wrobel.
 
This is a revised version of the original document I put together around October 14, 2001. For a list of changes that have been made since, please see [[#10_changes|section 10]] ('Changes'). This document has been updated and enhanced several times, in response to discussions with Heinz Wrobel.
   
  +
== New commands ==
   
  +
=== S2_GETPEERADDRESS ===
 
== 2. New commands ==
 
 
 
 
=== 2.1 <tt>S2_GETPEERADDRESS</tt> ===
 
   
 
As part of the negotiation process, the PPP protocol can return the addresses used by the peer (the other side of the point-to-point connection PPP establishes; typically a dial-in server) and assigned to the client establishing the connection. The SANA-II standard does not provide for a mechanism to return such information. Existing drivers therefore had to resort to other means, such as by setting global environment variables containing this information.
 
As part of the negotiation process, the PPP protocol can return the addresses used by the peer (the other side of the point-to-point connection PPP establishes; typically a dial-in server) and assigned to the client establishing the connection. The SANA-II standard does not provide for a mechanism to return such information. Existing drivers therefore had to resort to other means, such as by setting global environment variables containing this information.
Line 30: Line 26:
 
I propose a command with the following semantics:
 
I propose a command with the following semantics:
   
<pre> NAME
+
<pre>
  +
NAME
 
S2_GETPEERADDRESS -- Obtain the addresses used by the peer
 
S2_GETPEERADDRESS -- Obtain the addresses used by the peer
 
(server) and the client of a point-to-point connection.
 
(server) and the client of a point-to-point connection.
Line 61: Line 58:
 
respective address fields with zeroes. It is legal for a driver to
 
respective address fields with zeroes. It is legal for a driver to
 
respond to the S2_GETPEERADDRESS command with two zero addresses (both
 
respond to the S2_GETPEERADDRESS command with two zero addresses (both
ios2_SrcAddr and ios2_DstAddr filled with zeroes).</pre>
+
ios2_SrcAddr and ios2_DstAddr filled with zeroes).
  +
</pre>
I propose that the following command number should be assigned:
 
   
  +
I propose that the following command number should be assigned:
 
<tt>#define S2_GETPEERADDRESS 0xC002</tt>
 
<tt>#define S2_GETPEERADDRESS 0xC002</tt>
   
 
This command may be useful beyond the typical application (PPP) described above.
 
This command may be useful beyond the typical application (PPP) described above.
   
  +
=== S2_GETDNSADDRESS ===
 
 
=== 2.2 <tt>S2_GETDNSADDRESS</tt> ===
 
   
 
The PPP negotiation process may produce information on which domain name and NetBIOS name servers are available to the client. I think that it is doubtful that the availability of NetBIOS name servers will be useful for Amiga software (let alone whether NetBIOS name resolution has a future), which is why I suggest that a SANA-II command for returning only the domain name servers is introduced.
 
The PPP negotiation process may produce information on which domain name and NetBIOS name servers are available to the client. I think that it is doubtful that the availability of NetBIOS name servers will be useful for Amiga software (let alone whether NetBIOS name resolution has a future), which is why I suggest that a SANA-II command for returning only the domain name servers is introduced.
Line 76: Line 72:
 
I propose a command with the following semantics:
 
I propose a command with the following semantics:
   
<pre> NAME
+
<pre>
  +
NAME
 
S2_GETDNSADDRESS -- Obtain the addresses of the primary
 
S2_GETDNSADDRESS -- Obtain the addresses of the primary
 
and secondary domain name servers.
 
and secondary domain name servers.
Line 108: Line 105:
 
It is legal for a driver to respond to the S2_GETDNSADDRESS command
 
It is legal for a driver to respond to the S2_GETDNSADDRESS command
 
with two zero addresses (both ios2_SrcAddr and ios2_DstAddr filled
 
with two zero addresses (both ios2_SrcAddr and ios2_DstAddr filled
with zeroes).</pre>
+
with zeroes).
  +
</pre>
I propose that the following command number should be assigned:
 
   
  +
I propose that the following command number should be assigned:
 
<tt>#define S2_GETDNSADDRESS 0xC003</tt>
 
<tt>#define S2_GETDNSADDRESS 0xC003</tt>
   
 
This command may be useful beyond the typical application (PPP) described above.
 
This command may be useful beyond the typical application (PPP) described above.
   
  +
=== S2_GETEXTENDEDGLOBALSTATS ===
 
 
=== 2.3 <tt>S2_GETEXTENDEDGLOBALSTATS</tt> ===
 
   
 
There already exists a SANA-II command for querying global device statistics (<tt>S2_GETGLOBALSTATS</tt>) which should be common to all kinds of networking devices. Statistics that are particular to a certain device type are intended to be returned through the <tt>S2_GETSPECIALSTATS</tt> command. I feel that these mechanisms both fail to cater well enough for dial-up or session-oriented networking applications such as PPP or PPPoE. Since the data structure used by <tt>S2_GETGLOBALSTATS</tt> is of a fixed size and not intended to accomodate for new fields, I propose to introduce a new command which uses a different data structure, as follows:
 
There already exists a SANA-II command for querying global device statistics (<tt>S2_GETGLOBALSTATS</tt>) which should be common to all kinds of networking devices. Statistics that are particular to a certain device type are intended to be returned through the <tt>S2_GETSPECIALSTATS</tt> command. I feel that these mechanisms both fail to cater well enough for dial-up or session-oriented networking applications such as PPP or PPPoE. Since the data structure used by <tt>S2_GETGLOBALSTATS</tt> is of a fixed size and not intended to accomodate for new fields, I propose to introduce a new command which uses a different data structure, as follows:
   
  +
<syntaxhighlight>
<pre>struct Sana2ExtDeviceStats
 
  +
struct Sana2ExtDeviceStats
 
{
 
{
 
ULONG s2xds_Length;
 
ULONG s2xds_Length;
Line 137: Line 134:
 
struct timeval s2xds_LastDisconnected;
 
struct timeval s2xds_LastDisconnected;
 
struct timeval s2xds_TimeConnected;
 
struct timeval s2xds_TimeConnected;
};</pre>
+
};
  +
</syntaxhighlight>
  +
 
Before I proceed to explain what purposes the individual members serve, a few words on the <tt>S2QUAD</tt> type, which is defined as follows:
 
Before I proceed to explain what purposes the individual members serve, a few words on the <tt>S2QUAD</tt> type, which is defined as follows:
 
 
<tt>typedef struct { ULONG s2q_High; ULONG s2q_Low; } S2QUAD;</tt>
 
<tt>typedef struct { ULONG s2q_High; ULONG s2q_Low; } S2QUAD;</tt>
   
Line 145: Line 143:
   
 
The structure members have the following purposes:
 
The structure members have the following purposes:
 
 
   
 
<tt>s2xds_Length</tt>
 
<tt>s2xds_Length</tt>
Line 206: Line 202:
 
I propose a command with the following semantics:
 
I propose a command with the following semantics:
   
<pre> NAME
+
<pre>
  +
NAME
 
S2_GETEXTENDEDGLOBALSTATS -- Get interface accumulated statistics;
 
S2_GETEXTENDEDGLOBALSTATS -- Get interface accumulated statistics;
 
updated version.
 
updated version.
Line 242: Line 239:
 
RESULTS
 
RESULTS
 
ios2_Req.io_Error - Zero if successful; non-zero otherwise
 
ios2_Req.io_Error - Zero if successful; non-zero otherwise
ios2_WireError - More specific error number</pre>
+
ios2_WireError - More specific error number
  +
</pre>
  +
 
I propose that the following command number should be assigned:
 
I propose that the following command number should be assigned:
 
 
<tt>#define S2_GETEXTENDEDGLOBALSTATS 0xC004</tt>
 
<tt>#define S2_GETEXTENDEDGLOBALSTATS 0xC004</tt>
   
  +
=== S2_CONNECT ===
 
 
=== 2.4 <tt>S2_CONNECT</tt> ===
 
   
 
The driver model specified by the SANA-II standard really only covers networking hardware well. Software-only drivers, such as for dial-up networking, are, well, somehow mentioned in the standard, but they don't receive much attention. In particular, this means that a networking driver is assumed to be practically always attached to its link layer and no provisions exist to specify what kind of link layer that might be and how it might be accessed. This small oversight can probably be explained by the fact that at the time the SANA-II standard was adopted, dial-up networking had not yet gained the prominence it has today.
 
The driver model specified by the SANA-II standard really only covers networking hardware well. Software-only drivers, such as for dial-up networking, are, well, somehow mentioned in the standard, but they don't receive much attention. In particular, this means that a networking driver is assumed to be practically always attached to its link layer and no provisions exist to specify what kind of link layer that might be and how it might be accessed. This small oversight can probably be explained by the fact that at the time the SANA-II standard was adopted, dial-up networking had not yet gained the prominence it has today.
Line 255: Line 251:
 
To bridge this gap, I propose a new command which will make a driver connect to its link layer and go online, which uses the following data structure:
 
To bridge this gap, I propose a new command which will make a driver connect to its link layer and go online, which uses the following data structure:
   
  +
<syntaxhighlight>
<pre>struct Sana2Connection
 
  +
struct Sana2Connection
 
{
 
{
 
ULONG s2c_Size;
 
ULONG s2c_Size;
Line 264: Line 261:
 
STRPTR s2c_Login;
 
STRPTR s2c_Login;
 
STRPTR s2c_Password;
 
STRPTR s2c_Password;
};</pre>
+
};
  +
</syntaxhighlight>
The individual structure members have the following purposes:
 
 
   
  +
The individual structure members have the following purposes:
   
 
<tt>s2c_Size</tt>
 
<tt>s2c_Size</tt>
Line 277: Line 274:
 
This list contains options, to be used during the connection process. Each node has the following format:
 
This list contains options, to be used during the connection process. Each node has the following format:
   
  +
<syntaxhighlight>
<pre>struct Sana2ConnectionOption
 
  +
struct Sana2ConnectionOption
 
{
 
{
 
struct MinNode s2co_MinNode;
 
struct MinNode s2co_MinNode;
 
STRPTR s2co_Name;
 
STRPTR s2co_Name;
 
STRPTR s2co_Value;
 
STRPTR s2co_Value;
};</pre>
+
};
  +
</syntaxhighlight>
  +
 
The <tt>s2co_Name</tt> and <tt>s2co_Value</tt> entries point to <tt>NUL</tt>-terminated strings, which contain the name and the value of a parameter. ''Note that for numeric values, the respective number will be encoded in a text string.'' A number of parameters are reserved, which are [[#s2c_options|listed later]] in this text.
 
The <tt>s2co_Name</tt> and <tt>s2co_Value</tt> entries point to <tt>NUL</tt>-terminated strings, which contain the name and the value of a parameter. ''Note that for numeric values, the respective number will be encoded in a text string.'' A number of parameters are reserved, which are [[#s2c_options|listed later]] in this text.
   
Line 290: Line 290:
   
 
<pre>error_hook_func(hook,reserved,message);
 
<pre>error_hook_func(hook,reserved,message);
A0 A2 A1
 
   
 
VOID error_hook_func(struct Hook *hook,APTR reserved,
 
VOID error_hook_func(struct Hook *hook,APTR reserved,
Line 302: Line 301:
 
This hook is called when the link level device has been set up, but further initializations are necessary, such as telling a modem to dial out. The hook function is invoked with the following parameters:
 
This hook is called when the link level device has been set up, but further initializations are necessary, such as telling a modem to dial out. The hook function is invoked with the following parameters:
   
  +
<pre>
<pre>success = connect_hook_func(hook,reserved,s2cm);
 
  +
success = connect_hook_func(hook,reserved,s2cm);
D0 A0 A2 A1
 
   
 
BOOL connect_hook_func(struct Hook *hook,APTR reserved,
 
BOOL connect_hook_func(struct Hook *hook,APTR reserved,
struct Sana2ConnectionMessage *s2cm);</pre>
+
struct Sana2ConnectionMessage *s2cm);
  +
</pre>
  +
 
The <tt>reserved</tt> parameter '''must''' be <tt>NULL</tt>. The <tt>s2cm</tt> parameter points to a data structure, as follows:
 
The <tt>reserved</tt> parameter '''must''' be <tt>NULL</tt>. The <tt>s2cm</tt> parameter points to a data structure, as follows:
   
  +
<syntaxhighlight>
<pre>struct Sana2ConnectionMessage
 
  +
struct Sana2ConnectionMessage
 
{
 
{
 
ULONG s2cm_Size;
 
ULONG s2cm_Size;
Line 315: Line 317:
 
struct IORequest * s2cm_Request[2];
 
struct IORequest * s2cm_Request[2];
 
LONG s2cm_RequestType;
 
LONG s2cm_RequestType;
};</pre>
+
};
  +
</syntaxhighlight>
In this structure, the members have the following purposes:
 
 
   
  +
In this structure, the members have the following purposes:
   
 
<tt>s2cm_Size</tt>
 
<tt>s2cm_Size</tt>
Line 348: Line 350:
 
This hook is called by <tt>S2_CONNECT</tt> when the connection could not be established (the <tt>s2c_ConnectHook</tt> returned <tt>FALSE</tt>), or by <tt>S2_DISCONNECT</tt>, shortly before the link level device is to be closed. The hook function is invoked with the following parameters:
 
This hook is called by <tt>S2_CONNECT</tt> when the connection could not be established (the <tt>s2c_ConnectHook</tt> returned <tt>FALSE</tt>), or by <tt>S2_DISCONNECT</tt>, shortly before the link level device is to be closed. The hook function is invoked with the following parameters:
   
  +
<pre>
<pre>disconnect_hook_func(hook,reserved,s2cm);
 
  +
disconnect_hook_func(hook,reserved,s2cm);
A0 A2 A1
 
   
 
VOID disconnect_hook_func(struct Hook *hook,APTR reserved,
 
VOID disconnect_hook_func(struct Hook *hook,APTR reserved,
struct Sana2ConnectionMessage *s2cm);</pre>
+
struct Sana2ConnectionMessage *s2cm);
  +
</pre>
  +
 
The <tt>reserved</tt> parameter '''must''' be <tt>NULL</tt>. The <tt>s2cm</tt> parameter points to a data structure, as was described for the <tt>s2c_ConnectHook</tt>.
 
The <tt>reserved</tt> parameter '''must''' be <tt>NULL</tt>. The <tt>s2cm</tt> parameter points to a data structure, as was described for the <tt>s2c_ConnectHook</tt>.
   
Line 650: Line 654:
   
 
The command should work as follows:
 
The command should work as follows:
 
 
   
 
# The client must set up the <tt>Sana2Connection</tt> data structure, initialize the <tt>s2c_Size</tt>, <tt>s2c_Options</tt>, <tt>s2c_ErrorHook</tt>, <tt>s2c_ConnectHook</tt>, <tt>s2c_DisconnectHook</tt>, <tt>s2c_Login</tt> and <tt>s2c_Password</tt> fields.
 
# The client must set up the <tt>Sana2Connection</tt> data structure, initialize the <tt>s2c_Size</tt>, <tt>s2c_Options</tt>, <tt>s2c_ErrorHook</tt>, <tt>s2c_ConnectHook</tt>, <tt>s2c_DisconnectHook</tt>, <tt>s2c_Login</tt> and <tt>s2c_Password</tt> fields.
Line 666: Line 668:
 
I propose a command with the following semantics:
 
I propose a command with the following semantics:
   
<pre> NAME
+
<pre>
  +
NAME
 
S2_CONNECT -- Establish a link layer connection and go
 
S2_CONNECT -- Establish a link layer connection and go
 
online.
 
online.
Line 708: Line 711:
 
<tt>#define S2_CONNECT 0xC005</tt>
 
<tt>#define S2_CONNECT 0xC005</tt>
   
=== 2.5 <tt>S2_DISCONNECT</tt> ===
+
=== S2_DISCONNECT ===
   
 
This command complements <tt>S2_CONNECT</tt> in that it tears down a connection. It uses the same <tt>Sana2Connection</tt> structure and hooks, but most of these members are ignored.
 
This command complements <tt>S2_CONNECT</tt> in that it tears down a connection. It uses the same <tt>Sana2Connection</tt> structure and hooks, but most of these members are ignored.
   
 
The command should work as follows:
 
The command should work as follows:
 
 
   
 
# The client must set up the <tt>Sana2Connection</tt> data structure, initialize the <tt>s2c_Size</tt>, <tt>s2c_Options</tt>, <tt>s2c_ErrorHook</tt>, <tt>s2c_ConnectHook</tt>, <tt>s2c_DisconnectHook</tt>, <tt>s2c_Login</tt> and <tt>s2c_Password</tt> fields. The <tt>s2c_Options</tt>, <tt>s2c_ConnectHook</tt>, <tt>s2c_Login</tt> and <tt>s2c_Password</tt> fields will be ignored, but the client should play things safe.
 
# The client must set up the <tt>Sana2Connection</tt> data structure, initialize the <tt>s2c_Size</tt>, <tt>s2c_Options</tt>, <tt>s2c_ErrorHook</tt>, <tt>s2c_ConnectHook</tt>, <tt>s2c_DisconnectHook</tt>, <tt>s2c_Login</tt> and <tt>s2c_Password</tt> fields. The <tt>s2c_Options</tt>, <tt>s2c_ConnectHook</tt>, <tt>s2c_Login</tt> and <tt>s2c_Password</tt> fields will be ignored, but the client should play things safe.
Line 726: Line 727:
 
I propose a command with the following semantics:
 
I propose a command with the following semantics:
   
<pre> NAME
+
<pre>
  +
NAME
 
S2_DISCONNECT -- Go offline and close a link layer connection
 
S2_DISCONNECT -- Go offline and close a link layer connection
 
previously established with S2_CONNECT.
 
previously established with S2_CONNECT.
Line 768: Line 770:
   
 
SEE ALSO
 
SEE ALSO
S2_CONNECT</pre>
+
S2_CONNECT
  +
</pre>
  +
 
I propose that the following command number should be assigned:
 
I propose that the following command number should be assigned:
   
 
<tt>#define S2_DISCONNECT 0xC006</tt>
 
<tt>#define S2_DISCONNECT 0xC006</tt>
   
=== 2.6 <tt>S2_SAMPLE_THROUGHPUT</tt> ===
+
=== S2_SAMPLE_THROUGHPUT ===
   
 
The SANA-II standard already allows for statistics to be returned on the amount of data that has passed through a driver. Unfortunately, that information is not very accurate in that no information is provided on the time span in which the data was accumulated. Such information would be helpful in trying to determine as accurately as possible how large the data throughput actually is. I therefore propose a new command which can be used to obtain that information, which uses the following data structure:
 
The SANA-II standard already allows for statistics to be returned on the amount of data that has passed through a driver. Unfortunately, that information is not very accurate in that no information is provided on the time span in which the data was accumulated. Such information would be helpful in trying to determine as accurately as possible how large the data throughput actually is. I therefore propose a new command which can be used to obtain that information, which uses the following data structure:
   
  +
<syntaxhighlight>
<pre>struct Sana2ThroughputStats
 
  +
struct Sana2ThroughputStats
 
{
 
{
 
ULONG s2ts_Length;
 
ULONG s2ts_Length;
Line 790: Line 795:
 
S2QUAD s2ts_BytesReceived;
 
S2QUAD s2ts_BytesReceived;
 
S2QUAD s2ts_Updates;
 
S2QUAD s2ts_Updates;
};</pre>
+
};
  +
</syntaxhighlight>
  +
 
Before I proceed to explain what purposes the individual members serve, a few words on the <tt>S2QUAD</tt> type, which is defined as follows:
 
Before I proceed to explain what purposes the individual members serve, a few words on the <tt>S2QUAD</tt> type, which is defined as follows:
   
Line 798: Line 805:
   
 
The structure members have the following purposes:
 
The structure members have the following purposes:
 
 
   
 
<tt>s2ts_Length</tt>
 
<tt>s2ts_Length</tt>
Line 845: Line 850:
 
I propose a command with the following semantics:
 
I propose a command with the following semantics:
   
<pre> NAME
+
<pre>
  +
NAME
 
S2_SAMPLE_THROUGHPUT -- Obtain accurate information on
 
S2_SAMPLE_THROUGHPUT -- Obtain accurate information on
 
driver data throughput.
 
driver data throughput.
Line 872: Line 878:
 
it will immediately return the IOSana2Req with
 
it will immediately return the IOSana2Req with
 
ios2_Req.io_Error set to IOERR_NOCMD. Otherwise, the request will
 
ios2_Req.io_Error set to IOERR_NOCMD. Otherwise, the request will
remain queued until it is removed with AbortIO() later.</pre>
+
remain queued until it is removed with AbortIO() later.
  +
</pre>
  +
 
I propose that the following command number should be assigned:
 
I propose that the following command number should be assigned:
   
 
<tt>#define S2_SAMPLE_THROUGHPUT 0xC007</tt>
 
<tt>#define S2_SAMPLE_THROUGHPUT 0xC007</tt>
   
== 3. Annotations for existing commands ==
+
== Annotations for existing commands ==
   
  +
=== S2_ONLINE and S2_OFFLINE ===
 
 
=== 3.1 <tt>S2_ONLINE</tt> and <tt>S2_OFFLINE</tt> ===
 
   
 
This proposal introduces two new commands (<tt>S2_CONNECT</tt> and <tt>S2_DISCONNECT</tt>) which are somewhat related to the <tt>S2_ONLINE</tt> and <tt>S2_OFFLINE</tt> commands. How this relation works out shall be explained below. Note that the following text assumes that both the <tt>S2_CONNECT</tt>/<tt>S2_DISCONNECT</tt> and <tt>S2_ONLINE</tt>/<tt>S2_OFFLINE</tt> command pairs are implemented.
 
This proposal introduces two new commands (<tt>S2_CONNECT</tt> and <tt>S2_DISCONNECT</tt>) which are somewhat related to the <tt>S2_ONLINE</tt> and <tt>S2_OFFLINE</tt> commands. How this relation works out shall be explained below. Note that the following text assumes that both the <tt>S2_CONNECT</tt>/<tt>S2_DISCONNECT</tt> and <tt>S2_ONLINE</tt>/<tt>S2_OFFLINE</tt> command pairs are implemented.
Line 895: Line 901:
 
If the <tt>S2_CONNECT</tt> command was never successfully executed, then the commands <tt>S2_ONLINE</tt> and <tt>S2_OFFLINE</tt> must be rejected with <tt>ios2_Req.io_Error=S2ERR_BAD_STATE</tt> and <tt>ios2_WireError=S2WERR_UNIT_DISCONNECTED</tt>.
 
If the <tt>S2_CONNECT</tt> command was never successfully executed, then the commands <tt>S2_ONLINE</tt> and <tt>S2_OFFLINE</tt> must be rejected with <tt>ios2_Req.io_Error=S2ERR_BAD_STATE</tt> and <tt>ios2_WireError=S2WERR_UNIT_DISCONNECTED</tt>.
   
  +
== Extensions for existing commands ==
   
  +
=== S2_DEVICEQUERY ===
 
== 4. Extensions for existing commands ==
 
 
 
 
=== 4.1 <tt>S2_DEVICEQUERY</tt> ===
 
   
 
The <tt>Sana2DeviceQuery</tt> structure filled in by the <tt>S2_DEVICEQUERY</tt> command provides for information on the device's properties, including the maximum transmission unit (MTU) that may be used. What is not specifically covered is the 'raw' MTU a device may offer. In this context 'raw' means the number of bytes that are available for reading and writing when using the <tt>SANA2IOB_RAW</tt> flag with a <tt>CMD_READ</tt>/<tt>CMD_WRITE</tt> request on a device that supports these access methods. Currently, software developers can only make assumptions on how many bytes might comprise the 'raw' MTU by checking the <tt>Sana2DeviceQuery.HardwareType</tt> member and hoping that the driver supports raw <tt>CMD_READ</tt>/<tt>CMD_WRITE</tt> access.
 
The <tt>Sana2DeviceQuery</tt> structure filled in by the <tt>S2_DEVICEQUERY</tt> command provides for information on the device's properties, including the maximum transmission unit (MTU) that may be used. What is not specifically covered is the 'raw' MTU a device may offer. In this context 'raw' means the number of bytes that are available for reading and writing when using the <tt>SANA2IOB_RAW</tt> flag with a <tt>CMD_READ</tt>/<tt>CMD_WRITE</tt> request on a device that supports these access methods. Currently, software developers can only make assumptions on how many bytes might comprise the 'raw' MTU by checking the <tt>Sana2DeviceQuery.HardwareType</tt> member and hoping that the driver supports raw <tt>CMD_READ</tt>/<tt>CMD_WRITE</tt> access.
Line 907: Line 909:
 
I propose that the <tt>S2_DEVICEQUERY</tt> command and the associated <tt>Sana2DeviceQuery</tt> structure are extended to allow for the raw MTU to be queried. The new <tt>Sana2DeviceQuery</tt> structure would look like this:
 
I propose that the <tt>S2_DEVICEQUERY</tt> command and the associated <tt>Sana2DeviceQuery</tt> structure are extended to allow for the raw MTU to be queried. The new <tt>Sana2DeviceQuery</tt> structure would look like this:
   
  +
<syntaxhighlight>
<pre>struct Sana2DeviceQuery
 
  +
struct Sana2DeviceQuery
 
{
 
{
 
/*
 
/*
Line 929: Line 932:
 
** Format specific information
 
** Format specific information
 
*/
 
*/
};</pre>
+
};
  +
</syntaxhighlight>
  +
 
The <tt>RawMTU</tt> member is new. Devices which do not know and support this structure member may fill in the <tt>Sana2DeviceQuery</tt> structure only up to and including the <tt>HardwareType</tt> member.
 
The <tt>RawMTU</tt> member is new. Devices which do not know and support this structure member may fill in the <tt>Sana2DeviceQuery</tt> structure only up to and including the <tt>HardwareType</tt> member.
   
Line 938: Line 943:
 
A word of warning: a little testing with various Ethernet hardware drivers has revealed that the A2065 driver <tt>a2065.device</tt> does not handle the <tt>S2_DEVICEQUERY</tt> command properly if the <tt>Sana2DeviceQuery</tt> structure provided is larger than 30 bytes. In other words, the command will fail if the proposed <tt>RawMTU</tt> member is present in the query data structure to be filled in.
 
A word of warning: a little testing with various Ethernet hardware drivers has revealed that the A2065 driver <tt>a2065.device</tt> does not handle the <tt>S2_DEVICEQUERY</tt> command properly if the <tt>Sana2DeviceQuery</tt> structure provided is larger than 30 bytes. In other words, the command will fail if the proposed <tt>RawMTU</tt> member is present in the query data structure to be filled in.
   
  +
== New events ==
   
  +
=== S2EVENT_CONFIGCHANGED ===
 
== 5. New events ==
 
 
 
 
=== 5.1 <tt>S2EVENT_CONFIGCHANGED</tt> ===
 
   
 
The SANA-II standard does not cover protocols or devices which can change their properties during operation, such as the hardware address of the underlying driver. For drivers such as those which implement the proposed <tt>S2_GETPEERADDRESS</tt> and <tt>S2_GETDNSADDRESS</tt> commands it is vital that such changes can take place and be noticed by the client software. For this purpose I propose that a new event type is introduced, to be used with the SANA-II <tt>S2_ONEVENT</tt> command, using the following definition:
 
The SANA-II standard does not cover protocols or devices which can change their properties during operation, such as the hardware address of the underlying driver. For drivers such as those which implement the proposed <tt>S2_GETPEERADDRESS</tt> and <tt>S2_GETDNSADDRESS</tt> commands it is vital that such changes can take place and be noticed by the client software. For this purpose I propose that a new event type is introduced, to be used with the SANA-II <tt>S2_ONEVENT</tt> command, using the following definition:
Line 951: Line 952:
   
 
This event should be triggered whenever client-visible configuration information changes, as can be queried via the <tt>S2_DEVICEQUERY</tt>, <tt>S2_GETSTATIONADDRESS</tt>, <tt>S2_GETSPECIALSTATS</tt>, <tt>S2_GETGLOBALSTATS</tt>, <tt>S2_GETPEERADDRESS</tt> and <tt>S2_GETDNSADDRESS</tt> commands. Here is a short list of what could change:
 
This event should be triggered whenever client-visible configuration information changes, as can be queried via the <tt>S2_DEVICEQUERY</tt>, <tt>S2_GETSTATIONADDRESS</tt>, <tt>S2_GETSPECIALSTATS</tt>, <tt>S2_GETGLOBALSTATS</tt>, <tt>S2_GETPEERADDRESS</tt> and <tt>S2_GETDNSADDRESS</tt> commands. Here is a short list of what could change:
 
 
   
 
<tt>S2_DEVICEQUERY</tt>
 
<tt>S2_DEVICEQUERY</tt>
Line 978: Line 977:
 
Since the <tt>S2EVENT_CONFIGCHANGED</tt> event may arrive at any time and does not indicate what exactly has changed, application software should query the information it expects to change during its life time, and keep a copy of it around for later reference. When the <tt>S2EVENT_CONFIGCHANGED</tt> event arrives, it can compare the contents of the copy against the current state of affairs and act according to the differences it finds.
 
Since the <tt>S2EVENT_CONFIGCHANGED</tt> event may arrive at any time and does not indicate what exactly has changed, application software should query the information it expects to change during its life time, and keep a copy of it around for later reference. When the <tt>S2EVENT_CONFIGCHANGED</tt> event arrives, it can compare the contents of the copy against the current state of affairs and act according to the differences it finds.
   
  +
=== S2EVENT_CONNECT ===
 
 
=== 5.2 <tt>S2EVENT_CONNECT</tt> ===
 
   
 
This event is a counterpart to <tt>S2EVENT_ONLINE</tt>, and is associated with the <tt>S2_CONNECT</tt> command. I propose the following semantics:
 
This event is a counterpart to <tt>S2EVENT_ONLINE</tt>, and is associated with the <tt>S2_CONNECT</tt> command. I propose the following semantics:
Line 988: Line 985:
 
The event is to be sent when the driver has successfully established a link layer connection.
 
The event is to be sent when the driver has successfully established a link layer connection.
   
  +
=== S2EVENT_DISCONNECT ===
 
 
=== 5.3 <tt>S2EVENT_DISCONNECT</tt> ===
 
   
 
This event is a counterpart to <tt>S2EVENT_OFFLINE</tt>, and is associated with the <tt>S2_DISCONNECT</tt> command. I propose the following semantics:
 
This event is a counterpart to <tt>S2EVENT_OFFLINE</tt>, and is associated with the <tt>S2_DISCONNECT</tt> command. I propose the following semantics:
Line 998: Line 993:
 
The event is to be sent when the driver has closed the link layer connection previously established by the <tt>S2_CONNECT</tt> command.
 
The event is to be sent when the driver has closed the link layer connection previously established by the <tt>S2_CONNECT</tt> command.
   
  +
== New wire error codes ==
   
  +
=== S2WERR_UNIT_DISCONNECTED ===
 
== 6. New wire error codes ==
 
 
 
 
=== 6.1 <tt>S2WERR_UNIT_DISCONNECTED</tt> ===
 
   
 
This error code is a counterpart to <tt>S2WERR_UNIT_OFFLINE</tt>. It indicates that the associated command could not be executed because the link layer is not connected.
 
This error code is a counterpart to <tt>S2WERR_UNIT_OFFLINE</tt>. It indicates that the associated command could not be executed because the link layer is not connected.
Line 1,012: Line 1,003:
 
<tt>#define S2WERR_UNIT_DISCONNECTED 19 /* unit is currently not connected */</tt>
 
<tt>#define S2WERR_UNIT_DISCONNECTED 19 /* unit is currently not connected */</tt>
   
  +
=== S2WERR_UNIT_CONNECTED ===
 
 
=== 6.2 <tt>S2WERR_UNIT_CONNECTED</tt> ===
 
   
 
This error code is a counterpart to <tt>S2WERR_UNIT_ONLINE</tt>. It indicates that the associated command could not be executed because the link layer is already connected.
 
This error code is a counterpart to <tt>S2WERR_UNIT_ONLINE</tt>. It indicates that the associated command could not be executed because the link layer is already connected.
Line 1,022: Line 1,011:
 
<tt>#define S2WERR_UNIT_CONNECTED 20 /* unit is currently connected */</tt>
 
<tt>#define S2WERR_UNIT_CONNECTED 20 /* unit is currently connected */</tt>
   
  +
=== S2WERR_INVALID_OPTION ===
 
 
=== 6.3 <tt>S2WERR_INVALID_OPTION</tt> ===
 
   
 
This error code indicates that an option, such as passed by the <tt>S2_CONNECT</tt> command, is not acceptable. The option's value may be out of range or may not match the syntax specifications. To indicate which option that may be, a different mechanism '''must''' be used; a simple indication that something was wrong is '''not sufficient'''.
 
This error code indicates that an option, such as passed by the <tt>S2_CONNECT</tt> command, is not acceptable. The option's value may be out of range or may not match the syntax specifications. To indicate which option that may be, a different mechanism '''must''' be used; a simple indication that something was wrong is '''not sufficient'''.
Line 1,032: Line 1,019:
 
<tt>#define S2WERR_INVALID_OPTION 21 /* invalid option rejected */</tt>
 
<tt>#define S2WERR_INVALID_OPTION 21 /* invalid option rejected */</tt>
   
  +
=== S2WERR_MISSING_OPTION ===
 
 
=== 6.4 <tt>S2WERR_MISSING_OPTION</tt> ===
 
   
 
This error code indicates that a mandatory option, such as passed by the <tt>S2_CONNECT</tt> command, is not present. To indicate which option that may be, a different mechanism '''must''' be used; a simple indication that something was wrong is '''not sufficient'''.
 
This error code indicates that a mandatory option, such as passed by the <tt>S2_CONNECT</tt> command, is not present. To indicate which option that may be, a different mechanism '''must''' be used; a simple indication that something was wrong is '''not sufficient'''.
Line 1,042: Line 1,027:
 
<tt>#define S2WERR_MISSING_OPTION 22 /* a mandatory option is missing */</tt>
 
<tt>#define S2WERR_MISSING_OPTION 22 /* a mandatory option is missing */</tt>
   
  +
=== S2WERR_AUTHENTICATION_FAILED ===
 
 
=== 6.5 <tt>S2WERR_AUTHENTICATION_FAILED</tt> ===
 
   
 
Some drivers run protocols that require them to authenticate to a server. That process may fail. This wire error code is to indicate this fact.
 
Some drivers run protocols that require them to authenticate to a server. That process may fail. This wire error code is to indicate this fact.
Line 1,052: Line 1,035:
 
<tt>#define S2WERR_AUTHENTICATION_FAILED 23 /* could not log in */</tt>
 
<tt>#define S2WERR_AUTHENTICATION_FAILED 23 /* could not log in */</tt>
   
  +
== Callbacks ==
   
  +
=== S2_DMACopyToBuff64 and S2_DMACopyFromBuff64 ===
 
== 7. Callbacks ==
 
 
 
 
=== 7.1 <tt>S2_DMACopyToBuff64</tt> and <tt>S2_DMACopyFromBuff64</tt> ===
 
   
 
These two callbacks are identical in operation to the <tt>S2_DMACopyToBuff32</tt> and <tt>S2_DMACopyFromBuff32</tt> callbacks, as specified in the SANA-IIR3 standard. The difference is in that the memory region DMA is to take place in must be aligned to a 64 bit boundary and must be large enough to hold data that is a multiple of 64 bits in size. The purpose of these hooks is to allow for 64 bit aligned PCI DMA accesses to take place.
 
These two callbacks are identical in operation to the <tt>S2_DMACopyToBuff32</tt> and <tt>S2_DMACopyFromBuff32</tt> callbacks, as specified in the SANA-IIR3 standard. The difference is in that the memory region DMA is to take place in must be aligned to a 64 bit boundary and must be large enough to hold data that is a multiple of 64 bits in size. The purpose of these hooks is to allow for 64 bit aligned PCI DMA accesses to take place.
Line 1,068: Line 1,047:
 
#define S2_DMACopyFromBuff64 (S2_Dummy + 11)
 
#define S2_DMACopyFromBuff64 (S2_Dummy + 11)
   
  +
=== S2_Log ===
 
 
=== 7.2 <tt>S2_Log</tt> ===
 
   
 
A driver may want to report an important event for the user to see. Adding a log message to a file or opening a window to display a message in may not be the optimum approach as the user may be unaware of the context into which the message belongs. It may be advisable for the driver to use the message reporting and logging facilities used by the client software that uses its services, such as a TCP/IP stack. The <tt>S2_Log</tt> callback hook is intended to provide for such a link. If present, the driver must use this callback hook rather than whatever logging methods it implements itself. Note that unlike the other SANA-II callbacks, this is a regular hook, as to be invoked using <tt>utility.library</tt>/<tt>CallHookPkt()</tt>. The hook function is invoked using the following parameters:
 
A driver may want to report an important event for the user to see. Adding a log message to a file or opening a window to display a message in may not be the optimum approach as the user may be unaware of the context into which the message belongs. It may be advisable for the driver to use the message reporting and logging facilities used by the client software that uses its services, such as a TCP/IP stack. The <tt>S2_Log</tt> callback hook is intended to provide for such a link. If present, the driver must use this callback hook rather than whatever logging methods it implements itself. Note that unlike the other SANA-II callbacks, this is a regular hook, as to be invoked using <tt>utility.library</tt>/<tt>CallHookPkt()</tt>. The hook function is invoked using the following parameters:
   
  +
<pre>
<pre>log_hook_function(hook,reserved,message)
 
  +
log_hook_function(hook,reserved,message)
A0 A2 A1
 
   
 
void log_hook_function(struct hook * hook,APTR reserved,
 
void log_hook_function(struct hook * hook,APTR reserved,
struct S2LogMessage * message);</pre>
+
struct S2LogMessage * message);
  +
</pre>
  +
 
The <tt>reserved</tt> parameter '''must''' be set to <tt>NULL</tt>. The <tt>S2LogMessage</tt> structure passed as the third parameter looks like this:
 
The <tt>reserved</tt> parameter '''must''' be set to <tt>NULL</tt>. The <tt>S2LogMessage</tt> structure passed as the third parameter looks like this:
   
  +
<syntaxhighlight>
<pre>struct S2LogMessage
 
  +
struct S2LogMessage
 
{
 
{
 
LONG s2lm_Size;
 
LONG s2lm_Size;
Line 1,087: Line 1,067:
 
STRPTR s2lm_Name;
 
STRPTR s2lm_Name;
 
STRPTR s2lm_Message;
 
STRPTR s2lm_Message;
};</pre>
+
};
  +
</syntaxhighlight>
  +
 
The individual structure members serve the following functions:
 
The individual structure members serve the following functions:
 
 
   
 
<tt>s2lm_Size</tt>
 
<tt>s2lm_Size</tt>
Line 1,099: Line 1,079:
   
 
The smaller this value, the more important the message to be logged or displayed. The following priority levels are defined (similar to the Unix <tt>syslog()</tt> mechanism):
 
The smaller this value, the more important the message to be logged or displayed. The following priority levels are defined (similar to the Unix <tt>syslog()</tt> mechanism):
 
 
   
 
<tt>#define S2LOG_Emergency 0</tt>
 
<tt>#define S2LOG_Emergency 0</tt>
Line 1,154: Line 1,132:
 
<tt>#define S2_Log (S2_Dummy + 12)</tt>
 
<tt>#define S2_Log (S2_Dummy + 12)</tt>
   
  +
== Proposed driver requirements ==
 
 
== 8. Proposed driver requirements ==
 
   
 
This is an attempt to clarify part of the specification and to lay down a few rules that every SANA-II driver should follow in addition to the requirements described in the existing specifications. Here is what I propose:
 
This is an attempt to clarify part of the specification and to lay down a few rules that every SANA-II driver should follow in addition to the requirements described in the existing specifications. Here is what I propose:
 
 
   
 
<ul>
 
<ul>
Line 1,172: Line 1,146:
 
To simplify client software configuration, drivers may treat packet type 2048 as equivalent to the packet number associated with IP frames. This association is permitted only if it does not introduce ambiguity. For example, this association would not be permitted if the driver would receive and transmit IP packets in two different frame types or if the driver already associates packet type 2048 with non-IP packets.</li></ul>
 
To simplify client software configuration, drivers may treat packet type 2048 as equivalent to the packet number associated with IP frames. This association is permitted only if it does not introduce ambiguity. For example, this association would not be permitted if the driver would receive and transmit IP packets in two different frame types or if the driver already associates packet type 2048 with non-IP packets.</li></ul>
   
  +
== Unsolved problems ==
 
 
== 9. Unsolved problems ==
 
 
 
   
 
* Protocols like PPP can provide both for IPv4 and IPv6 addresses that should be used by the local client, the peer or any of the domain name servers. While the two addressing families are interoperable, there is a problem in how the driver should report them. Can you assume 128 bit addresses and encapsulate 32 bit addresses in them? If so, how do you make sure that the address format is unambiguous?
 
* Protocols like PPP can provide both for IPv4 and IPv6 addresses that should be used by the local client, the peer or any of the domain name servers. While the two addressing families are interoperable, there is a problem in how the driver should report them. Can you assume 128 bit addresses and encapsulate 32 bit addresses in them? If so, how do you make sure that the address format is unambiguous?
Line 1,182: Line 1,152:
 
* How to extend the <tt>Sana2DeviceQuery</tt> structure in the future? The current layout separates standard, common and format specific information, but there is no hint as to where which each section starts and where the next begins. Now that there is a proposal to add a new field to the common section, how would you add fields to the format specific section?
 
* How to extend the <tt>Sana2DeviceQuery</tt> structure in the future? The current layout separates standard, common and format specific information, but there is no hint as to where which each section starts and where the next begins. Now that there is a proposal to add a new field to the common section, how would you add fields to the format specific section?
   
  +
== Changes ==
   
  +
Changes since 02-May-2012:
   
  +
* Converted to MediaWiki format.
== 10. Changes ==
 
   
 
Changes since 24-Dec-2002:
 
Changes since 24-Dec-2002:
 
 
   
 
* The <tt>Sana2Connection</tt> data structure used by the <tt>S2_CONNECT</tt> command now must remain valid until the <tt>S2_DISCONNECT</tt> command is sent (see [[#2.4|section 2.4]]).
 
* The <tt>Sana2Connection</tt> data structure used by the <tt>S2_CONNECT</tt> command now must remain valid until the <tt>S2_DISCONNECT</tt> command is sent (see [[#2.4|section 2.4]]).
   
 
Changes since 01-May-2002:
 
Changes since 01-May-2002:
 
 
   
 
* Added the <tt>ppp.async.readrequests</tt> and <tt>ppp.async.eof</tt> configuration keywords.
 
* Added the <tt>ppp.async.readrequests</tt> and <tt>ppp.async.eof</tt> configuration keywords.
   
 
Changes since 04-Jan-2002:
 
Changes since 04-Jan-2002:
 
 
   
 
* Added the <tt>ppp.dummyremoteaddress</tt> and <tt>ppp.ethernet.ac</tt> configuration keywords.
 
* Added the <tt>ppp.dummyremoteaddress</tt> and <tt>ppp.ethernet.ac</tt> configuration keywords.
   
 
Changes since 10-Dec-2001:
 
Changes since 10-Dec-2001:
 
 
   
 
* Converted to HTML format.
 
* Converted to HTML format.
Line 1,213: Line 1,177:
   
 
Changes since 19-Nov-2001:
 
Changes since 19-Nov-2001:
 
 
   
 
* Added to the list of reserved configuration keywords (<tt>ppp.idletimeout</tt>, <tt>ppp.peeridletimeout</tt>, <tt>ppp.sendid</tt>).
 
* Added to the list of reserved configuration keywords (<tt>ppp.idletimeout</tt>, <tt>ppp.peeridletimeout</tt>, <tt>ppp.sendid</tt>).
Line 1,224: Line 1,186:
   
 
Changes since 12-Nov-2001:
 
Changes since 12-Nov-2001:
 
 
   
 
* Changed the command numbers of <tt>S2_GETPEERADDRESS</tt>, <tt>S2_GETDNSADDRESS</tt>, <tt>S2_GETEXTENDEDGLOBALSTATS</tt>, <tt>S2_CONNECT</tt>, <tt>S2_DISCONNECT</tt> and <tt>S2_SAMPLE_THROUGHPUT</tt> to be NSD-compliant. Also assigned a new number to the <tt>S2_SAMPLE_THROUGHPUT </tt> command.
 
* Changed the command numbers of <tt>S2_GETPEERADDRESS</tt>, <tt>S2_GETDNSADDRESS</tt>, <tt>S2_GETEXTENDEDGLOBALSTATS</tt>, <tt>S2_CONNECT</tt>, <tt>S2_DISCONNECT</tt> and <tt>S2_SAMPLE_THROUGHPUT</tt> to be NSD-compliant. Also assigned a new number to the <tt>S2_SAMPLE_THROUGHPUT </tt> command.
Line 1,232: Line 1,192:
   
 
Changes since 03-Nov-2001:
 
Changes since 03-Nov-2001:
 
 
   
 
* Renamed <tt>S2_GETNEWGLOBALSTATS</tt> to <tt>S2_GETEXTENDEDGLOBALSTATS</tt> (see [[#2.3|section 2.3]]).
 
* Renamed <tt>S2_GETNEWGLOBALSTATS</tt> to <tt>S2_GETEXTENDEDGLOBALSTATS</tt> (see [[#2.3|section 2.3]]).
Line 1,247: Line 1,205:
   
 
Changes since 14-Oct-2001:
 
Changes since 14-Oct-2001:
 
 
   
 
* Added <tt>S2_CONNECT</tt> and <tt>S2_DISCONNECT</tt> commands.
 
* Added <tt>S2_CONNECT</tt> and <tt>S2_DISCONNECT</tt> commands.
Line 1,256: Line 1,212:
 
* Removed item on <tt>S2_CONNECT</tt>/<tt>S2_DISCONNECT</tt> from section 7 (&quot;Unsolved problems&quot;).
 
* Removed item on <tt>S2_CONNECT</tt>/<tt>S2_DISCONNECT</tt> from section 7 (&quot;Unsolved problems&quot;).
 
* Added section 8 (&quot;Changes&quot;).
 
* Added section 8 (&quot;Changes&quot;).
 
== 11. Updated <tt>&lt;devices/sana2.h&gt;</tt> header file ==
 
 
Attached below you will find the updated <tt>&lt;devices/sana2.h&gt;</tt> header file, which includes corrections and definitions for all the proposed changes:
 
 
<pre>#ifndef SANA2_SANA2DEVICE_H
 
#define SANA2_SANA2DEVICE_H 1
 
 
/*
 
** $Filename$
 
** $Revision: 1.1 $
 
** $Date: 2005-06-09 08:46:16 $
 
**
 
** Structure definitions for SANA-II devices.
 
**
 
** (C) Copyright 1991-2002 Amiga, Inc.
 
** All Rights Reserved
 
*/
 
 
#ifndef EXEC_TYPES_H
 
#include &lt;exec/types.h&gt;
 
#endif
 
 
#ifndef EXEC_PORTS_H
 
#include &lt;exec/ports.h&gt;
 
#endif
 
 
#ifndef EXEC_IO_H
 
#include &lt;exec/io.h&gt;
 
#endif
 
 
#ifndef EXEC_TASKS_H
 
#include &lt;exec/tasks.h&gt;
 
#endif
 
 
#ifndef EXEC_ERRORS_H
 
#include &lt;exec/errors.h&gt;
 
#endif
 
 
#ifndef DEVICES_TIMER_H
 
#include &lt;devices/timer.h&gt;
 
#endif
 
 
#ifndef UTILITY_TAGITEM_H
 
#include &lt;utility/tagitem.h&gt;
 
#endif
 
 
#ifndef UTILITY_HOOKS_H
 
#include &lt;utility/hooks.h&gt;
 
#endif
 
 
#define SANA2_MAX_ADDR_BITS (128)
 
#define SANA2_MAX_ADDR_BYTES ((SANA2_MAX_ADDR_BITS+7)/8)
 
 
struct IOSana2Req
 
{
 
struct IORequest ios2_Req;
 
 
ULONG ios2_WireError; /* wire type specific error */
 
ULONG ios2_PacketType; /* packet type */
 
UBYTE ios2_SrcAddr[SANA2_MAX_ADDR_BYTES]; /* source address */
 
UBYTE ios2_DstAddr[SANA2_MAX_ADDR_BYTES]; /* dest address */
 
ULONG ios2_DataLength; /* length of packet data */
 
APTR ios2_Data; /* packet data */
 
APTR ios2_StatData; /* statistics data pointer */
 
APTR ios2_BufferManagement; /* see SANA-II OpenDevice adoc */
 
};
 
 
/*
 
** Defines for the io_Flags field
 
*/
 
#define SANA2IOB_RAW (7) /* raw packet IO requested */
 
#define SANA2IOB_BCAST (6) /* broadcast packet (received) */
 
#define SANA2IOB_MCAST (5) /* multicast packet (received) */
 
#define SANA2IOB_QUICK (IOB_QUICK) /* quick IO requested (0) */
 
 
#define SANA2IOF_RAW (1&lt;&lt;SANA2IOB_RAW)
 
#define SANA2IOF_BCAST (1&lt;&lt;SANA2IOB_BCAST)
 
#define SANA2IOF_MCAST (1&lt;&lt;SANA2IOB_MCAST)
 
#define SANA2IOF_QUICK (IOF_QUICK)
 
 
/*
 
** Defines for OpenDevice() flags
 
*/
 
#define SANA2OPB_MINE (0) /* exclusive access requested */
 
#define SANA2OPB_PROM (1) /* promiscuous mode requested */
 
 
#define SANA2OPF_MINE (1&lt;&lt;SANA2OPB_MINE)
 
#define SANA2OPF_PROM (1&lt;&lt;SANA2OPB_PROM)
 
 
/*
 
** Defines for OpenDevice() tags
 
*/
 
#define S2_Dummy (TAG_USER + 0xB0000)
 
 
#define S2_CopyToBuff (S2_Dummy + 1)
 
#define S2_CopyFromBuff (S2_Dummy + 2)
 
#define S2_PacketFilter (S2_Dummy + 3)
 
#define S2_CopyToBuff16 (S2_Dummy + 4)
 
#define S2_CopyFromBuff16 (S2_Dummy + 5)
 
#define S2_CopyToBuff32 (S2_Dummy + 6)
 
#define S2_CopyFromBuff32 (S2_Dummy + 7)
 
#define S2_DMACopyToBuff32 (S2_Dummy + 8)
 
#define S2_DMACopyFromBuff32 (S2_Dummy + 9)
 
#define S2_DMACopyToBuff64 (S2_Dummy + 10)
 
#define S2_DMACopyFromBuff64 (S2_Dummy + 11)
 
#define S2_Log (S2_Dummy + 12)
 
 
/*
 
** Filled in by 'S2_DEVICEQUERY'
 
*/
 
struct Sana2DeviceQuery
 
{
 
/*
 
** Standard information
 
*/
 
ULONG SizeAvailable; /* bytes available */
 
ULONG SizeSupplied; /* bytes supplied */
 
ULONG DevQueryFormat; /* this is type 0 */
 
ULONG DeviceLevel; /* this document is level 0 */
 
/*
 
** Common information
 
*/
 
UWORD AddrFieldSize; /* address size in bits */
 
ULONG MTU; /* maximum packet data size */
 
ULONG BPS; /* line rate (bits/sec) */
 
ULONG HardwareType; /* what the wire is (see below) */
 
ULONG RawMTU; /* maximum raw packet data size */
 
/*
 
** Format specific information
 
*/
 
};
 
 
/*
 
** Defined Hardware types
 
**
 
** If your hardware type is not listed below contact Amiga to get
 
** a new type number added for your hardware.
 
*/
 
#define S2WireType_Ethernet 1
 
#define S2WireType_IEEE802 6
 
#define S2WireType_Arcnet 7
 
#define S2WireType_LocalTalk 11
 
#define S2WireType_DyLAN 12
 
 
#define S2WireType_AmokNet 200 /* Amiga Floppy Port hardware */
 
 
#define S2WireType_Liana 202 /* Village Tronic parallel port hw */
 
 
#define S2WireType_PPP 253
 
#define S2WireType_SLIP 254
 
#define S2WireType_CSLIP 255 /* Compressed SLIP */
 
 
#define S2WireType_PLIP 420 /* SLIP over a parallel port */
 
 
/*
 
** Filled in by 'S2_GETTYPESTATS'
 
*/
 
struct Sana2PacketTypeStats
 
{
 
ULONG PacketsSent; /* transmitted count */
 
ULONG PacketsReceived; /* received count */
 
ULONG BytesSent; /* bytes transmitted count */
 
ULONG BytesReceived; /* bytes received count */
 
ULONG PacketsDropped; /* packets dropped count */
 
};
 
 
/*
 
** Filled in by 'S2_GETSPECIALSTATS'
 
*/
 
struct Sana2SpecialStatRecord
 
{
 
ULONG Type; /* statistic identifier */
 
ULONG Count; /* the statistic */
 
STRPTR String; /* statistic name */
 
};
 
 
struct Sana2SpecialStatHeader
 
{
 
ULONG RecordCountMax; /* room available */
 
ULONG RecordCountSupplied; /* number supplied */
 
/* struct Sana2SpecialStatRecord[RecordCountMax]; */
 
};
 
 
/*
 
** Filled in by 'S2_GETGLOBALSTATS'
 
*/
 
struct Sana2DeviceStats
 
{
 
ULONG PacketsReceived; /* received count */
 
ULONG PacketsSent; /* transmitted count */
 
ULONG BadData; /* bad packets received */
 
ULONG Overruns; /* hardware miss count */
 
ULONG Unused; /* Unused field */
 
ULONG UnknownTypesReceived; /* orphan count */
 
ULONG Reconfigurations; /* network reconfigurations */
 
struct timeval LastStart; /* time of last online */
 
};
 
 
/*
 
** A 64 bit big endian integer in ISO 'C' terms.
 
*/
 
typedef struct
 
{
 
ULONG s2q_High;
 
ULONG s2q_Low;
 
} S2QUAD;
 
 
/*
 
** Revised version, filled in by 'S2_GETEXTENDEDGLOBALSTATS'
 
*/
 
struct Sana2ExtDeviceStats
 
{
 
ULONG s2xds_Length;
 
ULONG s2xds_Actual;
 
 
S2QUAD s2xds_PacketsReceived;
 
S2QUAD s2xds_PacketsSent;
 
S2QUAD s2xds_BadData;
 
S2QUAD s2xds_Overruns;
 
S2QUAD s2xds_UnknownTypesReceived;
 
S2QUAD s2xds_Reconfigurations;
 
struct timeval s2xds_LastStart;
 
 
struct timeval s2xds_LastConnected;
 
struct timeval s2xds_LastDisconnected;
 
struct timeval s2xds_TimeConnected;
 
};
 
 
/*
 
** Used by 'S2_CONNECT' and 'S2_DISCONNECT'
 
*/
 
struct Sana2Connection
 
{
 
ULONG s2c_Size;
 
struct MinList s2c_Options;
 
struct Hook s2c_ErrorHook;
 
struct Hook s2c_ConnectHook;
 
struct Hook s2c_DisconnectHook;
 
STRPTR s2c_Login;
 
STRPTR s2c_Password;
 
};
 
 
struct Sana2ConnectionOption
 
{
 
struct MinNode s2co_MinNode;
 
STRPTR s2co_Name;
 
STRPTR s2co_Value;
 
};
 
 
struct Sana2ConnectionMessage
 
{
 
ULONG s2cm_Size;
 
struct Sana2Connection * s2cm_Connection;
 
struct IORequest * s2cm_Request[2];
 
LONG s2cm_RequestType;
 
};
 
 
/*
 
** Used by 'S2_SAMPLE_THROUGHPUT'
 
*/
 
struct Sana2ThroughputStats
 
{
 
ULONG s2ts_Length;
 
ULONG s2ts_Actual;
 
 
struct Task * s2ts_NotifyTask;
 
ULONG s2ts_NotifyMask;
 
 
struct timeval s2ts_StartTime;
 
struct timeval s2ts_EndTime;
 
S2QUAD s2ts_BytesSent;
 
S2QUAD s2ts_BytesReceived;
 
S2QUAD s2ts_Updates;
 
};
 
 
/*
 
** Used by the 'S2_Log' callback hook
 
*/
 
struct S2LogMessage
 
{
 
LONG s2lm_Size;
 
ULONG s2lm_Priority;
 
STRPTR s2lm_Name;
 
STRPTR s2lm_Message;
 
};
 
 
/*
 
** Log priority levels used by the 'S2_Log' callback hook
 
*/
 
#define S2LOG_Emergency 0 /* A panic condition */
 
#define S2LOG_Alert 1 /* A condition that should be corrected
 
immediately */
 
#define S2LOG_Critical 2 /* Critical conditions */
 
#define S2LOG_Error 3 /* A plain error */
 
#define S2LOG_Warning 4 /* A warning message */
 
#define S2LOG_Notice 5 /* Conditions that are not error conditions,
 
but should possibly be handled specially */
 
#define S2LOG_Information 6 /* An informational message */
 
#define S2LOG_Debug 7 /* Generated only in debugging mode */
 
 
/*
 
** Device Commands
 
*/
 
#define S2_START (CMD_NONSTD) /* First old style command */
 
 
#define S2_DEVICEQUERY (S2_START+ 0)
 
#define S2_GETSTATIONADDRESS (S2_START+ 1)
 
#define S2_CONFIGINTERFACE (S2_START+ 2)
 
#define S2_ADDMULTICASTADDRESS (S2_START+ 5)
 
#define S2_DELMULTICASTADDRESS (S2_START+ 6)
 
#define S2_MULTICAST (S2_START+ 7)
 
#define S2_BROADCAST (S2_START+ 8)
 
#define S2_TRACKTYPE (S2_START+ 9)
 
#define S2_UNTRACKTYPE (S2_START+10)
 
#define S2_GETTYPESTATS (S2_START+11)
 
#define S2_GETSPECIALSTATS (S2_START+12)
 
#define S2_GETGLOBALSTATS (S2_START+13)
 
#define S2_ONEVENT (S2_START+14)
 
#define S2_READORPHAN (S2_START+15)
 
#define S2_ONLINE (S2_START+16)
 
#define S2_OFFLINE (S2_START+17)
 
 
#define S2_END (S2_START+18) /* Last old style command */
 
 
/*
 
** New style commands introduced in 1997 and beyond
 
*/
 
#define S2_ADDMULTICASTADDRESSES 0xC000
 
#define S2_DELMULTICASTADDRESSES 0xC001
 
#define S2_GETPEERADDRESS 0xC002
 
#define S2_GETDNSADDRESS 0xC003
 
#define S2_GETEXTENDEDGLOBALSTATS 0xC004
 
#define S2_CONNECT 0xC005
 
#define S2_DISCONNECT 0xC006
 
#define S2_SAMPLE_THROUGHPUT 0xC007
 
 
/*
 
** Defined errors for io_Error (see also &lt;exec/errors.h&gt;)
 
*/
 
#define S2ERR_NO_ERROR 0 /* peachy-keen */
 
#define S2ERR_NO_RESOURCES 1 /* resource allocation failure */
 
#define S2ERR_BAD_ARGUMENT 3 /* garbage somewhere */
 
#define S2ERR_BAD_STATE 4 /* inappropriate state */
 
#define S2ERR_BAD_ADDRESS 5 /* who? */
 
#define S2ERR_MTU_EXCEEDED 6 /* too much to chew */
 
#define S2ERR_NOT_SUPPORTED 8 /* hardware can't support cmd */
 
#define S2ERR_SOFTWARE 9 /* software error detected */
 
#define S2ERR_OUTOFSERVICE 10 /* driver is OFFLINE */
 
#define S2ERR_TX_FAILURE 11 /* Transmission attempt failed */
 
 
/*
 
** From &lt;exec/errors.h&gt;
 
**
 
** IOERR_OPENFAIL (-1) * device/unit failed to open *
 
** IOERR_ABORTED (-2) * request terminated early [after AbortIO()] *
 
** IOERR_NOCMD (-3) * command not supported by device *
 
** IOERR_BADLENGTH (-4) * not a valid length (usually IO_LENGTH) *
 
** IOERR_BADADDRESS (-5) * invalid address (misaligned or bad range) *
 
** IOERR_UNITBUSY (-6) * device opens ok, but requested unit is busy *
 
** IOERR_SELFTEST (-7) * hardware failed self-test *
 
*/
 
 
/*
 
** Defined errors for ios2_WireError
 
*/
 
#define S2WERR_GENERIC_ERROR 0 /* no specific info available */
 
#define S2WERR_NOT_CONFIGURED 1 /* unit not configured */
 
#define S2WERR_UNIT_ONLINE 2 /* unit is currently online */
 
#define S2WERR_UNIT_OFFLINE 3 /* unit is currently offline */
 
#define S2WERR_ALREADY_TRACKED 4 /* protocol already tracked */
 
#define S2WERR_NOT_TRACKED 5 /* protocol not tracked */
 
#define S2WERR_BUFF_ERROR 6 /* buff mgt func returned error */
 
#define S2WERR_SRC_ADDRESS 7 /* source address problem */
 
#define S2WERR_DST_ADDRESS 8 /* destination address problem */
 
#define S2WERR_BAD_BROADCAST 9 /* broadcast address problem */
 
#define S2WERR_BAD_MULTICAST 10 /* multicast address problem */
 
#define S2WERR_MULTICAST_FULL 11 /* multicast address list full */
 
#define S2WERR_BAD_EVENT 12 /* unsupported event class */
 
#define S2WERR_BAD_STATDATA 13 /* statdata failed sanity check */
 
/*** THERE IS NO WIRE ERROR CODE 14 ***/
 
#define S2WERR_IS_CONFIGURED 15 /* attempt to config twice */
 
#define S2WERR_NULL_POINTER 16 /* null pointer detected */
 
#define S2WERR_TOO_MANY_RETRIES 17 /* tx failed - too many retries */
 
#define S2WERR_RCVREL_HDW_ERR 18 /* Driver fixable HW error */
 
#define S2WERR_UNIT_DISCONNECTED 19 /* unit is currently not connected */
 
#define S2WERR_UNIT_CONNECTED 20 /* unit is currently connected */
 
#define S2WERR_INVALID_OPTION 21 /* invalid option rejected */
 
#define S2WERR_MISSING_OPTION 22 /* a mandatory option is missing */
 
#define S2WERR_AUTHENTICATION_FAILED 23 /* could not log in */
 
/*
 
** For our dsylexic friends
 
*/
 
#define S2WERR_TOO_MANY_RETIRES S2WERR_TOO_MANY_RETRIES
 
 
/*
 
** Defined events
 
*/
 
#define S2EVENT_ERROR (1L&lt;&lt; 0) /* error catch all */
 
#define S2EVENT_TX (1L&lt;&lt; 1) /* transmitter error catch all */
 
#define S2EVENT_RX (1L&lt;&lt; 2) /* receiver error catch all */
 
#define S2EVENT_ONLINE (1L&lt;&lt; 3) /* unit is in service */
 
#define S2EVENT_OFFLINE (1L&lt;&lt; 4) /* unit is not in service */
 
#define S2EVENT_BUFF (1L&lt;&lt; 5) /* buff mgt function error */
 
#define S2EVENT_HARDWARE (1L&lt;&lt; 6) /* hardware error catch all */
 
#define S2EVENT_SOFTWARE (1L&lt;&lt; 7) /* software error catch all */
 
#define S2EVENT_CONFIGCHANGED (1L&lt;&lt; 8) /* driver configuration changed */
 
#define S2EVENT_CONNECT (1L&lt;&lt; 9) /* driver has opened session */
 
#define S2EVENT_DISCONNECT (1L&lt;&lt;10) /* driver has closed session */
 
 
#endif /* SANA2_SANA2DEVICE_H */</pre>
 

Latest revision as of 21:54, 10 May 2012

SANA-II Revision 4

Extending the SANA-II network driver specification
by Olaf Barthel

(Last updated 02-Mar-2003)

Introduction

The years have gone by without any substantial changes to the SANA-II standard being made. With good reason, since there was no apparent need to push the envelope and extend the driver specification. The last proposed change came 1997 from Holger Kruse, who suggested that commands should be added to control multicast packet reception for ranges of addresses rather than individual addresses.

I've been working on a TCP/IP stack and PPP drivers to go with them for a while and found that there were some things that SANA-II did specifically not address, and which ought to be covered by it. In other areas clarification was needed. Also, discussions I had with Harald Frank suggested that the extensions made by Heinz Wrobel and Stefan Sticht in the SANA-IIR3 specification could need extending.

The following text tries to tie all issues together and will conclude by listing problems which I think still need attention (or in other words, I didn't find a solution myself). Wherever possible, I have tried to provide a rationale for the changes I propose.

Please feel free to comment; you can contact me through the AmigaOS contact form. Note that the issues discussed in this document are just a list of proposed changes. No such features are part of any SANA-II specifications, although I'd like to claim that I have tried to implement the majority of the changes listed below in my own software.

This is a revised version of the original document I put together around October 14, 2001. For a list of changes that have been made since, please see section 10 ('Changes'). This document has been updated and enhanced several times, in response to discussions with Heinz Wrobel.

New commands

S2_GETPEERADDRESS

As part of the negotiation process, the PPP protocol can return the addresses used by the peer (the other side of the point-to-point connection PPP establishes; typically a dial-in server) and assigned to the client establishing the connection. The SANA-II standard does not provide for a mechanism to return such information. Existing drivers therefore had to resort to other means, such as by setting global environment variables containing this information.

I propose a command with the following semantics:

   NAME
        S2_GETPEERADDRESS -- Obtain the addresses used by the peer
           (server) and the client of a point-to-point connection.

   FUNCTION
        Obtain the address used by the peer of a point-to-point connection and
        the address assigned to the local driver.

   IO REQUEST
        ios2_Command          - S2_GETPEERADDRESS
        ios2_Flags            - Supported flags are:
                                SANA2IOB_QUICK
        ios2_BufferManagement - Magic cookie as returned when opening the
                                driver with a struct IOSana2Req

   RESULTS
        ios2_Req.io_Error - Zero if successful; non-zero otherwise
        ios2_WireError    - More specific error number
        ios2_SrcAddr      - Address assigned to the local driver
        ios2_DstAddr      - Address used by the peer

   NOTES
        The size of the address returned by S2_GETPEERADDRESS must not be
        different from the size returned by the S2_DEVICEQUERY command. For
        example, if a 32 bit IPv4 address was advertized, the driver must not
        return a 128 bit IPv6 address instead.

        If the driver is unable to return the local driver address
        (ios2_SrcAddr) or the peer's address (ios2_DstAddr) it must fill the
        respective address fields with zeroes. It is legal for a driver to
        respond to the S2_GETPEERADDRESS command with two zero addresses (both
        ios2_SrcAddr and ios2_DstAddr filled with zeroes).

I propose that the following command number should be assigned: #define S2_GETPEERADDRESS 0xC002

This command may be useful beyond the typical application (PPP) described above.

S2_GETDNSADDRESS

The PPP negotiation process may produce information on which domain name and NetBIOS name servers are available to the client. I think that it is doubtful that the availability of NetBIOS name servers will be useful for Amiga software (let alone whether NetBIOS name resolution has a future), which is why I suggest that a SANA-II command for returning only the domain name servers is introduced.

I propose a command with the following semantics:

   NAME
        S2_GETDNSADDRESS -- Obtain the addresses of the primary
           and secondary domain name servers.

   FUNCTION
        Obtain the addresses of the domain name servers available to the
        client using this driver's address.

   IO REQUEST
        ios2_Command          - S2_GETDNSADDRESS
        ios2_Flags            - Supported flags are:
                                SANA2IOB_QUICK
        ios2_BufferManagement - Magic cookie as returned when opening the
                                driver with a struct IOSana2Req

   RESULTS
        ios2_Req.io_Error - Zero if successful; non-zero otherwise
        ios2_WireError    - More specific error number
        ios2_SrcAddr      - Address of primary domain name server
        ios2_DstAddr      - Address of secondary domain name server

   NOTES
        The size of the address returned by S2_GETPEERADDRESS must not be
        different from the size as returned by the S2_DEVICEQUERY command. For
        example, if a 32 bit IPv4 address was advertized, the driver must not
        return a 128 bit IPv6 address instead.

        If the driver is unable to return the primary domain name server
        address (ios2_SrcAddr) or the secondary domain name server address
        (ios2_DstAddr) it must fill the respective address fields with zeroes.
        It is legal for a driver to respond to the S2_GETDNSADDRESS command
        with two zero addresses (both ios2_SrcAddr and ios2_DstAddr filled
        with zeroes).

I propose that the following command number should be assigned: #define S2_GETDNSADDRESS 0xC003

This command may be useful beyond the typical application (PPP) described above.

S2_GETEXTENDEDGLOBALSTATS

There already exists a SANA-II command for querying global device statistics (S2_GETGLOBALSTATS) which should be common to all kinds of networking devices. Statistics that are particular to a certain device type are intended to be returned through the S2_GETSPECIALSTATS command. I feel that these mechanisms both fail to cater well enough for dial-up or session-oriented networking applications such as PPP or PPPoE. Since the data structure used by S2_GETGLOBALSTATS is of a fixed size and not intended to accomodate for new fields, I propose to introduce a new command which uses a different data structure, as follows:

struct Sana2ExtDeviceStats
{
   ULONG          s2xds_Length;
   ULONG          s2xds_Actual;
 
   S2QUAD         s2xds_PacketsReceived;
   S2QUAD         s2xds_PacketsSent;
   S2QUAD         s2xds_BadData;
   S2QUAD         s2xds_Overruns;
   S2QUAD         s2xds_UnknownTypesReceived;
   S2QUAD         s2xds_Reconfigurations;
   struct timeval s2xds_LastStart;
 
   struct timeval s2xds_LastConnected;
   struct timeval s2xds_LastDisconnected;
   struct timeval s2xds_TimeConnected;
};

Before I proceed to explain what purposes the individual members serve, a few words on the S2QUAD type, which is defined as follows: typedef struct { ULONG s2q_High; ULONG s2q_Low; } S2QUAD;

In other words, the S2QUAD type stands for an unsigned 64 bit big endian integer, as expressed in ISO 'C' terms.

The structure members have the following purposes:

s2xds_Length

This is the size of the data structure to be filled in and should be initialized by the caller to sizeof(struct Sana2ExtDeviceStats). Smaller values are permitted, but these must not be smaller than 8 (which covers the s2xds_Length and s2xds_Actual members). A driver which finds an s2xds_Length < 8 must treat this as an error and reject the command with ios2_Req.io_Error=IOERR_BADLENGTH.

s2xds_Actual

The size of the data structure filled with information. This member is initialized by the driver and must be <= s2xds_Length.

s2xds_PacketsReceived

Number of packets that this unit has received. This is a 64 bit integer.

s2xds_PacketsSent

Number of packets that this unit has sent. This is a 64 bit integer.

s2xds_BadData

Number of bad packets received (i.e., hardware CRC failed). This is a 64 bit integer.

s2xds_Overruns

Number of packets dropped due to insufficient resources available in the network interface. This is a 64 bit integer.

s2xds_UnknownTypesReceived

Number of packets received that had no pending read command with the appropriate packet type. This is a 64 bit integer.

s2xds_Reconfigurations

Number of network reconfigurations since this unit was last configured. This is a 64 bit integer.

s2xds_LastStart

The time when this unit last went on-line.

s2xds_LastConnected

The time when this unit last established a connection. For dial-up connections, this should be the time when the underlying serial line started to accumulate costs. s2xds_LastConnected must be set to zero if the unit never managed to make a connection.

s2xds_LastDisconnected

The time when this unit last shut down a connection. For dial-up connections, this should be the time when the underlying serial line stopped accumulating costs, e.g. when the modem's carrier signal was lost. s2xds_LastDisconnected must be set to zero if the unit never disconnected.

s2xds_TimeConnected

The time this unit has been connected. For dial-up connections this should be the time between now and when the underlying serial line started accumulating costs.

If this unit is not currently connected, then s2xds_TimeConnected must be set to zero. This means in particular that when the connection is lost, s2xds_TimeConnected must be immediately set to zero and s2xds_LastDisconnected must be filled in so that client software can query how long the unit was connected by subtracting s2xds_LastConnected from s2xds_LastDisconnected.

If this unit is currently connected, s2xds_TimeConnected must never be zero; if necessary, set s2xds_TimeConnected.tv_secs=0 and s2xds_TimeConnected.tv_micros=1.

If s2xds_TimeConnected is zero, check s2xds_LastConnected and s2xds_LastDisconnected; if the latter two are not zero, you can calculate the previous connection time by subtracting s2xds_LastConnected from s2xds_LastDisconnected.

The layout and semantics used by the Sana2ExtDeviceStats data structure suggest that there is a difference between the underlying networking media (the link layer) and the state of the protocol that is running on top of it. With drivers for networking hardware such as Ethernet there was no difference between these two, but for protocols like SLIP, PPP or PPPoE there is a difference. The difference is in that a session or connection may exist for a certain time whereas the protocol running inside that session may be switched 'online' later. The primary purpose of the s2xds_LastConnected, s2xds_LastDisconnected and s2xds_TimeConnected fields is to allow for cost accounting and traffic monitoring (so that, for example, a driver may be disconnected after it has been idle for a while) to be written.

I propose a command with the following semantics:

   NAME
        S2_GETEXTENDEDGLOBALSTATS -- Get interface accumulated statistics;
           updated version.

   FUNCTION
        This command causes the device driver to retrieve various global
        runtime statistics for this network interface. The format of the data
        returned is as follows:

           struct Sana2ExtDeviceStats
           {
              ULONG s2xds_Length;
              ULONG s2xds_Actual;

              S2QUAD s2xds_PacketsReceived;
              S2QUAD s2xds_PacketsSent;
              S2QUAD s2xds_BadData;
              S2QUAD s2xds_Overruns;
              S2QUAD s2xds_UnknownTypesReceived;
              S2QUAD s2xds_Reconfigurations;
              struct timeval s2xds_LastStart;

              struct timeval s2xds_LastConnected;
              struct timeval s2xds_LastDisconnected;
              struct timeval s2xds_TimeConnected;
           };

   IO REQUEST
        ios2_Command          - S2_GETEXTENDEDGLOBALSTATS
        ios2_StatData         - Pointer to Sana2ExtDeviceStats structure
                                to fill in
        ios2_BufferManagement - Magic cookie as returned when opening the
                                driver with a struct IOSana2Req

   RESULTS
        ios2_Req.io_Error - Zero if successful; non-zero otherwise
        ios2_WireError    - More specific error number

I propose that the following command number should be assigned: #define S2_GETEXTENDEDGLOBALSTATS 0xC004

S2_CONNECT

The driver model specified by the SANA-II standard really only covers networking hardware well. Software-only drivers, such as for dial-up networking, are, well, somehow mentioned in the standard, but they don't receive much attention. In particular, this means that a networking driver is assumed to be practically always attached to its link layer and no provisions exist to specify what kind of link layer that might be and how it might be accessed. This small oversight can probably be explained by the fact that at the time the SANA-II standard was adopted, dial-up networking had not yet gained the prominence it has today.

To bridge this gap, I propose a new command which will make a driver connect to its link layer and go online, which uses the following data structure:

struct Sana2Connection
{
   ULONG          s2c_Size;
   struct MinList s2c_Options;
   struct Hook    s2c_ErrorHook;
   struct Hook    s2c_ConnectHook;
   struct Hook    s2c_DisconnectHook;
   STRPTR         s2c_Login;
   STRPTR         s2c_Password;
};

The individual structure members have the following purposes:

s2c_Size

The size of the entire data structure is stored here. This value must be >= 84. Smaller values must be rejected with ios2_Req.io_Error=IOERR_BADLENGTH. The purpose of s2c_Size is to allow for future expansion during which the structure may grow in size.

s2c_Options

This list contains options, to be used during the connection process. Each node has the following format:

struct Sana2ConnectionOption
{
   struct MinNode s2co_MinNode;
   STRPTR         s2co_Name;
   STRPTR         s2co_Value;
};

The s2co_Name and s2co_Value entries point to NUL-terminated strings, which contain the name and the value of a parameter. Note that for numeric values, the respective number will be encoded in a text string. A number of parameters are reserved, which are listed later in this text.

s2c_ErrorHook

This hook is called whenever an error message is to be reported during the connection/disconnection process. The hook function is invoked using the following parameters:

error_hook_func(hook,reserved,message);

VOID error_hook_func(struct Hook *hook,APTR reserved,
                     STRPTR message);

The reserved parameter must be NULL. The message parameter points to a NUL-terminated string. It must not be NULL.

Because the hook function may have to allocate memory, it must not be called from interrupt code.

s2c_ConnectHook

This hook is called when the link level device has been set up, but further initializations are necessary, such as telling a modem to dial out. The hook function is invoked with the following parameters:

success = connect_hook_func(hook,reserved,s2cm);

BOOL connect_hook_func(struct Hook *hook,APTR reserved,
                       struct Sana2ConnectionMessage *s2cm);

The reserved parameter must be NULL. The s2cm parameter points to a data structure, as follows:

struct Sana2ConnectionMessage
{
   ULONG                    s2cm_Size;
   struct Sana2Connection * s2cm_Connection;
   struct IORequest *       s2cm_Request[2];
   LONG                     s2cm_RequestType;
};

In this structure, the members have the following purposes:

s2cm_Size

The size of this data structure; it must be at least 20 bytes in size. The purpose of s2cm_Size is to allow for future expansion, which may cause the size of this structure to grow.

s2cm_Connection

This points back to the Sana2Connection structure which the hook that was invoked with the Sana2ConnectionMessage is embedded in.

s2cm_Request

Here you will find two I/O requests which can be used for reading and writing data to the link layer. These pointers must not be NULL and they must refer to different I/O requests, it is not permitted to pass the same request twice.

The dialer can use these requests for communicating with the modem, but it is also permitted to clone these requests by creating new I/O requests of the same size, copying the original contents and filling in different reply ports.

There is a danger in that the hook code may not receive the right kind of I/O request, which is why the s2cm_RequestType field identifies the kind of device the requests were created for.

When the hook function returns, it must make sure that none of the I/O requests are still pending, i.e. asynchronous I/O must have been stopped.

s2cm_RequestType

This identifies the type of device the I/O requests passed in s2cm_Request were created for. Possible values for this entry come from the New Style Device specification, e.g. NSDEVTYPE_SERIAL for a serial.device-like device or NSDEVTYPE_SANA2 for a networking driver.

The hook function must return TRUE if the connection could be established, and FALSE otherwise. Note that it is not sufficient to just return FALSE in case of failure. Your code must have called the s2c_ErrorHook with an explanation why things went wrong first.

s2c_DisconnectHook

This hook is called by S2_CONNECT when the connection could not be established (the s2c_ConnectHook returned FALSE), or by S2_DISCONNECT, shortly before the link level device is to be closed. The hook function is invoked with the following parameters:

disconnect_hook_func(hook,reserved,s2cm);

VOID disconnect_hook_func(struct Hook *hook,APTR reserved,
                          struct Sana2ConnectionMessage *s2cm);

The reserved parameter must be NULL. The s2cm parameter points to a data structure, as was described for the s2c_ConnectHook.

s2c_Login

s2c_Password

The purpose of these entries is to transport the authentication information the protocol may require. These entries are either NULL or contain pointers to NUL-terminated strings. If s2c_Login is NULL, then both login and password must be assumed to be empty. If s2c_Login is not NULL and s2c_Password is NULL, then the password must be assumed to be empty.

The list of options in s2c_Options supplies the necessary information on how the driver is to connect to the link layer. Each node contains an option, which bears a name and contains a value. This pair is what I call a parameter. A number of parameter names are reserved, as will be listed below:

ppp.async.device

Name of device driver to use for asynchronous PPP.

Example: serial.device

ppp.async.unit

Device unit number to use for asynchronous PPP.

Example: 0

ppp.async.speed

Transmission speed to use for asynchronous PPP in bits per second.

Example: 115200

ppp.async.buffersize

Receive buffer size for asynchronous PPP.

Example: 50000

ppp.async.checkcarrier

Whether the carrier signal of the link layer should be tested or not. This can be either 0 (do not test) or 1 (test the carrier signal).

Example: 1

ppp.async.rtscts

Whether or not hardware handshaking should be used by the link layer. This can be either 0 (off) or 1 (on).

Example: 1

ppp.async.shared

Whether or not the link layer device should be opened in shared mode. This can be either 0 (off) or 1 (on).

Example: 0

ppp.async.nullmodem

Whether or not the link layer is a direct connection, such as a nullmodem. This can be either 0 (off) or 1 (on).

Example: 0

ppp.async.eof

Whether or not the underlying serial device driver's 'EOF mode' should be enabled. This can be either 0 (off) or 1 (on).

Example: 0

ppp.async.readrequests

Number of read requests to be used for asynchronous PPP.

Example: 16

ppp.async.writerequests

Number of write requests to be used for asynchronous PPP.

Example: 16

ppp.async.accm

Asynchronous control character map, expressed as a hexadecimal value.

Example: $000A0000

ppp.async.pfc

Whether or not protocol field compression should be used. This can be either 0 (off) or 1 (on).

Example: 1

ppp.async.aacfc

Whether or not address and control field compression should be used. This can be either 0 (off) or 1 (on).

Example: 1

ppp.async.vjhc

Whether or not Van Jacobson header compression should be used. This can be either 0 (off) or 1 (on).

Example: 1

ppp.async.ignorefcs

Whether or not frame check sequences should be ignored upon reception. This can be either 0 (off) or 1 (on).

Example: 0

ppp.async.initialize

The modem initialization command, with embedded control sequences, if possible.

Example: AT\r

ppp.async.dial

The modem dial command, with embedded control sequences, if possible.

Example: ATD12345\r

ppp.async.dialtimeout

The dial timeout, i.e. the number of seconds to wait after the dial command has been sent for the modem to establish a connection.

Example: 60

ppp.async.hangup

The modem hangup command, with embedded control sequences, if possible.

Example: ATH0\r

ppp.idletimeout

Number of seconds the local host may remain idle, i.e. send no data to the peer, before a watchdog timeout elapses and proceeds to verify that the line is still operational.

Example: 30

ppp.localaddress

The IP address to assign to the local host, as part of the PPP negotiation process. This must be given in dotted decimal notation (RFC1700).

Example: 1.2.3.4

ppp.remoteaddress

The IP address to assume for the peer, as part of the PPP negotiation process. This must be given in dotted decimal notation (RFC1700).

Example: 1.2.3.4

ppp.dns1address

The IP address to be used by the primary domain name server, as part of the PPP negotiation process. This must be given in dotted decimal notation (RFC1700).

Example: 1.2.3.4

ppp.dns2address

The IP address to be used by the secondary domain name server, as part of the PPP negotiation process. This must be given in dotted decimal notation (RFC1700).

Example: 1.2.3.4

ppp.maxfail

The maximum number of negative configuration acknowledgements to be sent before the PPP negotiation process switches to reject those options.

Example: 5

ppp.maxterm

The maximum number of termination requests to be sent before the respective PPP network or link protocol gives up.

Example: 2

ppp.maxconfig

The maximum number of configuration requests to be sent before the respective PPP network or link protocol gives up.

Example: 10

ppp.timeout

The number of seconds that have to pass before the respective PPP network or link protocol will retry to do whatever didn't work during the last attempt.

Example: 3

ppp.mtu

The maximum transmission unit to use.

Example: 1500

ppp.peeridletimeout

Number of seconds the peer may remain idle, i.e. send no data to the local host, before a watchdog timeout elapses and proceeds to verify that the line is still operational.

Example: 30

ppp.rejectpap

Whether or not the Password Authentication Protocol should be accepted, if offered by the peer. This can be either 0 (accept) or 1 (reject).

Example: 0

ppp.sendid

A flag which controls whether the local host should send LCP identification packets or not. This can be either 0 (off) or 1 (on).

Example: 0

ppp.pap.timeout

The Password Authentication Protocol requires that the server answers to the client's request to log in. The server may be unable to respond immediately, which means that the client will have to repeat its request. A short delay should separate each request sent, such as three seconds.

Example: 3

ppp.pap.retry

If the client does not manage to authenticate with the server immediately, it may resend the authentication request several times. But the attempts have to stop eventually, such as after having resent the message ten times.

Example: 10

ppp.dummyremoteaddress

Whether or not the PPP driver should make up an IP address if the peer refuses to state its own IP address.

Example: 1

logfile

The name of a log file to create. If the file already exists, then new data should be appended to it.

Example: t:logfile

logoptions

A list of options which control what exactly should be logged.

ppp.ethernet.device

Name of device driver to use for PPPoE (PPP over Ethernet).

Example: a2065.device

ppp.ethernet.unit

Device unit number to use for PPPoE.

Example: 0

ppp.ethernet.raw

Whether or not raw link layer frames should be constructed for transmission or not. This can be either 0 (off) or 1 (on).

Example: 1

ppp.ethernet.bypass

Whether or not the IP packet transmission and reception should bypass several copying steps. This can be either 0 (off) or 1 (on).

Example: 1

ppp.ethernet.readpackets

The number of read requests to queue for the link layer.

Example: 16

ppp.ethernet.writepackets

The number of write requests to queue for the link layer.

Example: 16

ppp.ethernet.service

The name of the PPPoE service to request.

Example: ?

ppp.ethernet.ac

The name of the PPPoE access concentrator to request.

Example: ?

ppp.ethernet.connecttimeout

The number of seconds to wait for the PPPoE server to allow a session to be opened.

Example: 3

While this list of parameters may suggest that the command described above can be used solely with the PPP protocol, do not let that put you off. This list is merely the starting point, but it is not set in stone that it cannot be extended.

The names of the parameters are not case sensitive. As the names suggest, the name space itself is hierarchic in construction, i.e. everything related to the PPP protocol bears a name starting with the letters 'ppp' with the dot '.' separating the individual items. By this rule, ppp.async refers to options that concern asynchronous PPP and ppp.ethernet to options that concern PPP over Ethernet wire.

To add your own parameter, register it with the maintainer of the SANA-II standard or prefix its name with the letters 'x-'. For example, to use your own kind of 'ppp.ethernet.connecttimeout' parameter, change the name of the last component like this: ppp.ethernet.x-connecttimeout. No officially-registered parameter will ever begin with the prefix 'x-'.

The command should work as follows:

  1. The client must set up the Sana2Connection data structure, initialize the s2c_Size, s2c_Options, s2c_ErrorHook, s2c_ConnectHook, s2c_DisconnectHook, s2c_Login and s2c_Password fields.
  2. The connection options must be filled in, which means that nodes containing the respective information must be stored in the s2c_Options list. The client must make sure that the syntax of the parameters conforms to the specifications described above.
  3. A pointer to the Sana2Connection data structure is placed in the ios2_Data member of an IOSana2Req, the command is set to S2_CONNECT and the request is sent via DoIO() or SendIO().
  4. The driver receives the request and begins to examine the contents of the s2c_Options list, as provided in the data structure pointed to by the ios2_Data member of the request. Unknown options are ignored, options whose values do not conform to the syntax specification are rejected; this is done by calling the s2c_ErrorHook with an error message referring to the option in question and by returning the IOSana2Req with an error code of S2ERR_BAD_ARGUMENT and wire error code of S2WERR_INVALID_OPTION.
  5. If the options are all in good order, the driver proceeds to verify that all mandatory options are provided. If this is not the case, the s2c_ErrorHook is called with an error message referring to the option in question and the IOSana2Req is returned with an error code of S2ERR_BAD_ARGUMENT and wire error code of S2WERR_MISSING_OPTION.
  6. The driver proceeds to do its local initialization, which involves opening the link layer device, etc. If this initialization fails, the s2c_ErrorHook is called with an error message referring to the problem and the IOSana2Req is returned with an appropriate error code.
  7. When the initialization has finished, the driver may invoke the s2c_ConnectHook callback. Some drivers may require this, such as asynchronous PPP, some may not, such as PPPoE. The purpose of the hook function is to give the client a chance to perform modem initializations and connect to the peer. If the s2c_ConnectHook cannot perform its duties, it has to invoke the s2c_ErrorHook with an error message and eventually return FALSE. If FALSE is returned, the driver must invoke the s2c_DisconnectHook, reverse any initializations it had made and eventually returned the IOSana2Req with an appropriate error code. If the s2c_ConnectHook returned TRUE, then the driver must proceed with the actions that require that the link layer is operational. A protocol negotiation may follow, which, if successful, will make the driver return the IOSana2Req with an error code of zero, indicating success. If successful, the SANA-II events S2EVENT_CONNECT and S2EVENT_ONLINE must be sent.
  8. The command will eventually return, but the client must not release the memory allocated for the Sana2Connection structure and the option nodes in the s2c_Options list. This is because the driver may have to invoke the s2c_DisconnectHook hook due to the connection shutting down on its own accord.

The connect and disconnect hook functions must not be called from interrupt code. For each hook only a Task calling context of unknown priority must be assumed. Also, stack space is provided only to call exec.library and utility.library functions. The callback shall not place excessive data on the stack. Stack space should be considered limited.

I propose a command with the following semantics:

   NAME
        S2_CONNECT -- Establish a link layer connection and go
            online.

   FUNCTION
        This command is for use by networking devices which require
        a special link layer device to transmit their data, such as
        an asynchronous serial line and need to know about the
        configuration parameters necessary to open the connection.

   IO REQUEST
        ios2_Command          - S2_CONNECT
        ios2_Data             - Pointer to Sana2Connection structure
        ios2_BufferManagement - Magic cookie as returned when opening the
                                driver with a struct IOSana2Req

   RESULTS
        ios2_Req.io_Error - Zero if successful; non-zero otherwise
        ios2_WireError    - More specific error number

   NOTES
        If successful, this command implies S2_ONLINE, i.e. the
        link layer is allocated and used by the driver.

        The contents of the Sana2Connection structure must be valid
        until the connection is eventually shut down. The driver will
        need to cache it, so it must not be deallocated or otherwise
        modified.

        Note that S2_ONLINE does not necessarily imply S2_CONNECT, if
        the S2_CONNECT command is listed as supported by the driver via
        NSCMD_DEVICEQUERY. If S2_CONNECT is not listed as supported,
        S2_ONLINE obviously implies connect functionality.

        S2_CONNECT/S2_DISCONNECT do not nest.

   SEE ALSO
        S2_DISCONNECT

I propose that the following command number should be assigned:

#define S2_CONNECT 0xC005

S2_DISCONNECT

This command complements S2_CONNECT in that it tears down a connection. It uses the same Sana2Connection structure and hooks, but most of these members are ignored.

The command should work as follows:

  1. The client must set up the Sana2Connection data structure, initialize the s2c_Size, s2c_Options, s2c_ErrorHook, s2c_ConnectHook, s2c_DisconnectHook, s2c_Login and s2c_Password fields. The s2c_Options, s2c_ConnectHook, s2c_Login and s2c_Password fields will be ignored, but the client should play things safe.
  2. A pointer to the Sana2Connection data structure is placed in the ios2_Data member of an IOSana2Req, the command is set to S2_DISCONNECT and the request is sent via DoIO() or SendIO().
  3. The driver receives the request and proceeds to reverse the steps that previously allowed it to establish a connection. This includes telling the peer to shut down the link, but it does not include cleaning up the link layer device access, i.e. no I/O requests used for accessing a modem may be shut down yet.
  4. The s2c_DisconnectHook may be invoked with the proper parameters. Some drivers, such as for asynchronous PPP, will need the hook to tell the modem to hang up the line. Some drivers, such as for PPPoE, may not need this hook and thus ignore it.
  5. The initialization is reversed completely, all resources allocated when the connection was previously opened are released. The IOSana2Req is returned with an error code of zero, indicating success. The SANA-II event S2EVENT_DISCONNECT must be sent, and, if necessary, S2EVENT_OFFLINE.

The connect and disconnect hook functions must not be called from interrupt code. For each hook only a Task calling context of unknown priority must be assumed. Also, stack space is provided only to call exec.library and utility.library functions. The callback shall not place excessive data on the stack. Stack space should be considered limited.

I propose a command with the following semantics:

   NAME
        S2_DISCONNECT -- Go offline and close a link layer connection
            previously established with S2_CONNECT.

   FUNCTION
        This command complements the S2_CONNECT command in that it
        reverses the steps taken to establish a link layer connection.

   IO REQUEST
        ios2_Command          - S2_DISCONNECT
        ios2_Data             - Pointer to Sana2Connection structure
        ios2_BufferManagement - Magic cookie as returned when opening the
                                driver with a struct IOSana2Req

   RESULTS
        ios2_Req.io_Error - Zero if successful; non-zero otherwise
        ios2_WireError    - More specific error number

   NOTES
        If successful, this command implies S2_OFFLINE, i.e. the
        link layer is deallocated.

        The driver must ignore the S2_DISCONNECT command and
        recover gracefully if the S2_CONNECT was never sent or
        returned with an error.

        The contents of the Sana2Connection structure are valid only
        until the device driver has processed the command and returned
        the IOSana2Req. Any data the driver may need to retain beyond
        that point of time must be copied.

        Once the S2_DISCONNECT command has returned, it is safe to dispose
        of the Sana2Connection structure provided at S2_CONNECT time.

        Note that S2_OFFLINE does not necessarily imply S2_DISCONNECT, if
        the S2_DISCONNECT command is listed as supported by the driver via
        NSCMD_DEVICEQUERY. If S2_DISCONNECT is not listed as supported,
        S2_OFFLINE obviously implies disconnect functionality.

        S2_CONNECT/S2_DISCONNECT do not nest.

   SEE ALSO
        S2_CONNECT

I propose that the following command number should be assigned:

#define S2_DISCONNECT 0xC006

S2_SAMPLE_THROUGHPUT

The SANA-II standard already allows for statistics to be returned on the amount of data that has passed through a driver. Unfortunately, that information is not very accurate in that no information is provided on the time span in which the data was accumulated. Such information would be helpful in trying to determine as accurately as possible how large the data throughput actually is. I therefore propose a new command which can be used to obtain that information, which uses the following data structure:

struct Sana2ThroughputStats
{
   ULONG          s2ts_Length;
   ULONG          s2ts_Actual;
 
   struct Task *  s2ts_NotifyTask;
   ULONG          s2ts_NotifyMask;
 
   struct timeval s2ts_StartTime;
   struct timeval s2ts_EndTime;
   S2QUAD         s2ts_BytesSent;
   S2QUAD         s2ts_BytesReceived;
   S2QUAD         s2ts_Updates;
};

Before I proceed to explain what purposes the individual members serve, a few words on the S2QUAD type, which is defined as follows:

typedef struct { ULONG s2q_High; ULONG s2q_Low; } S2QUAD;

In other words, the S2QUAD type stands for an unsigned 64 bit big endian integer, as expressed in ISO 'C' terms.

The structure members have the following purposes:

s2ts_Length

This is the size of the data structure to be filled in and should be initialized by the caller to sizeof(struct Sana2ThroughputStats). Smaller values are permitted, but these must not be smaller than 8 (which covers the s2ts_Length and s2ts_Actual members). A driver which finds an s2ts_Length < 8 must treat this as an error and reject the command with ios2_Req.io_Error=IOERR_BADLENGTH.

s2ts_Actual

The size of the data structure filled with information. This member is initialized by the driver and must be <= s2ts_Length.

s2ts_NotifyTask

The Task to notify whenever the contents of this data structure change. This must be NULL if no notification is desired.

Note: This feature should be used carefully, as so much data may arrive that the driver will almost be constantly signalling this Task that a change has taken place.

It is recommend that periodic polling be used, such as to update displays of a link monitoring program.

s2ts_NotifyMask

The signal mask to use for notifying the Task whose address is found in s2ts_NotifyTask (via Signal(s2ts->s2ts_NotifyTask,s2ts->s2ts_NotifyMask);). This must be zero if no notification is desired.

s2ts_StartTime

The time when the driver started to fill in this data structure.

s2ts_EndTime

The time when the driver last updated the contents of this data structure.

s2ts_BytesSent

Total number of bytes sent since the driver started to fill in this data structure. This is a 64 bit integer.

s2ts_BytesReceived

Total number of bytes received since the driver started to fill in this data structure. This is a 64 bit integer.

s2ts_Updates

Number of times the driver has updated this data structure. This value will increase with every change. This is a 64 bit integer.

A driver implementing this command should take care to update the members s2ts_EndTime, s2ts_BytesSent, s2ts_BytesReceived and s2ts_Updates atomically each time changes are made.

I propose a command with the following semantics:

   NAME
        S2_SAMPLE_THROUGHPUT -- Obtain accurate information on
           driver data throughput.

   FUNCTION
        This command installs a data structure which is updated every time
        data is sent or received by the driver.

        This command must be sent via SendIO() or BeginIO(); until
        the associated I/O request is recalled using AbortIO(), the
        device unit will continue to update the Sana2ThroughputStats
        structure in real time.

   IO REQUEST
        ios2_Command          - S2_SAMPLE_THROUGHPUT
        ios2_StatData         - Pointer to Sana2ThroughputStats structure
                                to fill in
        ios2_BufferManagement - Magic cookie as returned when opening the
                                driver with a struct IOSana2Req

   RESULTS
        ios2_Req.io_Error - Zero if successful; non-zero otherwise

   NOTES
        If this device driver does not understand this command,
        it will immediately return the IOSana2Req with
        ios2_Req.io_Error set to IOERR_NOCMD. Otherwise, the request will
        remain queued until it is removed with AbortIO() later.

I propose that the following command number should be assigned:

#define S2_SAMPLE_THROUGHPUT 0xC007

Annotations for existing commands

S2_ONLINE and S2_OFFLINE

This proposal introduces two new commands (S2_CONNECT and S2_DISCONNECT) which are somewhat related to the S2_ONLINE and S2_OFFLINE commands. How this relation works out shall be explained below. Note that the following text assumes that both the S2_CONNECT/S2_DISCONNECT and S2_ONLINE/S2_OFFLINE command pairs are implemented.

S2_CONNECT implies S2_ONLINE and, if successful, may report S2EVENT_ONLINE and S2EVENT_CONNECT events. If the unit is currently disconnected, but still online, only the S2EVENT_CONNECT event shall be sent. Invoking the S2_CONNECT command on a driver which is already connected must be rejected with ios2_Req.io_Error=S2ERR_BAD_STATE and ios2_WireError=S2WERR_UNIT_CONNECTED.

S2_DISCONNECT implies S2_OFFLINE and, if successful, may report S2EVENT_OFFLINE and S2EVENT_DISCONNECT events. If the unit is curently connected and offline, then only the S2EVENT_DISCONNECT event shall be sent. Invoking the S2_DISCONNECT command on a driver which is already disconnected must be rejected with ios2_Req.io_Error=S2ERR_BAD_STATE and ios2_WireError=S2WERR_UNIT_DISCONNECTED.

S2_OFFLINE may be used after the S2_CONNECT has successfully connected the unit. In this case the driver will release control over the link layer and report the S2EVENT_OFFLINE event. The connection established using the S2_CONNECT will, however, persist.

S2_ONLINE may be used after S2_CONNECT has successfully connected the unit and the S2_OFFLINE was used. In this case the driver will again try to obtain control over the link layer and report the S2EVENT_ONLINE event if successful.

If the S2_CONNECT command was never successfully executed, then the commands S2_ONLINE and S2_OFFLINE must be rejected with ios2_Req.io_Error=S2ERR_BAD_STATE and ios2_WireError=S2WERR_UNIT_DISCONNECTED.

Extensions for existing commands

S2_DEVICEQUERY

The Sana2DeviceQuery structure filled in by the S2_DEVICEQUERY command provides for information on the device's properties, including the maximum transmission unit (MTU) that may be used. What is not specifically covered is the 'raw' MTU a device may offer. In this context 'raw' means the number of bytes that are available for reading and writing when using the SANA2IOB_RAW flag with a CMD_READ/CMD_WRITE request on a device that supports these access methods. Currently, software developers can only make assumptions on how many bytes might comprise the 'raw' MTU by checking the Sana2DeviceQuery.HardwareType member and hoping that the driver supports raw CMD_READ/CMD_WRITE access.

I propose that the S2_DEVICEQUERY command and the associated Sana2DeviceQuery structure are extended to allow for the raw MTU to be queried. The new Sana2DeviceQuery structure would look like this:

struct Sana2DeviceQuery
{
    /*
    ** Standard information
    */
    ULONG SizeAvailable;    /* bytes available */
    ULONG SizeSupplied;     /* bytes supplied */
    LONG  DevQueryFormat;   /* this is type 0 */
    LONG  DeviceLevel;      /* this document is level 0 */
 
    /*
    ** Common information
    */
    UWORD AddrFieldSize;    /* address size in bits */
    ULONG MTU;              /* maximum packet data size */
    LONG  bps;              /* line rate (bits/sec) */
    LONG  HardwareType;     /* what the wire is */
    ULONG RawMTU;           /* maximum raw packet data size */
 
    /*
    ** Format specific information
    */
};

The RawMTU member is new. Devices which do not know and support this structure member may fill in the Sana2DeviceQuery structure only up to and including the HardwareType member.

Devices which know and support the RawMTU member must fill it with a well-defined value. For Amiga Ethernet drivers, that value would be 1514, which is the standard MTU value of 1500 bytes plus the size of the Ethernet frame header, as per RFC894 (six bytes for the destination address, six bytes for the source address and two bytes for the frame type; the eight byte preamble and the terminating four byte CRC value are typically not under the control of the driver). Drivers which do not support raw read or write access must set the RawMTU member to zero.

If the RawMTU member is not provided, all bets are off and the application software must fall back to making estimates based upon the hardware type and the raw frame types it wishes to read and write. Ultimatively, the driver itself must decide whether it can accept raw read and write commands (or has to reject them with S2ERR_NOT_SUPPORTED) and whether the raw packet size is still covered by the underlying hardware MTU (or must be rejected with S2ERR_MTU_EXCEEDED).

A word of warning: a little testing with various Ethernet hardware drivers has revealed that the A2065 driver a2065.device does not handle the S2_DEVICEQUERY command properly if the Sana2DeviceQuery structure provided is larger than 30 bytes. In other words, the command will fail if the proposed RawMTU member is present in the query data structure to be filled in.

New events

S2EVENT_CONFIGCHANGED

The SANA-II standard does not cover protocols or devices which can change their properties during operation, such as the hardware address of the underlying driver. For drivers such as those which implement the proposed S2_GETPEERADDRESS and S2_GETDNSADDRESS commands it is vital that such changes can take place and be noticed by the client software. For this purpose I propose that a new event type is introduced, to be used with the SANA-II S2_ONEVENT command, using the following definition:

#define S2EVENT_CONFIGCHANGED (1L<<8)

This event should be triggered whenever client-visible configuration information changes, as can be queried via the S2_DEVICEQUERY, S2_GETSTATIONADDRESS, S2_GETSPECIALSTATS, S2_GETGLOBALSTATS, S2_GETPEERADDRESS and S2_GETDNSADDRESS commands. Here is a short list of what could change:

S2_DEVICEQUERY

AddrFieldSize, MTU, BPS

S2_GETSTATIONADDRESS

ios2_SrcAddr

S2_GETGLOBALSTATS

Reconfigurations, LastStart

S2_GETPEERADDRESS

ios2_SrcAddr, ios2_DstAddr

S2_GETDNSADDRESS

ios2_SrcAddr, ios2_DstAddr

The purpose of this event is not to post a notification whenever another byte or event counter has changed so that a monitoring program may update its display. The purpose is to convey to the client software that an important device configuration option has changed and that it is supposed to react and adapt to it. For example, a TCP/IP stack may, upon learning that a device's IP address has changed, rebuild its routing table.

Since the S2EVENT_CONFIGCHANGED event may arrive at any time and does not indicate what exactly has changed, application software should query the information it expects to change during its life time, and keep a copy of it around for later reference. When the S2EVENT_CONFIGCHANGED event arrives, it can compare the contents of the copy against the current state of affairs and act according to the differences it finds.

S2EVENT_CONNECT

This event is a counterpart to S2EVENT_ONLINE, and is associated with the S2_CONNECT command. I propose the following semantics:

#define S2EVENT_CONNECT (1L<<9) /* Driver has opened session */

The event is to be sent when the driver has successfully established a link layer connection.

S2EVENT_DISCONNECT

This event is a counterpart to S2EVENT_OFFLINE, and is associated with the S2_DISCONNECT command. I propose the following semantics:

#define S2EVENT_DISCONNECT (1L<<10) /* Driver has closed session */

The event is to be sent when the driver has closed the link layer connection previously established by the S2_CONNECT command.

New wire error codes

S2WERR_UNIT_DISCONNECTED

This error code is a counterpart to S2WERR_UNIT_OFFLINE. It indicates that the associated command could not be executed because the link layer is not connected.

I propose the following semantics:

#define S2WERR_UNIT_DISCONNECTED 19 /* unit is currently not connected */

S2WERR_UNIT_CONNECTED

This error code is a counterpart to S2WERR_UNIT_ONLINE. It indicates that the associated command could not be executed because the link layer is already connected.

I propose the following semantics:

#define S2WERR_UNIT_CONNECTED 20 /* unit is currently connected */

S2WERR_INVALID_OPTION

This error code indicates that an option, such as passed by the S2_CONNECT command, is not acceptable. The option's value may be out of range or may not match the syntax specifications. To indicate which option that may be, a different mechanism must be used; a simple indication that something was wrong is not sufficient.

I propose the following semantics:

#define S2WERR_INVALID_OPTION 21 /* invalid option rejected */

S2WERR_MISSING_OPTION

This error code indicates that a mandatory option, such as passed by the S2_CONNECT command, is not present. To indicate which option that may be, a different mechanism must be used; a simple indication that something was wrong is not sufficient.

I propose the following semantics:

#define S2WERR_MISSING_OPTION 22 /* a mandatory option is missing */

S2WERR_AUTHENTICATION_FAILED

Some drivers run protocols that require them to authenticate to a server. That process may fail. This wire error code is to indicate this fact.

I propose the following semantics:

#define S2WERR_AUTHENTICATION_FAILED 23 /* could not log in */

Callbacks

S2_DMACopyToBuff64 and S2_DMACopyFromBuff64

These two callbacks are identical in operation to the S2_DMACopyToBuff32 and S2_DMACopyFromBuff32 callbacks, as specified in the SANA-IIR3 standard. The difference is in that the memory region DMA is to take place in must be aligned to a 64 bit boundary and must be large enough to hold data that is a multiple of 64 bits in size. The purpose of these hooks is to allow for 64 bit aligned PCI DMA accesses to take place.

I propose that the following numbers should be assigned:

#define S2_DMACopyToBuff64 (S2_Dummy + 10)

  1. define S2_DMACopyFromBuff64 (S2_Dummy + 11)

S2_Log

A driver may want to report an important event for the user to see. Adding a log message to a file or opening a window to display a message in may not be the optimum approach as the user may be unaware of the context into which the message belongs. It may be advisable for the driver to use the message reporting and logging facilities used by the client software that uses its services, such as a TCP/IP stack. The S2_Log callback hook is intended to provide for such a link. If present, the driver must use this callback hook rather than whatever logging methods it implements itself. Note that unlike the other SANA-II callbacks, this is a regular hook, as to be invoked using utility.library/CallHookPkt(). The hook function is invoked using the following parameters:

log_hook_function(hook,reserved,message)

void log_hook_function(struct hook * hook,APTR reserved,
                       struct S2LogMessage * message);

The reserved parameter must be set to NULL. The S2LogMessage structure passed as the third parameter looks like this:

struct S2LogMessage
{
   LONG   s2lm_Size;
   ULONG  s2lm_Priority;
   STRPTR s2lm_Name;
   STRPTR s2lm_Message;
};

The individual structure members serve the following functions:

s2lm_Size

Size of the S2LogMessage structure, in bytes. The idea is to extend this data structure in the future, and the size stored in here tells you how long the structure is. The size must always be >= 16.

s2lm_Priority

The smaller this value, the more important the message to be logged or displayed. The following priority levels are defined (similar to the Unix syslog() mechanism):

#define S2LOG_Emergency 0

A panic condition.

#define S2LOG_Alert 1

A condition that should be corrected immediately.

#define S2LOG_Critical 2

Critical conditions.

#define S2LOG_Error 3

A plain error.

#define S2LOG_Warning 4

A warning message.

#define S2LOG_Notice 5

Conditions that are not error conditions, but should possibly be handled specially.

#define S2LOG_Information 6

An informational message.

#define S2LOG_Debug 7

Messages that contain information normally of use only when debugging.

s2lm_Name

Pointer to a NUL-terminated string which identifies the source of this message. This can be NULL in which case the name is treated as being unknown.

s2lm_Message

Pointer to a NUL-terminated string which contains the log message. The text should not contain any formatting characters such as line feeds or carriage returns. The s2lm_Message member must never be NULL.

All error messages issued by the device driver should use the current system locale wherever this is possible. The purpose of an error message is, after all, to assist the user in recovering from the error. Which may be difficult if the user does not even know the language in which the message is written.

The log message string is valid until the log hook function returns. If the driver needs to retain the message any longer, it must make a copy of it.

Since the client software into which the log hook calls may have to allocate memory to hold and display the log message, the log hook must not be called from interrupt code. The log hook shall not Wait() and it shall assume only a Task calling context of unknown priority. dos.library functions may not be called. Also, stack space is provided only to call exec.library and utility.library functions. The callback shall not place excessive data on the stack. Stack space should be considered limited and the callback should be designed to be fast and short.

This hook is installed at OpenDevice() time, which means that the hook is used for the unit that was opened, and not just for the I/O request it was opened with. The hook must remain installed until the I/O request that installed it is eventually used to close the device. When this happens, the device should fall back to use no log hook at all. No nesting is permitted or required.

I propose that the following number should be assigned:

#define S2_Log (S2_Dummy + 12)

Proposed driver requirements

This is an attempt to clarify part of the specification and to lay down a few rules that every SANA-II driver should follow in addition to the requirements described in the existing specifications. Here is what I propose:

  • A driver that does not use a broadcast medium, such as Ethernet, must not implement the S2_BROADCAST command. Likewise, if no multicast mechanism is supported, the S2_MULTICAST must not be implemented either.
  • SANA-II standard commands which the driver does not implement must be rejected with the IOERR_NOCMD error code. Commands that are implemented, but which cannot perform the requested services, must be rejected with the S2ERR_NOT_SUPPORTED error code. The difference between the two cases is in when the decision is made whether a command can be handled or not. Which commands should return IOERR_NOCMD is decided upon at the time the driver is designed and implemented. At this stage the implementor knows for sure which capabilities the driver will have and which it will not have. Commands which the driver will never be able to execute will be made to return the IOERR_NOCMD error code. If the decision whether a command can be executed is made only at run time, by evaluating the conditions under which a command can be executed, then the error code S2ERR_NOT_SUPPORTED should be returned in case of failure.
  • It must be possible to open the driver with a plain struct IOStdReq. This is necessary for the NewStyleDevices query command to work. In the command dispatcher, the driver must verify that all SANA-II commands are invoked with a proper size struct IOSana2Req I/O request. If the I/O request is shorter (as can be verified by looking at the embedded Message's mn_Length member), the command must be rejected with ios2_Req.io_Error=IOERR_BADLENGTH.
  • A driver must implement the NewStyleDevices NSCMD_DEVICEQUERY command, in conformance with the NSD specification 1.6 or newer. The motivation for this is to have a mechanism available for probing the capabilities of the driver, and the supported command set can provide for vital clues. In this context, the absence of the S2_BROADCAST command would suggest that the driver cannot send or receive broadcast messages.
  • A driver that does not allow its station address to be set with the S2_CONFIGINTERFACE command may silently ignore the command (returning it without setting an error condition) and even pretend that it can be configured more than once.
  • In response to the S2_DEVICEQUERY, S2_GETSPECIALSTATS and S2_GETGLOBALSTATS commands a driver may return information that is not entirely correct if it has to go online before it can provide for the correct data. For example, the maximum transmission unit for PPP is a number in the range of [1..1500] which is negotiated during the protocol configuration process. It is unlikely that numbers greater than 1500 will be used, yet it is still not impossible. Since the actual number will be known only after the driver has configured the protocol, the MTU value returned before the session was opened can differ from the MTU value valid after it has been opened. A driver should therefore attempt to return 'safe' defaults in place of information that is unavailable at the time it is queried. The 'safe' values shall be set up to allow the driver to work even if the protocol stack is not aware of later changes to those values. Beware of zero-length buffer sizes or time intervals that may cause client software to perform zero-length memory allocations or divisions by zero.
  • SANA-II assigns packet type numbers according to the underlying transport media. For example, Ethernet uses packet type 2048 for IP frames. No such packet type definition exists for PPP yet, which is why I propose to assign packet type 31 for IP packets transmitted via PPP. To simplify client software configuration, drivers may treat packet type 2048 as equivalent to the packet number associated with IP frames. This association is permitted only if it does not introduce ambiguity. For example, this association would not be permitted if the driver would receive and transmit IP packets in two different frame types or if the driver already associates packet type 2048 with non-IP packets.

Unsolved problems

  • Protocols like PPP can provide both for IPv4 and IPv6 addresses that should be used by the local client, the peer or any of the domain name servers. While the two addressing families are interoperable, there is a problem in how the driver should report them. Can you assume 128 bit addresses and encapsulate 32 bit addresses in them? If so, how do you make sure that the address format is unambiguous?
  • Currently, only the device's hardware type provides a clue as to what packet type responds to which protocol transported via the link. For Ethernet, IP packets are encapsulated in type 2048 frames, PPP encapsulates IP packets in type 31 frames, Arcnet can use type 240 or 212. Matching a protocol with a frame type is not an easy process which could be handled more elegantly.
  • How to extend the Sana2DeviceQuery structure in the future? The current layout separates standard, common and format specific information, but there is no hint as to where which each section starts and where the next begins. Now that there is a proposal to add a new field to the common section, how would you add fields to the format specific section?

Changes

Changes since 02-May-2012:

  • Converted to MediaWiki format.

Changes since 24-Dec-2002:

  • The Sana2Connection data structure used by the S2_CONNECT command now must remain valid until the S2_DISCONNECT command is sent (see section 2.4).

Changes since 01-May-2002:

  • Added the ppp.async.readrequests and ppp.async.eof configuration keywords.

Changes since 04-Jan-2002:

  • Added the ppp.dummyremoteaddress and ppp.ethernet.ac configuration keywords.

Changes since 10-Dec-2001:

  • Converted to HTML format.
  • Added the <devices/sana2.h> header file to the appendix.
  • The memory alignment for the S2_DMACopyToBuff64 and S2_DMACopyFromBuff64 hooks refers to bits and not to bytes.

Changes since 19-Nov-2001:

  • Added to the list of reserved configuration keywords (ppp.idletimeout, ppp.peeridletimeout, ppp.sendid).
  • Renamed the fields of the Sana2ExtDeviceStats structure.
  • Clarified that the S2QUAD type is a big endian integer.
  • More clarifications for the S2_CONNECT/S2_DISCONNECT and S2_ONLINE/S2_OFFLINE commands.
  • Updated the discussion of the Sana2DeviceQuery.RawMTU field, clarifying what is included in the the Ethernet RawMTU.
  • Updated the <devices/sana2.h> header file. Note that there is no equivalent "devices/sana2.i" header file yet.

Changes since 12-Nov-2001:

  • Changed the command numbers of S2_GETPEERADDRESS, S2_GETDNSADDRESS, S2_GETEXTENDEDGLOBALSTATS, S2_CONNECT, S2_DISCONNECT and S2_SAMPLE_THROUGHPUT to be NSD-compliant. Also assigned a new number to the S2_SAMPLE_THROUGHPUT command.
  • Added section 4 ("Extensions for existing commands").
  • Added the last paragraph to section 9, relating to the future extension of the Sana2DeviceQuery structure.

Changes since 03-Nov-2001:

  • Renamed S2_GETNEWGLOBALSTATS to S2_GETEXTENDEDGLOBALSTATS (see section 2.3).
  • The S2_GETEXTENDEDGLOBALSTATS now uses 64 bit quantities for the s2xds_PacketsReceived, s2xds_PacketsSent, s2xds_BadData, s2xds_Overruns, s2xds_UnknownTypesReceived and s2xds_Reconfigurations counters.
  • In section 2.6 the S2_SAMPLE_THROUGHPUT command was modified to use 64 bit integers for all members of the Sana2ThroughputStats structure.
  • All proposed commands are now listed with their numeric IDs.
  • The command autodocs specifically mention the ios2_BufferManagement field.
  • All references to ios2_Error have been replaced with ios2_Req.io_Error.
  • In section 7 the use of the IOERR_NOCMD/S2ERR_NOT_SUPPORTED error codes is clarified.
  • Section 7 takes a more detailed look at safe default values returned by the query commands.
  • Inserted section 3 ("Annotations for existing commands").
  • The S2_CONNECT and S2_DISCONNECT commands now specifically mention the life time of the data they have to deal with.

Changes since 14-Oct-2001:

  • Added S2_CONNECT and S2_DISCONNECT commands.
  • Added S2EVENT_CONNECT and S2EVENT_DISCONNECT events.
  • Added section 4 ("New wire error codes").
  • In section 5.2 the originally proposed log callback function has been wrapped into a standard Hook structure.
  • Removed item on S2_CONNECT/S2_DISCONNECT from section 7 ("Unsolved problems").
  • Added section 8 ("Changes").