Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
EnableSelfSendSample.c
/* |
File: EnableSelfSendSample.c |
By: Rich Kubota |
Developer Technical Support |
Purpose: Demonstrate the use of the OTOptionManagement call to tell an AppleTalk |
endpoint to enable/disable the SelfSend option. |
change history: |
9/14/98 rrk Modified check for asynch mode. Return err -1, instead of using |
classic AppleTalk SelfSend call. |
Note that this sample does not support asynch endpoints. To support |
an asynch endpoint, the same call to OTOptionManagement would happen |
however, the endpoint handler will be called with the |
T_OPTMGMTCOMPLETE event. The handler would then inspect the cookie, |
which will be the TOptMgmt "ret" value to check for the |
success or failure of the call. |
1/25/98 rrk Changed the original use of the OTOptionManagement call, OPT_SELFSEND |
which only enables selfsend from the endpoint to other AppleTalk services when |
broadcast messages are sent from the endpoint. The desired behavior is one |
where if other AppleTalk clients on the node send broadcast messages, that they |
are also sent to the endpoint. To this end, there is the ATALK_IOC_FULLSELFSEND |
Ioct, which must be sent to the DDP endpoint. |
Note that the ATALK_IOC_FULLSELFSEND is desired to respond similarly to the |
PSetSelfSend function. If the result is not negative, then the following responses |
can be expected. |
0 - FullSelfSend was previously off |
1 - FullSelfSend was previously on |
Input parameters |
ep - the AppleTalk EndpointRef on which to enable fullSelfSend. You can pass |
any AppleTalk endpoint, DDP or above, to this function. |
enableSelfSend - a long word of the desired setting. |
Return result |
< 0 - error |
0 - FullSelfSend was previously off |
1 - FullSelfSend was previously on |
Note that if the use of the Ioctl returns an error < 0, then the PBSetSelfSend |
function is called. |
Note: As with the PSetSelfSend call, the Ioctl call affects AppleTalk globally. |
If you enable this feature, it is recommended that you not disable the feature |
when the process quits. The user may launch another process which enables |
selfsend. Turning off selfsend in this case, affects the other process, as well. |
*/ |
#include "OpenTransport.h" // open transport files |
#include "OpenTptAppletalk.h" |
extern OSStatus DoNegotiateSelfSendOption(EndpointRef ep, long enableSelfSend); |
/* |
Sample function to enable/disable the SelfSend option for |
an AppleTalk endpoint. |
Input |
EndpointRef ep - endpoint on which to set SelfSend option on |
long enableSelfSend - 1L - option on, 0L - option off |
Return: 0 or 1 - previous state of self send |
-1 - asynch endpoints are not supported |
other negative result - error calling OTIoctl |
*/ |
OSStatus DoNegotiateSelfSendOption(EndpointRef ep, long enableSelfSend) |
{ |
OSStatus result; |
if (OTIsSynchronous(ep) == false) // check whether ep sync or not |
{ |
DebugStr("\pThis routine does not support asynch endpoints"); |
return (OSStatus)-1; |
} |
result = OTIoctl(ep, ATALK_IOC_FULLSELFSEND, (void*)enableSelfSend); |
return result; |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14