private SnmpPduPacket checkAcl(SnmpPduPacket pdu){
  SnmpPduPacket response=null;
  String community=new String(pdu.community);
  if (ipacl != null) {
    if (pdu.type == SnmpDefinitions.pduSetRequestPdu) {
      if (!ipacl.checkWritePermission(pdu.address,community)) {
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
          SNMP_ADAPTOR_LOGGER.logp(Level.FINER,dbgTag,"checkAcl","sender is " + pdu.address + " with "+ community+ ". Sender has no write permission");
        }
        int err=SnmpSubRequestHandler.mapErrorStatus(SnmpDefinitions.snmpRspAuthorizationError,pdu.version,pdu.type);
        response=newErrorResponsePdu(pdu,err,0);
      }
 else {
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
          SNMP_ADAPTOR_LOGGER.logp(Level.FINER,dbgTag,"checkAcl","sender is " + pdu.address + " with "+ community+ ". Sender has write permission");
        }
      }
    }
 else {
      if (!ipacl.checkReadPermission(pdu.address,community)) {
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
          SNMP_ADAPTOR_LOGGER.logp(Level.FINER,dbgTag,"checkAcl","sender is " + pdu.address + " with "+ community+ ". Sender has no read permission");
        }
        int err=SnmpSubRequestHandler.mapErrorStatus(SnmpDefinitions.snmpRspAuthorizationError,pdu.version,pdu.type);
        response=newErrorResponsePdu(pdu,err,0);
        SnmpAdaptorServer snmpServer=(SnmpAdaptorServer)adaptorServer;
        snmpServer.updateErrorCounters(SnmpDefinitions.snmpRspNoSuchName);
      }
 else {
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
          SNMP_ADAPTOR_LOGGER.logp(Level.FINER,dbgTag,"checkAcl","sender is " + pdu.address + " with "+ community+ ". Sender has read permission");
        }
      }
    }
  }
  if (response != null) {
    SnmpAdaptorServer snmpServer=(SnmpAdaptorServer)adaptorServer;
    snmpServer.incSnmpInBadCommunityUses(1);
    if (ipacl.checkCommunity(community) == false)     snmpServer.incSnmpInBadCommunityNames(1);
  }
  return response;
}

private SnmpPduPacket checkAcl ( SnmpPduPacket pdu ) { SnmpPduPacket response = null ; String community = new String ( pdu . community ) ; if ( ipacl != null ) { if ( pdu . type == SnmpDefinitions . pduSetRequestPdu ) { if ( ! ipacl . checkWritePermission ( pdu . address , community ) ) { if ( SNMP_ADAPTOR_LOGGER . isLoggable ( Level . FINER ) ) { SNMP_ADAPTOR_LOGGER . logp ( Level . FINER , dbgTag , "checkAcl" , "sender is " + pdu . address + " with " + community + ". Sender has no write permission" ) ; } int err = SnmpSubRequestHandler . mapErrorStatus ( SnmpDefinitions . snmpRspAuthorizationError , pdu . version , pdu . type ) ; response = newErrorResponsePdu ( pdu , err , 0 ) ; } else { if ( SNMP_ADAPTOR_LOGGER . isLoggable ( Level . FINER ) ) { SNMP_ADAPTOR_LOGGER . logp ( Level . FINER , dbgTag , "checkAcl" , "sender is " + pdu . address + " with " + community + ". Sender has write permission" ) ; } } } else { if ( ! ipacl . checkReadPermission ( pdu . address , community ) ) { if ( SNMP_ADAPTOR_LOGGER . isLoggable ( Level . FINER ) ) { SNMP_ADAPTOR_LOGGER . logp ( Level . FINER , dbgTag , "checkAcl" , "sender is " + pdu . address + " with " + community + ". Sender has no read permission" ) ; } int err = SnmpSubRequestHandler . mapErrorStatus ( SnmpDefinitions . snmpRspAuthorizationError , pdu . version , pdu . type ) ; response = newErrorResponsePdu ( pdu , err , 0 ) ; SnmpAdaptorServer snmpServer = ( SnmpAdaptorServer ) adaptorServer ; snmpServer . updateErrorCounters ( SnmpDefinitions . snmpRspNoSuchName ) ; } else { if ( SNMP_ADAPTOR_LOGGER . isLoggable ( Level . FINER ) ) { SNMP_ADAPTOR_LOGGER . logp ( Level . FINER , dbgTag , "checkAcl" , "sender is " + pdu . address + " with " + community + ". Sender has read permission" ) ; } } } } if ( response != null ) { SnmpAdaptorServer snmpServer = ( SnmpAdaptorServer ) adaptorServer ; snmpServer . incSnmpInBadCommunityUses ( 1 ) ; if ( ipacl . checkCommunity ( community ) == false ) snmpServer . incSnmpInBadCommunityNames ( 1 ) ; } return response ; }
check if the specified pdu is conform to the acl . this method returns null if the pdu is ok . if not , it returns the response pdu to be replied .
