Package org.cipango.diameter.node

Examples of org.cipango.diameter.node.DiameterMessage


    for (int i = 24; i < 256; i++)
    {
      Buffer buffer = new ByteArrayBuffer(i);
      buffer = Codecs.__message.encode(buffer, answer);
      // System.out.println(buffer.putIndex() + " / " + i);
      DiameterMessage message = Codecs.__message.decode(buffer);
      // System.out.println(message);
      assertFalse(message.isRequest());
      assertEquals(answer.getEndToEndId(), message.getEndToEndId());
      assertEquals(answer.getHopByHopId(), message.getHopByHopId());
      assertEquals(Sh.UDA, message.getCommand());
      assertEquals(Common.DIAMETER_SUCCESS.getCode(), message.get(Common.RESULT_CODE).intValue());
      assertEquals(InetAddress.getLocalHost(), message.get(Common.HOST_IP_ADDRESS));
      assertEquals("<shData>dasaiTag<shData>", new String(message.get(Sh.USER_DATA)));
    }
  }
View Full Code Here


            if (read == -1)
              throw new EofException();
            totalRead += read;
          }
                   
          DiameterMessage message = Codecs.__message.decode(b);
          message.setConnection(this);
          message.setNode(getNode());
         
          if (getNode().isStatsOn())
            _messagesReceived.incrementAndGet();
         
          // TODO move the following code at a better place. Need to be done before _listener.messageReceived(message, this);
          if (!message.isRequest())
          {
            int code;
            int vendorId = Common.IETF_VENDOR_ID;
           
            AVP<Integer> avp = message.getAVPs().get(Common.RESULT_CODE);
            if (avp != null)
            {
              code = avp.getValue();
            }
            else
            {
              AVPList expRc = message.get(Common.EXPERIMENTAL_RESULT);
              code = expRc.getValue(Common.EXPERIMENTAL_RESULT_CODE);
              vendorId = expRc.getValue(Common.VENDOR_ID);
            }
           
            ResultCode rc = Dictionary.getInstance().getResultCode(vendorId, code);
View Full Code Here

    return _buffer.toString();
  }
 
  public static void main(String[] args)
  {
    DiameterMessage message = new DiameterRequest(new Node(), Accounting.ACR, Accounting.ACCOUNTING_ORDINAL, "foo");
    message.getAVPs().add(Zh.ZH_APPLICATION_ID.getAVP());

    PrettyPrinter pp = new PrettyPrinter();
    message.accept(pp);
    System.out.println(pp);
  }
View Full Code Here

  }
 
  @Test
  public void testDecodeSAR() throws Exception
  {
    DiameterMessage message = Codecs.__message.decode(load("sar.dat"));

    assertTrue(message.isRequest());
    assertEquals(Cx.SAR, message.getCommand());
    assertEquals("scscf1.home1.net", message.get(Common.ORIGIN_HOST));
    assertEquals("home1.net", message.get(Common.ORIGIN_REALM));
   
    AVPList vsai = message.get(Common.VENDOR_SPECIFIC_APPLICATION_ID);
    assertEquals(IMS.IMS_VENDOR_ID, (int) vsai.getValue(Common.VENDOR_ID));
    assertEquals(Cx.CX_APPLICATION_ID.getId(), (int) vsai.getValue(Common.AUTH_APPLICATION_ID))
  }
View Full Code Here

   
    DiameterCommand command = isRequest ? dictionary.getRequest(code) : dictionary.getAnswer(code);
    if (command == null)
      command = isRequest ? Factory.newRequest(code, "Unknown") : Factory.newAnswer(code, "Unknown");
   
    DiameterMessage message = isRequest ? new DiameterRequest() : new DiameterAnswer();
   
    message.setApplicationId(getInt(buffer));
    message.setHopByHopId(getInt(buffer));
    message.setEndToEndId(getInt(buffer));
    message.setCommand(command);
   
    if (isRequest)
      ((DiameterRequest) message).setUac(false);
   
    message.setAVPList(Common.__grouped.decode(buffer));
    return message;
  }
View Full Code Here

  }
 
  @Test
  public void testDecodeLIA() throws Exception
  {
    DiameterMessage message = Codecs.__message.decode(load("lia.dat"));
    assertFalse(message.isRequest());
  }
View Full Code Here

    answer.setAVPList(l);
    answer.setResultCode(Common.DIAMETER_SUCCESS);

    Buffer buffer = new ByteArrayBuffer(512);
    buffer = Codecs.__message.encode(buffer, answer);
    DiameterMessage message = Codecs.__message.decode(buffer);
    assertFalse(message.isRequest());
    assertEquals(Common.CEA, message.getCommand());
  }
View Full Code Here

        }
        _indexTab--;
      }
      else if (value instanceof DiameterMessage)
      {
        DiameterMessage message = (DiameterMessage) value;
        StringBuilder sb = new StringBuilder();
        sb.append("[" + message.getApplicationId() + ",");
        sb.append(message.getEndToEndId() + "," + message.getHopByHopId() + "] ");
        sb.append(message.getCommand());
        if (value instanceof DiameterAnswer)
          sb.append(" / " + ((DiameterAnswer) message).getResultCode());
        add(sb.toString());       
        add(message.getAVPs());
      }
      else if (value instanceof AVP)
      {
        AVP avp = (AVP) value;
        add(avp.getType().toString(), avp.getValue());
View Full Code Here

    Dictionary.getInstance().load(IMS.class);
    Dictionary.getInstance().load(Cx.class);
    Dictionary.getInstance().load(Sh.class);
    JmxMessageLogger logger = new JmxMessageLogger();
    logger.start();
    DiameterMessage message = Codecs.__message.decode(load("mar.dat"));
    message.getAVPs().add(Cx.CX_APPLICATION_ID.getAVP());
    //((DiameterAnswer) message).setResultCode(Common.DIAMETER_SUCCESS);
    Output output  = DiameterMessageFormator.getPretty().newOutput();
    output.add(message);
    System.out.println(output.toString());
  }
View Full Code Here

TOP

Related Classes of org.cipango.diameter.node.DiameterMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.