source: A2P/a2p/AFPDS/MODCA/EOC.pm @ 3

Last change on this file since 3 was 3, checked in by guillaume, 16 years ago
  • AUTHORS: Ajout des différents contributeurs
  • COPYING: Ajout de la licence GPL v3
  • a2p: Préparation des sources pour leur publication sous GPL
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1#
2# Copyright (c) 2004-2007 - Consultas, PKG.fr
3#
4# This file is part of A2P.
5#
6# A2P is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# A2P is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with A2P; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19#
20# $Id: EOC.pm 3 2007-10-18 16:20:19Z guillaume $
21#
22# Class to export End Object Container members
23#
24# cf ref #2, p. 164
25#
26
27package AFPDS::MODCA::EOC ;
28
29use strict ;
30use A2P::Globals ;
31use A2P::Syslog ;
32use AFPDS::MODCA::Common ;
33
34BEGIN {
35    our $VERSION = sprintf "%s", q$Rev: 1007 $ =~ /([0-9.]+)\s+/ ;
36}
37our $VERSION ;
38our @ISA = ("AFPDS::MODCA");
39our $IDENTS ;
40
41sub _ID { 0xD3A992 }
42
43sub _supported_triplets {
44    return [], [
45            # 0x02 # Only X'02' FQN triplet should be supported
46        ];
47}
48
49sub new {
50    my $class = shift ;
51    &Debug("new " . __PACKAGE__ . " v$VERSION object");
52
53    my $self = {
54        FLUX     => 0,        # Associated flux
55        IDENT    => _ID,      # MO:DCA identity
56        FLAG     => 0,        # MO:DCA flags
57        RESERVED => 0,        # MO:DCA reserved
58        LONG     => 0,        # MO:DCA buffer length
59        BUFFER   => ''        # MO:DCA content buffer
60    };
61
62    return bless $self , $class ;
63}
64
65sub validate {
66    my $self = shift ;
67
68    &Debug("Found EOC to close integrated resource");
69    &UPSTAT('GET-COMPLETED-RESOURCE');
70
71    # Check FLUX is a Flux object
72    return ( 251, "EOC needs to be used with Flux object" )
73        unless ( ref($self->{FLUX}) =~ /^AFPDS::Flux$/ );
74
75    return () ;
76}
77
78sub create {
79    my $self = shift ;
80    my $resname = "" ;
81    my @err = () ;
82
83    if ( $self->{LONG} ) {
84        # Set resource name
85        $resname = substr( $self->{BUFFER}, 0, 8 );
86        $resname = $self->convert( $resname );
87
88        # Analyse authorized triplets if needed
89        @err = $self->check_triplets(substr( $self->{BUFFER}, 8 ))
90            if ( $self->{LONG} > 8 );
91
92        return @err if @err ;
93    }
94
95    # Check container is opened in flux
96    my $flux = $self->{FLUX} ;
97    my $container = $flux->get_resource($resname);
98    return ( 252, $resname ?
99        "Resource '$resname' not available" : "No resource available to close" )
100        unless ( $container and ref($container) =~ /^AFPDS::MODCA/ );
101
102    # Validate the expected structure, see BOC
103    my $struct = $container->{STRUCT} || 0 ;
104    return ( 253, "Unexpected '$struct' structure found for BOC object" )
105        unless ( $struct == 0xDC00 );
106
107    # At that time, just initialize a resource using counter
108    $container->{USED} = 0 ;
109
110    # Unselect resource in flux
111    $flux->set_resource(undef);
112
113    return @err ;
114}
115
116&Debug("Module " . __PACKAGE__ . " v$VERSION loaded");
117
118( $IDENTS->{&_ID} ) = __PACKAGE__ =~ /(\w+)$/ ;
Note: See TracBrowser for help on using the repository browser.