1 20 21 22 package org.snmp4j.agent; 23 24 import org.snmp4j.*; 25 import org.snmp4j.smi.*; 26 import org.snmp4j.agent.mo.snmp.SnmpProxyMIB; 27 import org.snmp4j.agent.security.VACM; 28 import org.snmp4j.agent.request.SnmpRequest; 29 import org.snmp4j.agent.mo.snmp.CoexistenceInfo; 30 31 40 public class ProxyForwardRequest { 41 42 private CommandResponderEvent commandEvent; 43 private PDU responsePDU; 44 private CoexistenceInfo coexistenceInfo; 45 private int proxyType; 46 47 public ProxyForwardRequest(CommandResponderEvent commandEvent, 48 CoexistenceInfo coexistenceInfo) { 49 this.commandEvent = commandEvent; 50 this.coexistenceInfo = coexistenceInfo; 51 setProxyType(); 52 } 53 54 public CommandResponderEvent getCommandEvent() { 55 return commandEvent; 56 } 57 58 public void setResponsePDU(PDU responsePDU) { 59 this.responsePDU = responsePDU; 60 } 61 62 public PDU getResponsePDU() { 63 return responsePDU; 64 } 65 66 public OctetString getContextEngineID() { 67 return coexistenceInfo.getContextEngineID(); 68 } 69 70 public OctetString getContext() { 71 return coexistenceInfo.getContextName(); 72 } 73 74 public OctetString getSecurityName() { 75 return coexistenceInfo.getSecurityName(); 76 } 77 78 public CoexistenceInfo getCoexistenceInfo() { 79 return coexistenceInfo; 80 } 81 82 public int getProxyType() { 83 return proxyType; 84 } 85 86 private void setProxyType() { 87 int viewType = 88 SnmpRequest.getViewType(commandEvent.getPDU().getType()); 89 switch (viewType) { 90 case VACM.VIEW_WRITE: { 91 proxyType = SnmpProxyMIB.SnmpProxyTypeEnum.write; 92 break; 93 } 94 case VACM.VIEW_NOTIFY: { 95 if (commandEvent.getPDU().getType() == PDU.INFORM) { 96 proxyType = SnmpProxyMIB.SnmpProxyTypeEnum.inform; 97 } 98 else { 99 proxyType = SnmpProxyMIB.SnmpProxyTypeEnum.trap; 100 } 101 break; 102 } 103 default: { 104 proxyType = SnmpProxyMIB.SnmpProxyTypeEnum.read; 105 } 106 } 107 } 108 109 public String toString() { 110 return ProxyForwardRequest.class.getName()+ 111 "[coexistenceInfo="+coexistenceInfo+ 112 ",proxyType="+proxyType+ 113 ",commandEvent="+commandEvent+"]"; 114 } 115 116 } 117 | Popular Tags |