NAME

Win32::MprApi - Perl wrapper for Win32 Router Configuration functions.

SYNOPSIS

use Win32::MprApi;

$ret = Win32::MprApi::MprConfigServerConnect(\$ServerName, \$hMprConfig);

$ret = Win32::MprApi::MprConfigGetGuidName($hMprConfig, \$FriendlyName, \$GUIDName);

$ret = Win32::MprApi::MprConfigGetFriendlyName($hMprConfig, \$GUIDName, \$FriendlyName);

$ret = Win32::MprApi::MprConfigServerDisconnect($hMprConfig);

DESCRIPTION

Interface to Win32 IP Router Configuration useful functions, needed to translate a Friendly Name (like "Local Area Connection") into a GUID (like "{88CE272F-847A-40CF-BFBA-001D9AD97450}") and vice-versa.

This module covers only a small subset of the functions and data structures provided by the Win32 Router Configuration API.

The API is supported on platforms where MprApi.dll is available:

  • Microsoft Windows 2000

  • Microsoft Windows XP

  • Microsoft Windows .NET Server 2003 family

The complete SDK Reference documentation is available online through Microsoft MSDN Library (http://msdn.microsoft.com/library/default.asp)

EXPORT

None by default.

FUNCTIONS

MprConfigServerConnect(\$ServerName, \$hMprConfig)

The MprConfigServerConnect function connects to the Windows 2000 router to be configured. Call this function before making any other calls to the server. The handle returned by this function is used in subsequent calls to configure interfaces and transports on the server.

Example

use Win32::MprApi;

my $ServerName; # if no name is defined, local server is used instead
my $hMprConfig; # receives the handle to connected server

# Connect to the server router
$ret = Win32::MprApi::MprConfigServerConnect(\$ServerName, \$hMprConfig);

if($ret == 0)
{
  printf "MprConfigServerConnect() Server connected successfuly, handle is %u\n", $hMprConfig;

  # Disconnect from the server router
  Win32::MprApi::MprConfigServerDisconnect($hMprConfig);
}
else
{
  printf "MprConfigServerConnect() error %u: %s\n", $ret, Win32::FormatMessage($ret);
}

Return Values

If the function succeeds, the return value is 0.

If the function fails, the error code can be decoded with Win32::FormatMessage($ret).

Requirements

Server: Included in Windows .NET Server 2003, Windows 2000 Server. Header: Declared in Mprapi.h. Library: Use Mprapi.dll.

MprConfigGetGuidName($hMprConfig, \$FriendlyName, \$GUIDName)

The MprConfigGetGuidName function returns the GUID name for an interface that corresponds to the specified friendly name.

Example

use Win32::MprApi;

my $ServerName; # if no name is defined, local server is used instead
my $hMprConfig; # receives the handle to connected server
my $FriendlyName = 'Local Area Connection';
my $GUIDName; # buffer for the translated GUID Name

# Connect to the server router
$ret = Win32::MprApi::MprConfigServerConnect(\$ServerName, \$hMprConfig);

if($ret == 0)
{
  $ret = Win32::MprApi::MprConfigGetGuidName($hMprConfig, \$FriendlyName, \$GUIDName);

    if($ret == 0)
    {
      printf "The GUID Name for connection %s is: %s\n", $FriendlyName, $GUIDName;
    }
    else
    {
      printf "MprConfigGetGuidName() error %u: %s\n", $ret, Win32::FormatMessage($ret);
    }

    # Disconnect from the server router
    Win32::MprApi::MprConfigServerDisconnect($hMprConfig);
}
else
{
  printf "MprConfigServerConnect() error %u: %s\n", $ret, Win32::FormatMessage($ret);
}

Return Values

If the function succeeds, the return value is 0.

If the function fails, the error code can be decoded with Win32::FormatMessage($ret).

Requirements

Server: Included in Windows .NET Server 2003, Windows 2000 Server. Header: Declared in Mprapi.h. Library: Use Mprapi.dll.

MprConfigGetFriendlyName($hMprConfig, \$GUIDName, \$FriendlyName)

The MprConfigGetFriendlyName function returns the Friendly Name for an interface that corresponds to the specified GUID name.

Example

use Win32::MprApi;

my $ServerName; # if no name is defined, local server is used instead
my $hMprConfig; # receives the handle to connected server
my $GUIDName = '{88CE272F-847A-40CF-BFBA-001D9AD97450}';
my $FriendlyName; # buffer for the translated Friendly Name

# Connect to the server router
$ret = Win32::MprApi::MprConfigServerConnect(\$ServerName, \$hMprConfig);

if($ret == 0)
{
  $ret = Win32::MprApi::MprConfigGetFriendlyName($hMprConfig, \$GUIDName, \$FriendlyName);

    if($ret == 0)
    {
      printf "The Friendly Name for GUID %s is: %s\n", $GUIDName, $FriendlyName;
    }
    else
    {
      printf "MprConfigGetFriendlyName() error %u: %s\n", $ret, Win32::FormatMessage($ret);
    }

    # Disconnect from the server router
    Win32::MprApi::MprConfigServerDisconnect($hMprConfig);
}
else
{
  printf "MprConfigServerConnect() error %u: %s\n", $ret, Win32::FormatMessage($ret);
}

Return Values

If the function succeeds, the return value is 0.

If the function fails, the error code can be decoded with Win32::FormatMessage($ret).

Requirements

Server: Included in Windows .NET Server 2003, Windows 2000 Server. Header: Declared in Mprapi.h. Library: Use Mprapi.dll.

MprConfigServerDisconnect( $hMprConfig )

The MprConfigServerDisconnect function disconnects a connection made by a previous call to MprConfigServerConnect.

Example

See previous examples

Return Values

This function has no return values.

Requirements

Server: Included in Windows .NET Server 2003, Windows 2000 Server. Header: Declared in Mprapi.h. Library: Use Mprapi.dll.

CREDITS

Thanks to Aldo Calpini for the powerful Win32::API module that makes this thing work.

AUTHOR

Luigino Masarati, <lmasarati@hotmail.com>