• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SnmpVarBind类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.jmx.snmp.SnmpVarBind的典型用法代码示例。如果您正苦于以下问题:Java SnmpVarBind类的具体用法?Java SnmpVarBind怎么用?Java SnmpVarBind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SnmpVarBind类属于com.sun.jmx.snmp包,在下文中一共展示了SnmpVarBind类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: splitFrom

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * This method creates a new Vector which does not contain the first
 * element up to the specified limit.
 *
 * @param original The original vector.
 * @param limit The limit.
 */
private Vector<SnmpVarBind> splitFrom(Vector<SnmpVarBind> original, int limit) {

    int max= original.size();
    Vector<SnmpVarBind> result= new Vector<>(max - limit);
    int i= limit;

    // Ok the loop looks a bit strange. But in order to improve the
    // perf, we try to avoid reference to the limit variable from
    // within the loop ...
    //
    for(Enumeration<SnmpVarBind> e= original.elements(); e.hasMoreElements(); --i) {
        SnmpVarBind var= e.nextElement();
        if (i >0)
            continue;
        result.addElement(new SnmpVarBind(var.oid, var.value));
    }
    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:SnmpMibAgent.java


示例2: newMibRequest

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * This is a factory method for creating new SnmpMibRequest objects.
 * @param engine The local engine.
 * @param reqPdu The received pdu.
 * @param vblist The vector of SnmpVarBind objects in which the
 *        MIB concerned by this request is involved.
 * @param version The protocol version of the SNMP request.
 * @param userData User allocated contextual data.
 *
 * @return A new SnmpMibRequest object.
 *
 * @since 1.5
 **/
public static SnmpMibRequest newMibRequest(SnmpEngine engine,
                                           SnmpPdu reqPdu,
                                           Vector<SnmpVarBind> vblist,
                                           int version,
                                           Object userData,
                                           String principal,
                                           int securityLevel,
                                           int securityModel,
                                           byte[] contextName,
                                           byte[] accessContextName) {
    return new SnmpMibRequestImpl(engine,
                                  reqPdu,
                                  vblist,
                                  version,
                                  userData,
                                  principal,
                                  securityLevel,
                                  securityModel,
                                  contextName,
                                  accessContextName);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:SnmpMibAgent.java


示例3: registerCheckException

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
@Override
public void registerCheckException(SnmpVarBind var,
                                   SnmpStatusException exception)
    throws SnmpStatusException {
    // The index in the exception must correspond to
    // the SNMP index ...
    //
    // We throw the exception in order to abort the SET operation
    // in an atomic way.
    final int errorCode = exception.getStatus();
    final int mappedErrorCode = mapSetException(errorCode,
                                                version);

    if (errorCode != mappedErrorCode)
        throw new
            SnmpStatusException(mappedErrorCode, getVarIndex(var)+1);
    else
        throw new SnmpStatusException(exception, getVarIndex(var)+1);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:SnmpRequestTree.java


示例4: init

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
private void init(SnmpAdaptorServer server,
                  SnmpPdu req,
                  int nonRepeat,
                  int maxRepeat,
                  int R) {
    this.server = server;
    this.nonRepeat= nonRepeat;
    this.maxRepeat= maxRepeat;
    this.globalR= R;

    final int max= translation.length;
    final SnmpVarBind[] list= req.varBindList;
    final NonSyncVector<SnmpVarBind> nonSyncVarBind =
            ((NonSyncVector<SnmpVarBind>)varBind);
    for(int i=0; i < max; i++) {
        translation[i]= i;
        // we need to allocate a new SnmpVarBind. Otherwise the first
        // sub request will modify the list...
        //
        final SnmpVarBind newVarBind =
            new SnmpVarBind(list[i].oid, list[i].value);
        nonSyncVarBind.addNonSyncElement(newVarBind);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:SnmpSubBulkRequestHandler.java


示例5: registerSetException

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
@Override
public void registerSetException(SnmpVarBind var,
                                 SnmpStatusException exception)
    throws SnmpStatusException {
    // The index in the exception must correspond to
    // the SNMP index ...
    //
    if (version == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(exception, getVarIndex(var)+1);

    // Although the first pass of check() did not fail,
    // the set() phase could not be carried out correctly.
    // Since we don't know how to make an "undo", and some
    // assignation may already have been performed, we're going
    // to throw an snmpRspUndoFailed.
    //
    throw new SnmpStatusException(SnmpDefinitions.snmpRspUndoFailed,
                                  getVarIndex(var)+1);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:SnmpRequestTree.java


示例6: mergeBulkResponses

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
private SnmpVarBind[] mergeBulkResponses(int size) {
    // Let's allocate the array for storing the result
    //
    SnmpVarBind[] result= new SnmpVarBind[size];
    for(int i= size-1; i >=0; --i) {
        result[i]= new SnmpVarBind();
        result[i].value= SnmpVarBind.endOfMibView;
    }

    // Go through the list of subrequests and concatenate.
    // Hopefully, by now all the sub-requests should be finished
    //
    for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) {
        SnmpSubRequestHandler sub= e.nextElement();
        sub.updateResult(result);
    }

    return result;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:SnmpRequestHandler.java


示例7: newValidResponsePdu

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * Make a response pdu with the specified error status and index.
 * NOTE: the response pdu share its varBindList with the request pdu.
 */
private SnmpPduRequest newValidResponsePdu(SnmpPduPacket reqPdu,
                                           SnmpVarBind[] varBindList) {
    SnmpPduRequest result = new SnmpPduRequest() ;

    result.address = reqPdu.address ;
    result.port = reqPdu.port ;
    result.version = reqPdu.version ;
    result.community = reqPdu.community ;
    result.type = SnmpPduRequest.pduGetResponsePdu ;
    result.requestId = reqPdu.requestId ;
    result.errorStatus = SnmpDefinitions.snmpRspNoError ;
    result.errorIndex = 0 ;
    result.varBindList = varBindList ;

    ((SnmpAdaptorServer)adaptorServer).
        updateErrorCounters(result.errorStatus) ;

    return result ;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:SnmpRequestHandler.java


示例8: SnmpMibRequestImpl

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * @param engine The local engine.
 * @param reqPdu The received pdu.
 * @param vblist The vector of SnmpVarBind objects in which the
 *        MIB concerned by this request is involved.
 * @param protocolVersion  The protocol version of the SNMP request.
 * @param userData     User allocated contextual data. This object must
 *        be allocated on a per SNMP request basis through the
 *        SnmpUserDataFactory registered with the SnmpAdaptorServer,
 *        and is handed back to the user through SnmpMibRequest objects.
 */
public SnmpMibRequestImpl(SnmpEngine engine,
                          SnmpPdu reqPdu,
                          Vector<SnmpVarBind> vblist,
                          int protocolVersion,
                          Object userData,
                          String principal,
                          int securityLevel,
                          int securityModel,
                          byte[] contextName,
                          byte[] accessContextName) {
    varbinds   = vblist;
    version    = protocolVersion;
    data       = userData;
    this.reqPdu = reqPdu;
    this.engine = engine;
    this.principal = principal;
    this.securityLevel = securityLevel;
    this.securityModel = securityModel;
    this.contextName = contextName;
    this.accessContextName = accessContextName;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:SnmpMibRequestImpl.java


示例9: get

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * Processes a <CODE>get</CODE> operation. It will throw an exception for V1 requests or it will set exceptions within the list for V2 requests.
 *
 * @param inRequest The SnmpMibRequest object holding the list of variable to be retrieved.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */

@Override
public void get(SnmpMibRequest inRequest) throws SnmpStatusException {

    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
            SnmpErrorHandlerAgent.class.getName(),
            "get", "Get in Exception");

    if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(SnmpStatusException.noSuchName);

    Enumeration<SnmpVarBind> l = inRequest.getElements();
    while(l.hasMoreElements()) {
        SnmpVarBind varbind = l.nextElement();
        varbind.setNoSuchObject();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:SnmpErrorHandlerAgent.java


示例10: getNext

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * Processes a <CODE>getNext</CODE> operation. It will throw an exception for V1 requests or it will set exceptions within the list for V2 requests..
 *
 * @param inRequest The SnmpMibRequest object holding the list of variables to be retrieved.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */

@Override
public void getNext(SnmpMibRequest inRequest) throws SnmpStatusException {

    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
            SnmpErrorHandlerAgent.class.getName(),
            "getNext", "GetNext in Exception");

    if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(SnmpStatusException.noSuchName);

    Enumeration<SnmpVarBind> l = inRequest.getElements();
    while(l.hasMoreElements()) {
        SnmpVarBind varbind = l.nextElement();
        varbind.setEndOfMibView();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:SnmpErrorHandlerAgent.java


示例11: getBulk

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * Processes a <CODE>getBulk</CODE> operation. It will throw an exception if the request is a V1 one or it will set exceptions within the list for V2 ones.
 *
 * @param inRequest The SnmpMibRequest object holding the list of variable to be retrieved.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */

@Override
public void getBulk(SnmpMibRequest inRequest, int nonRepeat, int maxRepeat)
    throws SnmpStatusException {

    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
            SnmpErrorHandlerAgent.class.getName(),
            "getBulk", "GetBulk in Exception");

    if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
        throw new SnmpStatusException(SnmpDefinitions.snmpRspGenErr, 0);

    Enumeration<SnmpVarBind> l = inRequest.getElements();
    while(l.hasMoreElements()) {
        SnmpVarBind varbind = l.nextElement();
        varbind.setEndOfMibView();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:SnmpErrorHandlerAgent.java


示例12: init

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
private void init(SnmpPdu req, SnmpAdaptorServer server) {
    this.server = server;

    // The translation table is easy in this case ...
    //
    final int max= translation.length;
    final SnmpVarBind[] list= req.varBindList;
    final NonSyncVector<SnmpVarBind> nonSyncVarBind =
            ((NonSyncVector<SnmpVarBind>)varBind);
    for(int i=0; i < max; i++) {
        translation[i]= i;
        // we need to allocate a new SnmpVarBind. Otherwise the first
        // sub request will modify the list...
        //
        final SnmpVarBind newVarBind =
            new SnmpVarBind(list[i].oid, list[i].value);
        nonSyncVarBind.addNonSyncElement(newVarBind);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:SnmpSubNextRequestHandler.java


示例13: makeErrorVarbindPdu

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
SnmpPduPacket makeErrorVarbindPdu(SnmpPduPacket req, int statusTag) {

        final SnmpVarBind[] vblist = req.varBindList;
        final int length = vblist.length;

        switch (statusTag) {
        case SnmpDataTypeEnums.errEndOfMibViewTag:
            for (int i=0 ; i<length ; i++)
                vblist[i].value = SnmpVarBind.endOfMibView;
            break;
        case SnmpDataTypeEnums.errNoSuchObjectTag:
            for (int i=0 ; i<length ; i++)
                vblist[i].value = SnmpVarBind.noSuchObject;
            break;
        case SnmpDataTypeEnums.errNoSuchInstanceTag:
            for (int i=0 ; i<length ; i++)
                vblist[i].value = SnmpVarBind.noSuchInstance;
            break;
        default:
            return newErrorResponsePdu(req,snmpRspGenErr,1);
        }
        return newValidResponsePdu(req,vblist);
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:SnmpRequestHandler.java


示例14: SnmpSubRequestHandler

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * SNMP V1/V2 The constructor initialize the subrequest with the whole varbind list contained
 * in the original request.
 */
@SuppressWarnings("unchecked")  // cast to NonSyncVector<SnmpVarBind>
protected SnmpSubRequestHandler(SnmpMibAgent agent,
                                SnmpPdu req,
                                boolean nouse) {
    this(agent,req);

    // The translation table is easy in this case ...
    //
    int max= translation.length;
    SnmpVarBind[] list= req.varBindList;
    for(int i=0; i < max; i++) {
        translation[i]= i;
        ((NonSyncVector<SnmpVarBind>)varBind).addNonSyncElement(list[i]);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:SnmpSubRequestHandler.java


示例15: updateResult

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * The method updates a given var bind list with the result of a
 * previsouly invoked operation.
 * Prior to calling the method, one must make sure that the operation was
 * successful. As such the method getErrorIndex or getErrorStatus should be
 * called.
 */
protected void updateResult(SnmpVarBind[] result) {

    if (result == null) return;
    final int max=varBind.size();
    final int len=result.length;
    for(int i= 0; i< max ; i++) {
        // bugId 4641694: must check position in order to avoid
        //       ArrayIndexOutOfBoundException
        final int pos=translation[i];
        if (pos < len) {
            result[pos] =
                (SnmpVarBind)((NonSyncVector)varBind).elementAtNonSync(i);
        } else {
            if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
                SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(),
                    "updateResult","Position `"+pos+"' is out of bound...");
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:SnmpSubRequestHandler.java


示例16: SnmpSubRequestHandler

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * SNMP V1/V2 . To be called with updateRequest.
 */
protected SnmpSubRequestHandler(SnmpMibAgent agent, SnmpPdu req) {
    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
            "constructor", "creating instance for request " + String.valueOf(req.requestId));
    }

    version= req.version;
    type= req.type;
    this.agent= agent;

    // We get a ref on the pdu in order to pass it to SnmpMibRequest.
    reqPdu = req;

    //Pre-allocate room for storing varbindlist and translation table.
    //
    int length= req.varBindList.length;
    translation= new int[length];
    varBind= new NonSyncVector<SnmpVarBind>(length);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:SnmpSubRequestHandler.java


示例17: newMibRequest

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
 * This is a factory method for creating new SnmpMibRequest objects.
 * @param reqPdu The received PDU.
 * @param vblist   The vector of SnmpVarBind objects in which the
 *        MIB concerned by this request is involved.
 * @param version  The protocol version of the SNMP request.
 * @param userData User allocated contextual data.
 *
 * @return A new SnmpMibRequest object.
 *
 * @since 1.5
 **/
public static SnmpMibRequest newMibRequest(SnmpPdu reqPdu,
                                           Vector<SnmpVarBind> vblist,
                                           int version,
                                           Object userData)
{
    return new SnmpMibRequestImpl(null,
                                  reqPdu,
                                  vblist,
                                  version,
                                  userData,
                                  null,
                                  SnmpDefinitions.noAuthNoPriv,
                                  getSecurityModel(version),
                                  null,null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:SnmpMibAgent.java


示例18: mergeNextResponses

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
private SnmpPduPacket mergeNextResponses(SnmpPduRequest req) {
    int max= req.varBindList.length;
    SnmpVarBind[] result= new SnmpVarBind[max];

    // Go through the list of subrequests and concatenate.
    // Hopefully, by now all the sub-requests should be finished
    //
    for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) {
        SnmpSubRequestHandler sub= e.nextElement();
        sub.updateResult(result);
    }

    if (req.version == snmpVersionTwo) {
        return newValidResponsePdu(req,result);
    }

    // In v1 make sure there is no endOfMibView ...
    //
    for(int i=0; i < max; i++) {
        SnmpValue val= result[i].value;
        if (val == SnmpVarBind.endOfMibView)
            return newErrorResponsePdu(req,
                               SnmpDefinitions.snmpRspNoSuchName, i+1);
    }

    // So far so good ...
    //
    return newValidResponsePdu(req,result);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:SnmpRequestHandler.java


示例19: concatVector

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
private void concatVector(SnmpMibRequest req, Vector<SnmpVarBind> source) {
    for(Enumeration<SnmpVarBind> e= source.elements(); e.hasMoreElements(); ) {
        SnmpVarBind var= e.nextElement();
        // We need to duplicate the SnmpVarBind otherwise it is going
        // to be overloaded by the next get Next ...
        req.addVarBind(new SnmpVarBind(var.oid, var.value));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:SnmpMibAgent.java


示例20: findHandlingNode

import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
@Override
void findHandlingNode(SnmpVarBind varbind,
                      long[] oid, int depth,
                      SnmpRequestTree handlers)
    throws SnmpStatusException {


    final int length = oid.length;
    SnmpMibNode node = null;

    if (handlers == null)
        throw new SnmpStatusException(SnmpStatusException.snmpRspGenErr);

    if (depth > length) {
        // Nothing is left... the oid is not valid
        throw new SnmpStatusException(SnmpStatusException.noSuchObject);
    } else if (depth == length) {
        // The oid is not complete...
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    } else {
        // Some children variable or subobject is being querried
        // getChild() will raise an exception if no child is found.
        //
        final SnmpMibNode child= getChild(oid[depth]);

        // XXXX zzzz : what about null children?
        //             (variables for nested groups)
        // if child==null, then we're dealing with a variable or
        // a table: we register this node.
        // This behaviour should be overriden in subclasses,
        // in particular in group meta classes: the group
        // meta classes that hold tables should take care
        // of forwarding this call to all the tables involved.
        //
        if (child == null)
            handlers.add(this,depth,varbind);
        else
            child.findHandlingNode(varbind,oid,depth+1,handlers);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:SnmpMibOid.java



注:本文中的com.sun.jmx.snmp.SnmpVarBind类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RMProxy类代码示例发布时间:2022-05-22
下一篇:
Java ConverterFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap