예제 #1
0
    public void sendCeaMessage(int resultCode, Message cer, String errMessage)
        throws TransportException, OverloadException {
      logger.debug("Send CEA message");

      IMessage message = parser.createEmptyMessage(Message.CAPABILITIES_EXCHANGE_ANSWER, 0);
      message.setRequest(false);
      message.setHopByHopIdentifier(cer.getHopByHopIdentifier());
      message.setEndToEndIdentifier(cer.getEndToEndIdentifier());
      message
          .getAvps()
          .addAvp(Avp.ORIGIN_HOST, metaData.getLocalPeer().getUri().getFQDN(), true, false, true);
      message
          .getAvps()
          .addAvp(Avp.ORIGIN_REALM, metaData.getLocalPeer().getRealmName(), true, false, true);
      for (InetAddress ia : metaData.getLocalPeer().getIPAddresses())
        message.getAvps().addAvp(Avp.HOST_IP_ADDRESS, ia, true, false);
      message
          .getAvps()
          .addAvp(Avp.VENDOR_ID, metaData.getLocalPeer().getVendorId(), true, false, true);

      for (ApplicationId appId : metaData.getLocalPeer().getCommonApplications())
        addAppId(appId, message);

      message.getAvps().addAvp(Avp.PRODUCT_NAME, metaData.getLocalPeer().getProductName(), false);
      message.getAvps().addAvp(Avp.RESULT_CODE, resultCode, true, false, true);
      message.getAvps().addAvp(Avp.FIRMWARE_REVISION, metaData.getLocalPeer().getFirmware(), true);
      if (errMessage != null) message.getAvps().addAvp(Avp.ERROR_MESSAGE, errMessage, false);
      sendMessage(message);
    }
  public DiameterMessage sendSyncMessage(DiameterMessage message) {
    DiameterMessage answer = null;

    Message receivedMessage = doSendMessage(message);

    if (receivedMessage != null) {
      if (!receivedMessage.isRequest()) {
        if (receivedMessage.isError()) {
          answer = new ErrorAnswerImpl(receivedMessage);
        } else {
          switch (receivedMessage.getCommandCode()) {
            case AbortSessionAnswer.commandCode:
              answer = new AbortSessionAnswerImpl(receivedMessage);
              break;
            case AccountingAnswer.commandCode:
              answer = new AccountingAnswerImpl(receivedMessage);
              break;
            case CapabilitiesExchangeAnswer.commandCode:
              answer = new CapabilitiesExchangeAnswerImpl(receivedMessage);
              break;
            case DeviceWatchdogAnswer.commandCode:
              answer = new DeviceWatchdogAnswerImpl(receivedMessage);
              break;
            case DisconnectPeerAnswer.commandCode:
              answer = new DisconnectPeerAnswerImpl(receivedMessage);
              break;
            case ReAuthAnswer.commandCode:
              answer = new ReAuthAnswerImpl(receivedMessage);
              break;
            case SessionTerminationAnswer.commandCode:
              answer = new SessionTerminationAnswerImpl(receivedMessage);
              break;
            default:
              logger.error(
                  "Received an unknown type of Message for Base Activity: " + receivedMessage);
              break;
          }
        }
      } else {
        logger.error("Received a REQUEST message when expecting an ANSWER.");
      }
    } else {
      logger.debug("No answer received. Returning null.");
    }

    return answer;
  }
 /** @param message */
 public JMultimediaAuthRequestImpl(Message message) {
   super(message);
   message.setRequest(true);
 }