The RAS function is detailed

Source: Internet
Author: User
Tags call back manage connection

1. What does RAS mean?
A: All of Microsoft's WI n d o w S platforms have RAS clients, which allow us to place our own computers with another
remote computer (which is characterized by a remote access server component), in general, the RAS client takes advantage of the connected
A modem that is connected to the phone line calls the remote computer by dialing. Therefore, sometimes, the RAS client
Also known as the Dial-Up Networking (DUN) client. Server in this regard, there must be a service waiting for the DUN connection,
After the connection between the RAS client and the server is established, the Network protocol stack (which is related to the framing protocol used) is
This RAS connection communicates with the remote computer as if it were connected over a LAN. Now, of course, many modulation
The data communication rate of the demodulator is significantly slower than the direct LAN connection. RAS connections are validated by the options available in the phonebook entry, and the RAS can be
Move into a machine and log in to a domain.
2.RAS Error printing?
Raserror.h lists quite a few pre-defined error codes. In this file, you will notice an error stating
String, which is associated with each error code used in RAS Rasgeterrorstring
3. Platform compatible?
Some of the data structures used by the RAS function are based on
The value defined by the winver, using or without additional data fields, respectively.
So be sure to define the current winver, or the failure will return 632
Go straight to Targetver.h, like XP:
/No # define WINVER 0x0501
Just add it directly.

[CPP]View Plaincopy
    1. #ifndef WINVER   
    2. #define WINVER 0x0501   
    3. #endif   

4. Specific function Description:
(1)

[CPP]View Plaincopy
  1. DWORD RasDial (
  2. __in lprasdialextensions Lprasdialextensions,
  3. __in lpctstr Lpszphonebook,
  4. __in Lprasdialparams Lprasdialparams,
  5. __in DWORD dwnotifiertype,
  6. __in lpvoid lpvnotifier,
  7. __in Lphrasconn Lphrasconn
  8. );

Lprasdialextensions: The parameter is an optional pointer to a rasdialextensions structure with
This structure, your application can use the extension attribute of the rasdial function, can be ignored, set to null
Pszphonebook: The path used to identify a phone book file. Set to NULL, indicating that the current default phone book file is used
Lprasdialparams: Defines dial-up and user authentication parameters
Dwnotifiertype, Lpvnotifier: Can I call synchronously or asynchronously?
Lphrasconn:

The following continues the parsing of this function's internal structure:
The first parameter lprasdialextensions corresponds to the struct body:

[CPP]View Plaincopy
  1. typedef struct tagrasdialextensions {
  2. DWORD  dwsize;
  3. DWORD  dwfoptions;
  4. HWND  hwndparent;
  5. ulong_ptr  reserved;
  6. #if (WINVER >= 0x500)   
  7. ulong_ptr  reserved1;
  8. Raseapinfo Raseapinfo;
  9. #endif   
  10. } rasdialextensions

Dwsize: Must be set to the length of the rasdialextensions structure (in bytes).
Dwfoptions: Allows you to set bit flags for using the rasdial extension feature, as follows:
Rdeopt_useprefixsuffix: Enables rasdial to use prefixes and suffixes associated with a specified dial-up device
Rdeopt_pausedstates: Allows rasdial to enter the suspend operation so that the user can retry the login, change the password and set the callback number
Rdeopt_ignoremodemspeaker: Make rasdial Ignore Modem speaker settings in RAS phone book
Rdeopt_setmodemspeaker: If the Rdeopt_ignoremodemspeaker flag is set, use this flag to turn on the modem horn
Rdeopt_ignoresoftwarecompression: Make rasdial ignore software compression settings
Rdeopt_setsoftwarecompression: After setting the Rdeopt_ignoresoftwarecompression flag, then use this flag, will open the software compression
Rdeopt_pauseonscript: for RasDialDlg internal use. This flag cannot be set
Rdeopt_usecustomscripting:2000/nt not supported
Rdeopt_customdial:nt not supported
hWndParent: No, it should be set to NULL
Reserved: No, set to 0
Reserved1: No, set to 0
Raseapinfo:nt not supported

Second parameter: Phone book file:
The phone book is just a collection of rasentry structures that contain phone numbers, data rates, user authentication information, and other connection information, and on the 2000/nt platform, the phone book extension is generally. PBK file
Specific structure See window Network programming chapter 16.

A third parameter:

[CPP]View Plaincopy
  1. typedef struct _rasdialparams {
  2. DWORD   dwsize;
  3. TCHAR   Szentryname[ras_maxentryname + 1];
  4. TCHAR   Szphonenumber[ras_maxphonenumber + 1];
  5. TCHAR   Szcallbacknumber[ras_maxcallbacknumber + 1];
  6. TCHAR   Szusername[unlen + 1];
  7. TCHAR   Szpassword[pwlen + 1];
  8. TCHAR   Szdomain[dnlen + 1];
  9. #if (WINVER >= 0x401)   
  10. DWORD  Dwsubentry;
  11. ulong_ptr  Dwcallbackid;
  12. #endif   
  13. } rasdialparams;

Dwsize: Must be set to rasdialparams; the length of the structure (in bytes).
Szentryname: A string that allows you to identify a phonebook entry that is contained within the phone book file listed in the Lpszphonebook parameter of the rasdial function, such as an empty string (""), Rasdial will select the first available modem installed on the system,

and dial the connection according to the next parameter Szphonenumber
Szphonenumber: A string that represents a phone number that takes precedence over the phone number included in the phonebook entry specified in the Szentryname field
Szcallbacknumber: Allows you to specify a phone number that the RAS server can call back based on this number. If the RAS server allows a callback number, it interrupts the original connection and dials back with the callback number you specified. This feature is very good, because with it

Server to know where the connected users come from
szUserName: A string that identifies the logon name used to authenticate a user on the RAS server
Szpassword: A string that identifies the password used by the user on the R a s server for authentication
Szdomain: Optional. Allows you to specify the initial phone notebooks entry to dial a RAS multilink connection
Dwcallbackid: Allows you to post an application-defined value to an R a s D i-l F u N C 2 callback function

Fourth of the fifth parameter:
If the Lpvnotifier parameter is set to Null,rasdial, it will be placed in synchronous mode. The Dwnotifiertype parameter is ignored. Synchronous invocation of rasdial is the simplest use of the function; In the ointment, the connection cannot be monitored in synchronous mode, if the Lpvnotifier

parameter is not NULL, it goes into asynchronous mode, which means that the function call returns immediately when the connection is made. The connection process can be monitored
Dwnotifiertype:
The 0:lpvnotifier parameter uses the RASDIALFUNC function pointer to manage connection events
The 1:lpvnotifier parameter manages connection events with the RASDIALFUNC1 function pointer
The 2:lpvnotifier parameter manages connection events with the RASDIALFUNC2 function pointer
The 0xfffffff:lpvnotifier parameter enables rasdial to send a window message during a connection event
The following three functions are:

[CPP]View Plaincopy
    1. void CALLBACK Rasdialfunc (
    2. [In] UINT Unmsg,
    3. [In] Rasconnstate Rasconnstate,
    4. [In] DWORD dwerror
    5. );

Unmsg: only possible for wm_rasdialevent
Rasconnstate: Receive rasdial function upcoming connection activity: Run, pause, and break
Dwerror:ras error code

[CPP]View Plaincopy
  1. void CALLBACK RasDialFunc1 (
  2. [In] Hrasconn Hrasconn,
  3. [In] UINT Unmsg,
  4. [In] Rasconnstate Rascs,
  5. [In] DWORD Dwerror,
  6. [In] DWORD Dwextendederror
  7. );

Hrasconn: A handle to a connection
Dwextendederror: Extended error message

[CPP]View Plaincopy
  1. DWORD CALLBACK RasDialFunc2 (
  2. [In] DWORD Dwcallbackid,
  3. [In] DWORD Dwsubentry,
  4. [In] Hrasconn Hrasconn,
  5. [In] UINT Unmsg,
  6. [In] Rasconnstate Rascs,
  7. [In] DWORD Dwerror,
  8. [In] DWORD Dwextendederror
  9. );

Dwcallbackid: Contains an application-defined value that was originally set in Rasdialparams; the Dwcallbackid field of the struct.
Dwsubentry: Receive sub-entry phone Book index, this index will callback the RASDIALFUNC2 function again

(2) Event notification function

[CPP]View Plaincopy
    1. dword   Rasconnectionnotification (  
    2.   __in           hrasconn hrasconn,  
    3.   __in          HANDLE  hevent,  
    4.   __in           dword  dwflags  
    5. );   

A connection handle returned by hrasconn:rasdial, such as Invalid_handle_value (strong conversion to hrasconn)
Hevent:createevent Create
DwFlags:
Rascn_connection: When Hrasconn is Invalid_handle_value, any RAS connection will trigger this event
Rascn_disconnection: When Hrasconn is Invalid_handle_value, any RAS aborts will trigger this event
Rascn_bandwidthadded: On a multilink connection, the child entry connection triggers this event
Rascn_bandwidthremoved: This event is triggered when a sub-entry cancels a connection on a multilink connection

(3)

[CPP]View Plaincopy
    1. DWORD Rashangup (
    2. __in Hrasconn Hrasconn
    3. );

A connection handle returned by hrasconn:rasdial
Note: When connecting on a modem port, this port takes time to reset the connection if the connection is closed. Therefore, you should wait until the port connection is completely closed. To do this, when you reset your connection, you can call the
R Asgetconnectionstatus to determine if the connection is completely closed.

(4)

[CPP]View Plaincopy
    1. DWORD Rasgetconnectstatus (
    2. __in Hrasconn Hrasconn,
    3. __in_out Lprasconnstatus Lprasconnstatus
    4. );

A connection handle returned by hrasconn:rasdial
Lprasconnstatus: Get the current connection status

[CPP]View Plaincopy
  1. typedef struct _rasconnstatus {
  2. DWORD   dwsize;
  3. Rasconnstate rasconnstate;
  4. DWORD   dwerror;
  5. TCHAR   Szdevicetype[ras_maxdevicetype + 1];
  6. TCHAR  Szdevicename[ras_maxdevicename + 1];
  7. #if (WINVER >= 0x401)   
  8. TCHAR  szphonenumber[Ras_maxphonenumber + 1];
  9. #endif//(WINVER >= 0x401)   
  10. } rasconnstatus;

Dwsize: Must be set to the length of the Rasconnstatus structure (in bytes).
Rasconnstate:ras Connection Activity Status
Dwerror: If Rasgetconnectstatus does not return 0, get a specific R a s error code
Szdevicetype: Gets a string that represents the type of device used for the connection
Szdevicename: Get the current device name
Szphonenumber: A string such as a phone number, such as *99#

(5) Obtain all device names and types with R A s capability

[CPP]View Plaincopy
    1. DWORD RasEnumDevices (
    2. __in Lprasdevinfo Lprasdevinfo,
    3. __in_out lpdword LPCB,
    4. __out lpdword lpcdevices
    5. );

(6) Determine if the name is in the correct format and is included in the phone book

[CPP]View Plaincopy
    1. DWORD Rasvalidateentryname (
    2. __in lpctstr Lpszphonebook,
    3. __in lpctstr lpszentry
    4. );

Lpszphonebook: The path used to identify a phone book file. Set to NULL, indicating that the current default phone book file is used
Lpszentry: The name is not in the phone book, but when the name is formatted correctly, it returns ERROR_SUCCESS. If the name format is wrong, the function will fail and return to Error_invalidname;
If this name is in the phone book, it will return to Error_alread_yexist

(7)
RAS has four functions that allow a program to manage the rasentry structure of the phonebook. They are: Rasset Entry,
Rasgetentryproperties, Rasrenameentry and Rasdeleteentry. To create a new entry or to an existing
Can be modified by using the Rassetentryproperties function

(8)
You can use the Rasgetentrydialparams and Rassetentrydialparams functions to manage specific calls
User security credentials related to the book entry

The RAS function is detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.