View Javadoc
1   // NAME
2   //      $RCSfile: ListeningContextFace.java,v $
3   // DESCRIPTION
4   //      [given below in javadoc format]
5   // DELTA
6   //      $Revision: 3.6 $
7   // CREATED
8   //      $Date: 2006/11/29 16:12:50 $
9   // COPYRIGHT
10  //      Westhawk Ltd
11  // TO DO
12  //
13  
14  /*
15   * Copyright (C) 2005 - 2006 by Westhawk Ltd
16   * <a href="www.westhawk.co.uk">www.westhawk.co.uk</a>
17   *
18   * Permission to use, copy, modify, and distribute this software
19   * for any purpose and without fee is hereby granted, provided
20   * that the above copyright notices appear in all copies and that
21   * both the copyright notice and this permission notice appear in
22   * supporting documentation.
23   * This software is provided "as is" without express or implied
24   * warranty.
25   * author <a href="mailto:snmp@westhawk.co.uk">Tim Panton</a>
26   */
27  
28  package uk.co.westhawk.snmp.stack;
29  
30  /*-
31   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
32   * SNMP Java Client
33   * ჻჻჻჻჻჻
34   * Copyright 2023 MetricsHub, Westhawk
35   * ჻჻჻჻჻჻
36   * This program is free software: you can redistribute it and/or modify
37   * it under the terms of the GNU Lesser General Public License as
38   * published by the Free Software Foundation, either version 3 of the
39   * License, or (at your option) any later version.
40   *
41   * This program is distributed in the hope that it will be useful,
42   * but WITHOUT ANY WARRANTY; without even the implied warranty of
43   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
44   * GNU General Lesser Public License for more details.
45   *
46   * You should have received a copy of the GNU General Lesser Public
47   * License along with this program.  If not, see
48   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
49   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
50   */
51  import uk.co.westhawk.snmp.event.*;
52  
53  /**
54   * This interface contains the SNMP listening context methods.
55   *
56   * @since 4_14
57   * @author <a href="mailto:snmp@westhawk.co.uk">Birgit Arkesteijn</a>
58   * @version $Revision: 3.6 $ $Date: 2006/11/29 16:12:50 $
59   */
60  public interface ListeningContextFace {
61      static final String     version_id =
62          "@(#)$Id: ListeningContextFace.java,v 3.6 2006/11/29 16:12:50 birgit Exp $ Copyright Westhawk Ltd";
63  
64      /**
65       * The default port number where we listen for traps (162).
66       */
67      public final static int DEFAULT_TRAP_PORT = 162;
68  
69  
70  /**
71   * Returns the port number.
72   *
73   * @return The port no
74   */
75  public int getPort();
76  
77  /**
78   * Returns the local address the server will bind to
79   * When the address is null, the socket accepts connections on
80   * any/all local addresses.
81   *
82   * @return The bind address
83   */
84  public String getBindAddress();
85  
86  /**
87   * Returns the type of socket.
88   *
89   * @see SnmpContextBasisFace#STANDARD_SOCKET
90   * @see SnmpContextBasisFace#TCP_SOCKET
91   * @return The type of socket 
92   */
93  public String getTypeSocket();
94  
95  /**
96   * Returns the maximum number of bytes this context will read from the
97   * socket. By default this will be set to <code>MSS</code> (i.e. 1300).
98   *
99   * @see SnmpContextBasisFace#MSS
100  * @see #setMaxRecvSize(int)
101  * @see AbstractSnmpContext#setMaxRecvSize(int)
102  * @return The number 
103  */
104 public int getMaxRecvSize();
105 
106 /**
107  * Sets the maximum number of bytes this context will read from the
108  * socket. By default this will be set to <code>MSS</code> (i.e. 1300).
109  *
110  * @see SnmpContextBasisFace#MSS
111  * @see AbstractSnmpContext#getMaxRecvSize()
112  * @param no The new size 
113  */
114 public void setMaxRecvSize(int no);
115 
116 /**
117  * Removes the resouces held by this context. 
118  * This method will stop the thread listening for packets. 
119  */
120 public void destroy();
121 
122 /**
123  * Adds the specified PDU listener to receive the undecoded PDUs.
124  * When a PDU is received the PDU received event is fired to all 
125  * listeners, until one of them consumes it.
126  *
127  * <p>
128  * All the SnmpContext objects use this method to listen for PDUs. When
129  * a SnmpContext object decodes the PDU succesfully, it will consume
130  * it.
131  * </p>
132  *
133  * <p>
134  * Only when a listener is added will this context create a listening socket.
135  * </p>
136  *
137  * @param l The listener object
138  * @exception java.io.IOException Thrown when creating a listening
139  * socket fails
140  *
141  * @see RawPduReceivedSupport#fireRawPduReceived
142  * @see AbstractSnmpContext#addTrapListener
143  * @see AbstractSnmpContext#addRequestPduListener
144  * @see #addUnhandledRawPduListener(RawPduListener)
145  */
146 public void addRawPduListener(RawPduListener l)
147 throws java.io.IOException;
148 
149 /**
150  * Removes the specified PDU listener. When there are no more listeners,
151  * calls destroy().
152  *
153  * @param l The listener object
154  */
155 public void removeRawPduListener(RawPduListener l);
156 
157 /**
158  * Adds the specified PDU listener to receive the undecoded PDUs when
159  * it was not handled (i.e. not consumed) by any of the PDU listeners in
160  * addRawPduListener().
161  *
162  * <p>
163  * Only when a listener is added will this context create a listening socket.
164  * </p>
165  *
166  * @param listener The listener object
167  * @exception java.io.IOException Thrown when creating a listening
168  * socket fails
169  *
170  * @see #addRawPduListener(RawPduListener)
171  */
172 public void addUnhandledRawPduListener(RawPduListener listener)
173 throws java.io.IOException;
174 
175 /**
176  * Removes the specified unhandled PDU listener. When there are no more 
177  * listeners, calls destroy().
178  *
179  * @param listener The listener object
180  */
181 public void removeUnhandledRawPduListener(RawPduListener listener);
182 
183 }