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 |
Contains: Demonstrate the use of the OTOptionManagement call to tell an AppleTalk |
endpoint to enable/disable the SelfSend option. |
Written by: Rich Kubota |
Copyright: Copyright © 1999 by Apple Computer, Inc., All Rights Reserved. |
You may incorporate this Apple sample source code into your program(s) without |
restriction. This Apple sample source code has been provided "AS IS" and the |
responsibility for its operation is yours. You are not permitted to redistribute |
this Apple sample source code as "Apple sample source code" after having made |
changes. If you're going to re-distribute the source, we require that you make |
it clear in the source that the code was descended from Apple sample source |
code, but that you've made changes. |
Change History (most recent first): |
7/22/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1 |
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" |
#include "AppleTalk.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: kOTNoError indicates that the option was successfully negotiated |
otherwise the error result is returned |
IMPORTANT NOTE: if you find that this sample fails to enable/disable self send, check |
the file OpenTptAppleTalk.h and ensure that ATALK_IOC_FULLSELFSEND is defined |
as follows |
#define ATALK_IOC_FULLSELFSEND MIOC_CMD(MIOC_ATALK,47) |
there are versions of the header file that incorrectly define |
ATALK_IOC_FULLSELFSEND as follows. |
#define ATALK_IOC_FULLSELFSEND MIOC_CMD(MIOC_ATALK,47) // INCORRECT |
*/ |
OSStatus DoNegotiateSelfSendOption(EndpointRef ep, long enableSelfSend) |
{ |
OSStatus result; |
SetSelfparms pb; |
Boolean usePB = false; |
if (OTIsSynchronous(ep) == false) // check whether ep sync or not |
usePB = true; |
else |
{ |
result = OTIoctl(ep, ATALK_IOC_FULLSELFSEND, (void*)enableSelfSend); |
if (result < kOTNoError) |
usePB = true; // if an error occured, try using the PBSetSelfSend call |
} |
if (usePB == true) |
{ |
pb.newSelfFlag = enableSelfSend != 0 ? true : false; /* set self send option */ |
result = PSetSelfSend((MPPPBPtr) &pb, false); |
} |
return result; |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-07-22