radius_acct_open

Creates a Radius handle for accounting

说明

resource radius_acct_open ( void )

返回值

Returns a handle on success, FALSE on error. This function only fails if insufficient memory is available.

范例

示例 #1 radius_acct_open example

<?php
$res = radius_acct_open ()
    or die ("Could not create handle");
print("Handle successfully created");
?>

radius_add_server

Adds a server

说明

bool radius_add_server ( resource $radius_handle , string $hostname , int $port , string $secret , int $timeout , int $max_tries )

radius_add_server may be called multiple times, and it may be used together with radius_config. At most 10 servers may be specified. When multiple servers are given, they are tried in round-robin fashion until a valid response is received, or until each server's max_tries limit has been reached.

参数

radius_handle

hostname
The hostname parameter specifies the server host, either as a fully qualified domain name or as a dotted-quad IP address in text form.

port
The port specifies the UDP port to contact on the server. If port is given as 0, the library looks up the radius/udp or radacct/udp service in the network services database, and uses the port found there. If no entry is found, the library uses the standard Radius ports, 1812 for authentication and 1813 for accounting.

secret
The shared secret for the server host is passed to the secret parameter. The Radius protocol ignores all but the leading 128 bytes of the shared secret.

timeout
The timeout for receiving replies from the server is passed to the timeout parameter, in units of seconds.

max_tries
The maximum number of repeated requests to make before giving up is passed into the max_tries.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 radius_add_server example

<?php
if (!radius_add_server($res, 'radius.example.com', 1812, 'testing123', 3, 3)) {
    echo 'RadiusError:' . radius_strerror($res). "\n<br>";
    exit;
}
?>

参见

  • radius_config

radius_auth_open

Creates a Radius handle for authentication

说明

resource radius_auth_open ( void )

返回值

Returns a handle on success, FALSE on error. This function only fails if insufficient memory is available.

范例

示例 #1 radius_auth_open example

<?php
$radh = radius_auth_open()
    or die ("Could not create handle");
echo "Handle successfully created";
?>

radius_close

Frees all ressources

说明

bool radius_close ( resource $radius_handle )

It is not needed to call this function because php frees all resources at the end of each request.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

radius_config

Causes the library to read the given configuration file

说明

bool radius_config ( resource $radius_handle , string $file )

Before issuing any Radius requests, the library must be made aware of the servers it can contact. The easiest way to configure the library is to call radius_config. radius_config causes the library to read a configuration file whose format is described in » radius.conf.

参数

radius_handle

file
The pathname of the configuration file is passed as the file argument to radius_config. The library can also be configured programmatically by calls to radius_add_server.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • radius_add_server

radius_create_request

Create accounting or authentication request

说明

bool radius_create_request ( resource $radius_handle , int $type )

A Radius request consists of a code specifying the kind of request, and zero or more attributes which provide additional information. To begin constructing a new request, call radius_create_request.

Note: Attention: You must call this function, before you can put any attribute!

参数

radius_handle

type
Type is RADIUS_ACCESS_REQUEST or RADIUS_ACCOUNTING_REQUEST.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 radius_create_request example

<?php
if (!radius_create_request($res, RADIUS_ACCESS_REQUEST)) {
    echo 'RadiusError:' . radius_strerror($res). "\n<br />";
    exit;
}
?>

参见

  • radius_send_request

radius_cvt_addr

Converts raw data to IP-Address

说明

string radius_cvt_addr ( string $data )

范例

示例 #1 radius_cvt_addr example

<?php
while ($resa = radius_get_attr($res)) {

    if (!is_array($resa)) {
        printf ("Error getting attribute: %s\n",  radius_strerror($res));
        exit;
    }

    $attr = $resa['attr'];
    $data = $resa['data'];
    
    switch ($attr) {

    case RADIUS_FRAMED_IP_ADDRESS:
        $ip = radius_cvt_addr($data);
        echo "IP: $ip<br>\n";
        break;

    case RADIUS_FRAMED_IP_NETMASK:
        $mask = radius_cvt_addr($data);
        echo "MASK: $mask<br>\n";
        break;
    }
}
?>

参见

  • radius_cvt_int
  • radius_cvt_string

radius_cvt_int

Converts raw data to integer

说明

int radius_cvt_int ( string $data )

范例

示例 #1 radius_cvt_int example

<?php
while ($resa = radius_get_attr($res)) {

    if (!is_array($resa)) {
        printf ("Error getting attribute: %s\n",  radius_strerror($res));
        exit;
    }

    $attr = $resa['attr'];
    $data = $resa['data'];
    
    switch ($attr) {

    case RADIUS_FRAMED_MTU:
        $mtu = radius_cvt_int($data);
        echo "MTU: $mtu<br>\n";
        break;
    }
}
?>

参见

  • radius_cvt_addr
  • radius_cvt_string

radius_cvt_string

Converts raw data to string

说明

string radius_cvt_string ( string $data )

范例

示例 #1 radius_cvt_string example

<?php
while ($resa = radius_get_attr($res)) {

    if (!is_array($resa)) {
        printf ("Error getting attribute: %s\n",  radius_strerror($res));
        exit;
    }

    $attr = $resa['attr'];
    $data = $resa['data'];
    
    switch ($attr) {

    case RADIUS_FILTER_ID:
        $id = radius_cvt_string($data);
        echo "Filter ID: $id<br>\n";
        break;
    }
}
?>

参见

  • radius_cvt_addr
  • radius_cvt_int

radius_demangle_mppe_key

Derives mppe-keys from mangled data

说明

string radius_demangle_mppe_key ( resource $radius_handle , string $mangled )

When using MPPE with MS-CHAPv2, the send- and recv-keys are mangled (see » RFC 2548), however this function is useless, because I don't think that there is or will be a PPTP-MPPE implementation in PHP.

返回值

Returns the demangled string, or FALSE on error.

radius_demangle

Demangles data

说明

string radius_demangle ( resource $radius_handle , string $mangled )

Some data (Passwords, MS-CHAPv1 MPPE-Keys) is mangled for security reasons, and must be demangled before you can use them.

返回值

Returns the demangled string, or FALSE on error.

radius_get_attr

Extracts an attribute

说明

mixed radius_get_attr ( resource $radius_handle )

Like Radius requests, each response may contain zero or more attributes. After a response has been received successfully by radius_send_request, its attributes can be extracted one by one using radius_get_attr. Each time radius_get_attr is called, it gets the next attribute from the current response.

返回值

Returns an associative array containing the attribute-type and the data, or error number <= 0.

范例

示例 #1 radius_get_attr example

<?php
while ($resa = radius_get_attr($res)) {

    if (!is_array($resa)) {
        printf("Error getting attribute: %s\n",  radius_strerror($res));
        exit;
    }

    $attr = $resa['attr'];
    $data = $resa['data'];
    printf("Got Attr:%d %d Bytes %s\n", $attr, strlen($data), bin2hex($data));
}
?>

参见

  • radius_put_attr
  • radius_get_vendor_attr
  • radius_put_vendor_attr
  • radius_send_request

radius_get_tagged_attr_data

Extracts the data from a tagged attribute

说明

string radius_get_tagged_attr_data ( string $data )

If a tagged attribute has been returned from radius_get_attr, radius_get_tagged_attr_data will return the data from the attribute.

参数

data
The tagged attribute to be decoded.

返回值

Returns the data from the tagged attribute 或者在失败时返回 FALSE.

范例

示例 #1 radius_get_tagged_attr_data example

<?php
while ($resa = radius_get_attr($res)) {
    if (!is_array($resa)) {
        printf ("Error getting attribute: %s\n",  radius_strerror($res));
        exit;
    }

    $attr = $resa['attr'];
    $data = $resa['data'];

    $tag = radius_get_tagged_attr_tag($data);
    $value = radius_get_tagged_attr_data($data);

    printf("Got tagged attribute with tag %d and value %s\n", $tag, $value);
}
?>

参见

  • radius_get_attr
  • radius_get_tagged_attr_tag

radius_get_tagged_attr_tag

Extracts the tag from a tagged attribute

说明

int radius_get_tagged_attr_tag ( string $data )

If a tagged attribute has been returned from radius_get_attr, radius_get_tagged_attr_data will return the tag from the attribute.

参数

data
The tagged attribute to be decoded.

返回值

Returns the tag from the tagged attribute 或者在失败时返回 FALSE.

范例

示例 #1 radius_get_tagged_attr_tag example

<?php
while ($resa = radius_get_attr($res)) {
    if (!is_array($resa)) {
        printf ("Error getting attribute: %s\n",  radius_strerror($res));
        exit;
    }

    $attr = $resa['attr'];
    $data = $resa['data'];

    $tag = radius_get_tagged_attr_tag($data);
    $value = radius_get_tagged_attr_data($data);

    printf("Got tagged attribute with tag %d and value %s\n", $tag, $value);
}
?>

参见

  • radius_get_attr
  • radius_get_tagged_attr_data

radius_get_vendor_attr

Extracts a vendor specific attribute

说明

array radius_get_vendor_attr ( string $data )

If radius_get_attr returns RADIUS_VENDOR_SPECIFIC, radius_get_vendor_attr may be called to determine the vendor.

返回值

Returns an associative array containing the attribute-type, vendor and the data, or FALSE on error.

范例

示例 #1 radius_get_vendor_attr example

<?php
while ($resa = radius_get_attr($res)) {

    if (!is_array($resa)) {
        printf ("Error getting attribute: %s\n",  radius_strerror($res));
        exit;
    }

    $attr = $resa['attr'];
    $data = $resa['data'];
    printf("Got Attr:%d %d Bytes %s\n", $attr, strlen($data), bin2hex($data));
    if ($attr == RADIUS_VENDOR_SPECIFIC) {

        $resv = radius_get_vendor_attr($data);
        if (is_array($resv)) {
            $vendor = $resv['vendor'];
            $attrv = $resv['attr'];
            $datav = $resv['data'];    
            printf("Got Vendor Attr:%d %d Bytes %s\n", $attrv, strlen($datav), bin2hex($datav));
        }
        
    }
}
?>

参见

  • radius_get_attr
  • radius_put_vendor_attr

radius_put_addr

Attaches an IP address attribute

说明

bool radius_put_addr ( resource $radius_handle , int $type , string $addr [, int $options = 0 [, int $tag ]] )

Attaches an IP address attribute to the current RADIUS request.

Note:

A request must be created via class="function">radius_create_request before this function can be called.

参数

radius_handle
The RADIUS resource.

type
The attribute type.

addr
An IPv4 address in string form, such as 10.0.0.1.

options
A bitmask of the attribute options. The available options include RADIUS_OPTION_TAGGED and RADIUS_OPTION_SALT.

tag
The attribute tag. This parameter is ignored unless the RADIUS_OPTION_TAGGED option is set.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

更新日志

版本说明
PECL radius 1.3.0The options and tag parameters were added.

radius_put_attr

Attaches a binary attribute

说明

bool radius_put_attr ( resource $radius_handle , int $type , string $value [, int $options = 0 [, int $tag ]] )

Attaches a binary attribute to the current RADIUS request.

Note:

A request must be created via class="function">radius_create_request before this function can be called.

参数

radius_handle
The RADIUS resource.

type
The attribute type.

value
The attribute value, which will be treated as a raw binary string.

options
A bitmask of the attribute options. The available options include RADIUS_OPTION_TAGGED and RADIUS_OPTION_SALT.

tag
The attribute tag. This parameter is ignored unless the RADIUS_OPTION_TAGGED option is set.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 radius_put_attr example

<?php
mt_srand(time());
$chall = mt_rand();
$chapval = md5(pack('Ca*',1 , 'sepp' . $chall));
$pass = pack('CH*', 1, $chapval);
if (!radius_put_attr($res, RADIUS_CHAP_PASSWORD, $pass)) {
    echo 'RadiusError:' . radius_strerror($res). "\n<br />";
    exit;
}
?>

更新日志

版本说明
PECL radius 1.3.0The options and tag parameters were added.

参见

  • radius_get_attr
  • radius_get_vendor_attr
  • radius_put_vendor_attr

radius_put_int

Attaches an integer attribute

说明

bool radius_put_int ( resource $radius_handle , int $type , int $value [, int $options = 0 [, int $tag ]] )

Attaches an integer attribute to the current RADIUS request.

Note:

A request must be created via class="function">radius_create_request before this function can be called.

参数

radius_handle
The RADIUS resource.

type
The attribute type.

value
The attribute value.

options
A bitmask of the attribute options. The available options include RADIUS_OPTION_TAGGED and RADIUS_OPTION_SALT.

tag
The attribute tag. This parameter is ignored unless the RADIUS_OPTION_TAGGED option is set.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

更新日志

版本说明
PECL radius 1.3.0The options and tag parameters were added.

范例

示例 #1 radius_put_int example

<?php
if (!radius_put_int($res, RAD_FRAMED_PROTOCOL, RAD_PPP)) {
   echo 'RadiusError:' . radius_strerror($res). "\n<br />";
   exit;
}
?>

参见

  • radius_put_string
  • radius_put_vendor_int
  • radius_put_vendor_string

radius_put_string

Attaches a string attribute

说明

bool radius_put_string ( resource $radius_handle , int $type , string $value [, int $options = 0 [, int $tag ]] )

Attaches a string attribute to the current RADIUS request. In general, radius_put_attr is a more useful function for attaching string attributes, as it is binary safe.

Note:

A request must be created via class="function">radius_create_request before this function can be called.

参数

radius_handle
The RADIUS resource.

type
The attribute type.

value
The attribute value. This value is expected by the underlying library to be null terminated, therefore this parameter is not binary safe.

options
A bitmask of the attribute options. The available options include RADIUS_OPTION_TAGGED and RADIUS_OPTION_SALT.

tag
The attribute tag. This parameter is ignored unless the RADIUS_OPTION_TAGGED option is set.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

更新日志

版本说明
PECL radius 1.3.0The options and tag parameters were added.

范例

示例 #1 radius_put_string example

<?php
if (!radius_put_string($res, RADIUS_USER_NAME, 'billy')) {
    echo 'RadiusError:' . radius_strerror($res). "\n<br />";
    exit;
}
?>

参见

  • radius_put_int
  • radius_put_vendor_int
  • radius_put_vendor_string

radius_put_vendor_addr

Attaches a vendor specific IP address attribute

说明

bool radius_put_vendor_addr ( resource $radius_handle , int $vendor , int $type , string $addr )

Attaches an IP address vendor specific attribute to the current RADIUS request.

Note:

A request must be created via class="function">radius_create_request before this function can be called.

参数

radius_handle
The RADIUS resource.

vendor
The vendor ID.

type
The attribute type.

addr
An IPv4 address in string form, such as 10.0.0.1.

options
A bitmask of the attribute options. The available options include RADIUS_OPTION_TAGGED and RADIUS_OPTION_SALT.

tag
The attribute tag. This parameter is ignored unless the RADIUS_OPTION_TAGGED option is set.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

更新日志

版本说明
PECL radius 1.3.0The options and tag parameters were added.

radius_put_vendor_attr

Attaches a vendor specific binary attribute

说明

bool radius_put_vendor_attr ( resource $radius_handle , int $vendor , int $type , string $value [, int $options = 0 [, int $tag ]] )

Attaches a vendor specific binary attribute to the current RADIUS request.

Note:

A request must be created via class="function">radius_create_request before this function can be called.

参数

radius_handle
The RADIUS resource.

vendor
The vendor ID.

type
The attribute type.

value
The attribute value, which will be treated as a raw binary string.

options
A bitmask of the attribute options. The available options include RADIUS_OPTION_TAGGED and RADIUS_OPTION_SALT.

tag
The attribute tag. This parameter is ignored unless the RADIUS_OPTION_TAGGED option is set.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

更新日志

版本说明
PECL radius 1.3.0The options and tag parameters were added.

范例

示例 #1 radius_put_vendor_attr example

<?php
if (!radius_put_vendor_attr($res, RADIUS_VENDOR_MICROSOFT, RAD_MICROSOFT_MS_CHAP_CHALLENGE, $challenge)) {
    echo 'RadiusError:' . radius_strerror($res). "\n<br />";
    exit;
}
?>

参见

  • radius_get_vendor_attr

radius_put_vendor_int

Attaches a vendor specific integer attribute

说明

bool radius_put_vendor_int ( resource $radius_handle , int $vendor , int $type , int $value [, int $options = 0 [, int $tag ]] )

Attaches a vendor specific integer attribute to the current RADIUS request.

Note:

A request must be created via class="function">radius_create_request before this function can be called.

参数

radius_handle
The RADIUS resource.

vendor
The vendor ID.

type
The attribute type.

value
The attribute value.

options
A bitmask of the attribute options. The available options include RADIUS_OPTION_TAGGED and RADIUS_OPTION_SALT.

tag
The attribute tag. This parameter is ignored unless the RADIUS_OPTION_TAGGED option is set.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

更新日志

版本说明
PECL radius 1.3.0The options and tag parameters were added.

参见

  • radius_put_vendor_string

radius_put_vendor_string

Attaches a vendor specific string attribute

说明

bool radius_put_vendor_string ( resource $radius_handle , int $vendor , int $type , string $value [, int $options = 0 [, int $tag ]] )

Attaches a vendor specific string attribute to the current RADIUS request. In general, radius_put_vendor_attr is a more useful function for attaching string attributes, as it is binary safe.

Note:

A request must be created via class="function">radius_create_request before this function can be called.

参数

radius_handle
The RADIUS resource.

vendor
The vendor ID.

type
The attribute type.

value
The attribute value. This value is expected by the underlying library to be null terminated, therefore this parameter is not binary safe.

options
A bitmask of the attribute options. The available options include RADIUS_OPTION_TAGGED and RADIUS_OPTION_SALT.

tag
The attribute tag. This parameter is ignored unless the RADIUS_OPTION_TAGGED option is set.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

更新日志

版本说明
PECL radius 1.3.0The options and tag parameters were added.

参见

  • radius_put_vendor_int

radius_request_authenticator

Returns the request authenticator

说明

string radius_request_authenticator ( resource $radius_handle )

The request authenticator is needed for demangling mangled data like passwords and encryption-keys.

返回值

Returns the request authenticator as string, or FALSE on error.

参见

  • radius_demangle

radius_salt_encrypt_attr

Salt-encrypts a value

说明

string radius_salt_encrypt_attr ( resource $radius_handle , string $data )

Applies the RADIUS salt-encryption algorithm to the given value.

In general, this is achieved automatically by providing the RADIUS_OPTION_SALT option to an attribute setter function, but this function can be used if low-level request construction is required.

参数

data
The data to be salt-encrypted.

返回值

Returns the salt-encrypted data 或者在失败时返回 FALSE.

参见

  • radius_put_addr
  • radius_put_attr
  • radius_put_int
  • radius_put_string

radius_send_request

Sends the request and waits for a reply

说明

int radius_send_request ( resource $radius_handle )

After the Radius request has been constructed, it is sent by radius_send_request.

The radius_send_request function sends the request and waits for a valid reply, retrying the defined servers in round-robin fashion as necessary.

返回值

If a valid response is received, radius_send_request returns the Radius code which specifies the type of the response. This will typically be RADIUS_ACCESS_ACCEPT, RADIUS_ACCESS_REJECT, or RADIUS_ACCESS_CHALLENGE. If no valid response is received, radius_send_request returns FALSE.

参见

  • radius_create_request

radius_server_secret

Returns the shared secret

说明

string radius_server_secret ( resource $radius_handle )

The shared secret is needed as salt for demangling mangled data like passwords and encryption-keys.

返回值

Returns the server's shared secret as string, or FALSE on error.

radius_strerror

Returns an error message

说明

string radius_strerror ( resource $radius_handle )

If Radius-functions fail then they record an error message. This error message can be retrieved with this function.

返回值

Returns error messages as string from failed radius functions.

目录