NAME
Net::SAP::Packet - A SAP Packet
SYNOPSIS
use Net::SAP::Packet;
my $packet = new Net::SAP::Packet();
$packet->type( 'advertisement' );
$packet->compressed( 0 );
$packet->payload( $sdp_data );
DESCRIPTION
The Net::SAP::Packet
class represents a single SAP Packet. It provides methods for getting and setting the properties of the packet.
METHODS
- new( [$binary_data] )
-
Creates a new
Net::SAP::Packet
object with default values for all the properties. Takes an optional parameter which is passed straight toparse()
if given. - parse( $binary_data )
-
Parses a binary packet (as received from the network) and stores its data in the object. Returns non-zero if the binary data is invalid.
- generate()
-
Generates a binary packet from the properties stored in the perl object. Returned undefined if there is a problem creating the packet. This method also calculates the message id hash field for the packet and compresses it if the
compressed()
field is set. - origin_address_type()
-
Get or Set the family of the origin address (either ipv4 or ipv6).
Example:
$type = $packet->origin_address_type(); $packet->origin_address_type( 'ipv6' );
- origin_address()
-
Get or Set the origin address (IPv4 or IPv6 address of the host sending the packet). Be sure to also set the address type using
origin_address_type()
.Example:
$origin = $packet->origin_address(); $packet->origin_address( '152.78.104.83' );
- compressed()
-
Get or Set wether the packet was, or should be compressed. Note that the payload of the SAP packet should be no more than 1024 bytes. So compression should be used is the raw data is more than that.
Example:
$compressed = $packet->compressed(); $packet->compressed( 1 );
- type()
-
Get or Set the packet type - advertisement or deletion. A delete packet is used to instruct clients that a previously advertised session is now no longer valid.
Example:
$type = $packet->type(); $packet->type( 'advertisement' ); $packet->type( 'deletion' );
- version()
-
Get the SAP version number of a received packet. Usually 1 or 0. See the end of RFC2974 for a description of the difference between packet versions. All packets created using
Net::SAP
are version 1. - message_id_hash()
-
Get the Message ID Hash for the packet. The hash for a new packet is calculated when calling
generate()
. The hash is a 16-bit unsigned integer (0 to 65535). - encrypted()
-
Gets whether a packet is encrypted or not. Note that
Net::SAP
can't currently encrypt or de-crypt packets. - encryption_key_length()
-
Gets the length of the packet's encryption key. Note that
Net::SAP
can't currently encrypt or decrypt packets. - encryption_key()
-
Gets the encryption key for a packet. Returns undefined value if there is no encryption key for the packet. Note that
Net::SAP
can't currently encrypt or de-crypt packets. - payload_type()
-
Get or Set the packet's payload type. This field should be a MIME type. The default MIME type for packets is 'application/sdp'.
Example:
$mime = $packet->payload_type(); $packet->payload_type( 'application/sdp' );
- payload()
-
Get or Set the packet's payload.
Example:
$payload = $packet->payload(); $packet->payload( $sdp_data );
SEE ALSO
http://www.ietf.org/rfc/rfc2974.txt
BUGS
Please report any bugs or feature requests to bug-net-sap@rt.cpan.org
, or through the web interface at http://rt.cpan.org. I will be notified, and then you will automatically be notified of progress on your bug as I make changes.
AUTHOR
Nicholas Humfrey, njh@ecs.soton.ac.uk
COPYRIGHT AND LICENSE
Copyright (C) 2004-2006 University of Southampton
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.005 or, at your option, any later version of Perl 5 you may have available.