Re: Using the broadcast address
Re: Using the broadcast address
- Subject: Re: Using the broadcast address
- From: "Marc Epard" <email@hidden>
- Date: Thu, 16 May 2002 11:39:06 -0500
You can get the broadcast address from the InetInterfaceInfo for the
interface you want to broadcast on.
InetInterfaceInfo interfaceInfo;
ZERO(interfaceInfo);
error = OTInetGetInterfaceInfo(&interfaceInfo, kDefaultInetInterface);
(error handling removed)
if (interfaceInfo.fBroadcastAddr != 0)
broadcastAddress = interfaceInfo.fBroadcastAddr;
else
broadcastAddress = interfaceInfo.fAddress | ~interfaceInfo.fNetmask;
Also, be sure to negotiate the IP_BROADCAST option for the endpoint.
struct TOption : public TOptionHeader
{
UInt32 value;
};
TOption optionBuffer;
optionBuffer.len = sizeof(optionBuffer);
optionBuffer.level = INET_IP;
optionBuffer.name = IP_BROADCAST;
optionBuffer.status = 0;
optionBuffer.value = T_YES;
TOptMgmt optReq;
optReq.flags = T_NEGOTIATE;
optReq.opt.maxlen = sizeof(optionBuffer);
optReq.opt.len = sizeof(optionBuffer);
optReq.opt.buf = (UInt8*) &optionBuffer;
VERIFYNOERR(endpoint->OptionManagement(&optReq, &optReq));
ASSERT(optionBuffer.status == T_SUCCESS);
-Marc
Marc Epard
Netopia, Inc.
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.