5 use FS::Record qw( qsearchs );
13 FS::port - Object methods for port records
19 $record = new FS::port \%hash;
20 $record = new FS::port { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
30 $session = $port->session;
34 An FS::port object represents an individual port on a NAS. FS::port inherits
35 from FS::Record. The following fields are currently supported:
39 =item portnum - primary key
41 =item ip - IP address of this port
43 =item nasport - port number on the NAS
45 =item nasnum - NAS this port is on - see L<FS::nas>
55 Creates a new port. To add the example to the database, see L<"insert">.
57 Note that this stores the hash reference, not a distinct copy of the hash it
58 points to. You can ask the object for a copy with the I<hash> method.
62 # the new method can be inherited from FS::Record, if a table method is defined
68 Adds this record to the database. If there is an error, returns the error,
69 otherwise returns false.
73 # the insert method can be inherited from FS::Record
77 Delete this record from the database.
81 # the delete method can be inherited from FS::Record
83 =item replace OLD_RECORD
85 Replaces the OLD_RECORD with this one in the database. If there is an error,
86 returns the error, otherwise returns false.
90 # the replace method can be inherited from FS::Record
94 Checks all fields to make sure this is a valid example. If there is
95 an error, returns the error, otherwise returns false. Called by the insert
100 # the check method should currently be supplied - FS::Record contains some
101 # data checking routines
106 $self->ut_numbern('portnum')
107 || $self->ut_ipn('ip')
108 || $self->ut_numbern('nasport')
109 || $self->ut_number('nasnum');
111 return $error if $error;
112 return "Either ip or nasport must be specified"
113 unless $self->ip || $self->nasport;
114 return "Unknown nasnum"
115 unless qsearchs('nas', { 'nasnum' => $self->nasnum } );
121 Returns the currently open session on this port, or if no session is currently
122 open, the most recent session. See L<FS::session>.
128 qsearchs('session', { 'portnum' => $self->portnum }, '*',
129 'ORDER BY login DESC LIMIT 1' );
136 $Id: port.pm,v 1.5 2001-02-14 04:33:06 ivan Exp $
140 The author forgot to customize this manpage.
142 The session method won't deal well if you have multiple open sessions on a
143 port, for example if your RADIUS server drops B<stop> records. Suggestions for
144 how to deal with this sort of lossage welcome; should we close the session
145 when we get a new session on that port? Tag it as invalid somehow? Close it
146 one second after it was opened? *sigh* Maybe FS::session shouldn't let you
147 create overlapping sessions, at least folks will find out their logging is
150 If you think the above refers multiple user logins you need to read the
155 L<FS::Record>, schema.html from the base documentation.