I am trying to attach a new PPP interface and then
modify it using NetLibIFSettingSet. NetLibIFSettingSet
returns with no errors. When my app exits, I check the
network preference panel, and it hasn't been modified.

Below is the code I am using. It's a function that's
called when a button is pressed in the main form. I am
using CodeWarrior/SDK 3.1, and downloading to a
PalmIIIx/PalmOS 3.1

Any help will be really appreciated

Paul Babic
 


Err MyConfigModemSW()
{
  Boolean done;
  Err err;
  UInt16 index;
  UInt16 IFerrs;
  UInt16 IFinstance;
  UInt32 IFcreator;
  UInt32 version;

  char   UseModem;
  char   DynamicIP;
  char   ServiceName[] = "Minstrel";
  UInt16 DefaultIFInstance; 
  UInt32 BaudRate;
  UInt32 PrimaryDNS;
  UInt32 SecondaryDNS;
  UInt32 DefaultIFCreator;
  UInt32 ReqIPAddr;

  // check whether network library is present
  err =
FtrGet(netFtrCreator,netFtrNumVersion,&version);
  if (err) return err;  
  printf("Mesg: Version %x\n",version);
  
  // look for network library
  err = SysLibFind("Net.lib", &AppNetRefnum);
  if (err)
  {
    printf("Error: SysLibFind.\n");
    printf("Error: Could not find Network
library.\n");
    return err;
  }

  // detach all attached network interfaces
  done = false;
  for (index=0; !done; index++)
  {
    // check for IF
    err =
NetLibIFGet(AppNetRefnum,index,&IFcreator,&IFinstance);
    if (err)
    {
      switch (err)
      {
        case netErrInvalidInterface:
          printf("Error: Index too high.\n\n");
          done = true;
          break;
        case netErrPrefNotFound:
          //printf("Error: No value for setting.\n");
          break;
        default:
          //printf("Error: Unknown error.\n\n");
          break;
      }
      if (index > 100)
        done = true;
      continue;
    }

    // if found interface, detach it
    err =
NetLibIFDetach(AppNetRefnum,IFcreator,IFinstance,TimeOutInTicks);
    if (err)
    {
      printf("Error: NetLibIFDetach. %d\n",err);
      switch (err)
      {
        case netErrInterfaceNotFound:
          printf("Error: Interface not found.\n");
          break;
        default:
          printf("Error: Unknown error.\n");
          break;
      }
    }
    printf("Mesg: Detached interface %d.\n",index);
  
    if (index > 100) 
      break;
  }

  // attach my network interface
  IFinstance = 0;
  err = NetLibIFAttach(AppNetRefnum,netIFCreatorPPP,
                       IFinstance,TimeOutInTicks);
  if (err)
  {
    printf("Error: NetLibIFAttach. %d\n",err);
    switch (err)
    {
      case netErrInterfaceNotFound:
        printf("Error: Interface not found.
%d\n",err);
        break;
      case netErrTooManyInterfaces:
        printf("Error: Too many interfaces.
%d\n",err);
        break;
      default:
        printf("Error: Unknown error. %d\n",err);
        break;
    }
  }
  printf("Mesg: Attached new network interface.\n");

  // reset all general settings
  err =
NetLibSettingSet(AppNetRefnum,netSettingResetAll,NULL,0);
  if (err) printf("Error: 1\n");
    
  // set primary DNS
  PrimaryDNS = 0x11111111;
  err =
NetLibSettingSet(AppNetRefnum,netSettingPrimaryDNS,&PrimaryDNS,sizeof(PrimaryDNS));
  if (err) printf("Error: 2\n");

  // set secondary DNS
  SecondaryDNS = 0x22222222;
  err =
NetLibSettingSet(AppNetRefnum,netSettingSecondaryDNS,&SecondaryDNS,sizeof(SecondaryDNS));
  if (err) printf("Error: 3\n");

  // set default IF creator
  DefaultIFCreator = netIFCreatorPPP;
  err =
NetLibSettingSet(AppNetRefnum,netSettingDefaultIFCreator,&DefaultIFCreator,sizeof(DefaultIFCreator));
  if (err) printf("Error: 4\n");

  // set default IF instance
  DefaultIFInstance = 0;
  err =
NetLibSettingSet(AppNetRefnum,netSettingDefaultIFInstance,&DefaultIFInstance,sizeof(DefaultIFInstance));
  if (err) printf("Error: 5\n");

  // reset all interface settings
  err =
NetLibIFSettingSet(AppNetRefnum,netIFCreatorPPP,DefaultIFInstance,netIFSettingResetAll,0,0);
  if (err) printf("Error: 6\n");

  // set IF ServiceName
  err =
NetLibIFSettingSet(AppNetRefnum,netIFCreatorPPP,DefaultIFInstance,netIFSettingServiceName,ServiceName,9);
  if (err) printf("Error: 7\n");

  // set IF ReqIPAddr
  ReqIPAddr = 0x80808080;
  err =
NetLibIFSettingSet(AppNetRefnum,netIFCreatorPPP,DefaultIFInstance,netIFSettingReqIPAddr,&ReqIPAddr,sizeof(ReqIPAddr));
  if (err) printf("Error: 8\n");

  // reset IF DynamicIP
  DynamicIP = 0;
  err =
NetLibIFSettingSet(AppNetRefnum,netIFCreatorPPP,DefaultIFInstance,netIFSettingDynamicIP,&DynamicIP,sizeof(DynamicIP));
  if (err) printf("Error: 9\n");
  
  // set IF BaudRate
  BaudRate = 19200;
  err =
NetLibIFSettingSet(AppNetRefnum,netIFCreatorPPP,DefaultIFInstance,netIFSettingBaudRate,&BaudRate,sizeof(BaudRate));
  if (err) printf("Error: 10\n");


  return 0;
}



__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/


-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to