⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snmpproperty.java

📁 纯java的SNMPv1/v2协议实现,并在其基础上进行封装以便于使用.
💻 JAVA
字号:
package yww.snmpif;
/**
 * 保存SNMP属性
 * @author Administrator
 *
 */
public class SnmpProperty {

	private String ipAddress;
	private String community;
	private String writeCommunity;
	private int port;
	private int timeout;
	private int version;
	
	/**
	 * 构建SnmpPorperty
	 * </br>设置SNMP属性默认值
	 * </br>community = "public";
	 * </br>writeCommunity = "private";
	 * </br>port = 161;
	 * </br>timeout = 5000;
	 * </br>version  = 0;
	 */
	public SnmpProperty()
	{
		community = "public";
		writeCommunity = "private";
		port = 161;
		timeout = 5000;
		version  = 0;
	}
	
	/**
	 * 获得只读共同体名
	 * @return 只读共同体名
	 */
	public String getCommunity() {
		return community;
	}
	
	/**
	 * 设置只读共同体名
	 * @param community
	 */
	public void setCommunity(String community) {
		this.community = community;
	}
	
	/**
	 * 获得IP地址
	 * @return IP地址
	 */
	public String getIpAddress() {
		return ipAddress;
	}
	
	/**
	 * 设置IP地址
	 * @param ipAddress
	 */
	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}
	
	/**
	 * 获得SNMP端口
	 * @return SNMP端口
	 */
	public int getPort() {
		return port;
	}
	
	/**
	 * 设置SNMP端口
	 * @param port
	 */
	public void setPort(int port) {
		this.port = port;
	}
	
	/**
	 * 获得超时时间
	 * @return 超时时间(ms)
	 */
	public int getTimeout() {
		return timeout;
	}
	
	/**
	 * 设置超时时间 单位(ms)
	 * @param timeout
	 */
	public void setTimeout(int timeout) {
		this.timeout = timeout;
	}
	
	/**
	 * 获得版本号,版本号参考RFC1157和RFC1901中的定义
	 * RFC1157-SNMP DEFINITIONS

     IMPORTS FROM RFC1155-SMI;

     -- top-level message

             Message ::=
                     SEQUENCE {
                          version        -- version-1 for this RFC
                             INTEGER {
                                 version-1(0)
                             },

                         community      -- community name
                             OCTET STRING,

                         data           -- e.g., PDUs if trivial
                             ANY        -- authentication is being used
                     }
                     
                     
  -- From RFC 1901:
  
  COMMUNITY-BASED-SNMPv2 DEFINITIONS ::= BEGIN

    -- top-level message

        Message ::=
                SEQUENCE {
                     version
                        INTEGER {
                            version(1)  -- modified from RFC 1157
                        },

                    community           -- community name
                        OCTET STRING,

                    data                -- PDUs as defined in [4]
                        ANY
                }
        }

    END                   
	 * @return 版本号
	 */
	public int getVersion() {
		return version;
	}
	
	/**
	 * 设置版本号,版本号见getVersion()
	 * @param version
	 */
	public void setVersion(int version) {
		this.version = version;
	}
	
	/**
	 * 获得读写共同体名
	 * @return 读写共同体名
	 */
	public String getWriteCommunity() {
		return writeCommunity;
	}
	
	/**
	 * 设置读写共同体名
	 * @param writeCommunity
	 */
	public void setWriteCommunity(String writeCommunity) {
		this.writeCommunity = writeCommunity;
	}
	
	/**
	 * 根据RFC1157和RFC1901中定义设定.
	 */
	public static int SNMPv1 = 0;
	public static int SNMPv2 = 1;
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -