Re: Getting PPP connection state on 10.1 fails mysteriously sometimes
Re: Getting PPP connection state on 10.1 fails mysteriously sometimes
- Subject: Re: Getting PPP connection state on 10.1 fails mysteriously sometimes
- From: <email@hidden>
- Date: Sat, 18 May 2002 03:10:58 +0100
Hi morgan, chris !
I have the same problem on X. ( works very well on 9).
I have reported this in a bug report (ID 2844410) filed in Feb 2002. No news
yet about a fix.. If Quinn (the esquimoo.) read this, may be he could tell
us something about it !
//========================================================
BOOL Internet_AreWeConnected(EndpointRef EPRef)
//=========================================================
// The Endpoint MUST BE synchronous at the time of this call !!
{
TOptMgmt cmd;
TOption* option;
UInt8 buf[500];
OSStatus Err;
CCMiscInfo *info;
cmd.opt.buf= buf;
cmd.opt.len= sizeof(TOptionHeader);
cmd.opt.maxlen = sizeof(buf);
cmd.flags= T_CURRENT;
option = (TOption *) buf;
option->level = COM_PPP;
option->name = CC_OPT_GETMISCINFO; // PPP_OPT_GETCURRENTSTATE;
option->status = 0;
option->len = sizeof(TOptionHeader);
// OTSetSynchronous(EPRef);
Err = OTOptionManagement(EPRef, &cmd, &cmd);
if( Err) return false;
option = (TOption *) cmd.opt.buf;
if (option->status == T_SUCCESS)
{
CCMiscInfo *info = (CCMiscInfo *) &option->value[0];
//
// Are we connected?
//
if (info->connectionStatus == kPPPConnectionStatusConnected) return
TRUE;
else
return FALSE;
}
return FALSE;
//........
option = (TOption *) cmd.opt.buf;
info = (CCMiscInfo *) &option->value[0];
if (option->status == T_SUCCESS)
{
//
// Are we connected?
//
if ( info->connectionStatus == kPPPStateInitial ||
info->connectionStatus == kPPPStateClosed ||
info->connectionStatus == kPPPStateClosing) return FALSE;
if (info->connectionStatus == kPPPStateOpening ||
info->connectionStatus == kPPPStateOpened ) return TRUE;
}
if (option->status == T_READONLY)
{
if ( info->connectionStatus == kPPPStateInitial ||
info->connectionStatus == kPPPStateClosed ||
info->connectionStatus == kPPPStateClosing) return FALSE;
if (info->connectionStatus == kPPPStateOpening ||
info->connectionStatus == kPPPStateOpened ) return TRUE;
}
return FALSE;
} // Internet_AreWeConnected
----------------------------------------
JP Harmand | iccs software
email@hidden |
http://turbo3d.free.fr
----------------------------------------
--
>
De : Herb Hrowal <email@hidden>
>
Date : Fri, 17 May 2002 14:55:20 -0700
>
@ : Mac Network Programming <email@hidden>
>
Objet : Re: Getting PPP connection state on 10.1 fails mysteriously sometimes
>
>
Hi Morgan,
>
>
We had a similar problem back when Mac OS X was first released and it turns
>
out the OT implementation on X is a little more sensitive about how the
>
TOption and TOptMgmt structures are initialized. If I remember correctly,
>
the only change we had to make to both structures is to set the len member
>
to the full size of the buffer instead of just the size of the TOption
>
structure. Just use the same value you use for maxlen.
>
>
Hope this helps,
>
>
--
>
Herb Hrowal <email@hidden>
>
Staff Engineer, Mac Client Software
>
EarthLink, Inc.
>
>
>
on 5/17/2002 2:02 PM, Morgan Redman at email@hidden wrote:
>
>
> Hi Chris,
>
>
>
> I was just wondering if you ever got a reply to the email below that was
>
> not sent to this list. I am having the same problem. I dont check the
>
> PPP state, but I use a function much like the one below to get the
>
> connection state. I am using the same code that works in my OS 9
>
> version, but I always get kOTBadOptionErr.
>
>
>
> -Morgan
>
>
>
> On Wednesday, January 9, 2002, at 07:32 AM, Chris Hanson wrote:
>
>
>
>> I'm using the below code in a Mach-O bundle (built with CodeWarrior Pro
>
>> 7.0) to get the CCMiscInfo structure for a PPP endpoint on Mac OS X
>
>> 10.1.
>
>>
>
>> All I really want to do is determine whether PPP is connected during
>
>> and after dialing, so I'm using an almost identical call to get the
>
>> state of the PPP endpoint, and if the state is kPPPStateOpened I call
>
>> the below function. However, sometimes -- not all the time --
>
>> OTOptionManagement returns kOTBadOptionErr. This is the case even
>
>> though PPP is obviously connected, and Apple's PPP menu bar extra shows
>
>> the correct connection state.
>
>>
>
>> Am I doing something silly that's making this not work? Or are there
>
>> known issues with this? (It'd be nice if there were OT/PPP sample code
>
>> for Mac OS X. :)
>
>>
>
>> Thanks a lot.
>
>>
>
>> -- Chris
>
>>
>
>> OSStatus OTPPPGetMiscInfo(EndpointRef inEndpoint, CCMiscInfo* outInfo)
>
>> {
>
>> OSStatus anErr = noErr;
>
>> Boolean wasSync;
>
>>
>
>> check(inEndpoint != kOTInvalidEndpointRef);
>
>> check(outInfo != NULL);
>
>>
>
>> if ((inEndpoint == kOTInvalidEndpointRef) or (outInfo == NULL)) {
>
>> return paramErr;
>
>> }
>
>>
>
>> TOptMgmt cmd;
>
>> TOption* option;
>
>> UInt8 buf[sizeof(TOption) + sizeof(CCMiscInfo)];
>
>>
>
>> cmd.opt.buf = buf;
>
>> cmd.opt.len = sizeof(TOption);
>
>> cmd.opt.maxlen = sizeof(TOption) + sizeof(CCMiscInfo);
>
>> cmd.flags = T_CURRENT;
>
>>
>
>> option = (TOption *) buf;
>
>> option->len = sizeof(TOption);
>
>> option->level = COM_PPP;
>
>> option->name = CC_OPT_GETMISCINFO;
>
>> option->status = 0;
>
>>
>
>> wasSync = OTIsSynchronous(inEndpoint);
>
>>
>
>> anErr = OTSetSynchronous(inEndpoint);
>
>> check_noerr(anErr);
>
>>
>
>> if (anErr == noErr) {
>
>> anErr = OTOptionManagement(inEndpoint, &cmd, &cmd);
>
>> check_noerr(anErr);
>
>>
>
>> if (anErr == noErr) {
>
>> option = (TOption *) cmd.opt.buf;
>
>>
>
>> if (option->status == T_SUCCESS)
>
>> {
>
>> CCMiscInfo *info = (CCMiscInfo *) &option->value[0];
>
>>
>
>> BlockMoveData(info, outInfo, sizeof(CCMiscInfo));
>
>> }
>
>> }
>
>>
>
>> if (wasSync == false) {
>
>> (void) OTSetAsynchronous(inEndpoint);
>
>> }
>
>> }
>
>>
>
>> return anErr;
>
>> }
>
>>
>
>> -- Chris Hanson | Email: email@hidden
>
>> bDistributed.com, Inc. | Phone: +1-847-372-3955
>
>> Making Business Distributed | Fax: +1-847-589-3738
>
>> http://bdistributed.com/ | Personal Email: email@hidden
>
>> _______________________________________________
>
>> opentransportdev mailing list | email@hidden
>
>> Help/Unsubscribe/Archives:
>
>> http://www.lists.apple.com/mailman/listinfo/opentransportdev
>
>> Do not post admin requests to the list. They will be ignored.
>
> _______________________________________________
>
> 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.
>
_______________________________________________
>
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.
_______________________________________________
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.