コード例 #1
0
  @Override
  public Long addSendRoutingInfoForGprsRequest(
      int customInvokeTimeout,
      IMSI imsi,
      GSNAddress ggsnAddress,
      ISDNAddressString ggsnNumber,
      MAPExtensionContainer extensionContainer)
      throws MAPException {

    if ((this.appCntx.getApplicationContextName()
            != MAPApplicationContextName.gprsLocationInfoRetrievalContext)
        || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3
            && this.appCntx.getApplicationContextVersion()
                != MAPApplicationContextVersion.version4))
      throw new MAPException(
          "Bad application context name for addSendRoutingInfoForGprsRequest: must be gprsLocationInfoRetrievalContext_V3 or V4");

    Invoke invoke =
        this.mapProviderImpl
            .getTCAPProvider()
            .getComponentPrimitiveFactory()
            .createTCInvokeRequest();
    if (customInvokeTimeout == _Timer_Default) invoke.setTimeout(_Timer_m);
    else invoke.setTimeout(customInvokeTimeout);

    OperationCode oc =
        this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
    oc.setLocalOperationCode((long) MAPOperationCode.sendRoutingInfoForGprs);
    invoke.setOperationCode(oc);

    SendRoutingInfoForGprsRequestImpl req =
        new SendRoutingInfoForGprsRequestImpl(imsi, ggsnAddress, ggsnNumber, extensionContainer);
    AsnOutputStream aos = new AsnOutputStream();
    req.encodeData(aos);

    Parameter p =
        this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
    p.setTagClass(req.getTagClass());
    p.setPrimitive(req.getIsPrimitive());
    p.setTag(req.getTag());
    p.setData(aos.toByteArray());
    invoke.setParameter(p);

    Long invokeId;
    try {
      invokeId = this.tcapDialog.getNewInvokeId();
      invoke.setInvokeId(invokeId);
    } catch (TCAPException e) {
      throw new MAPException(e.getMessage(), e);
    }

    this.sendInvokeComponent(invoke);

    return invokeId;
  }
コード例 #2
0
ファイル: TCAPComponentsTest.java プロジェクト: nacerix/jss7
    public void addNewReturnResult(Long invokeId) throws Exception {

      ReturnResult rr = this.tcapProvider.getComponentPrimitiveFactory().createTCResultRequest();
      rr.setInvokeId(invokeId);

      OperationCode oc = TcapFactory.createOperationCode();

      oc.setLocalOperationCode(10L);
      rr.setOperationCode(oc);

      TestEvent te = TestEvent.createSentEvent(EventType.ReturnResult, null, sequence++);
      this.observerdEvents.add(te);

      this.dialog.sendComponent(rr);
    }
コード例 #3
0
ファイル: TCAPComponentsTest.java プロジェクト: nacerix/jss7
    @Override
    public void encode(AsnOutputStream aos) throws EncodeException {
      try {
        aos.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _TAG);
        int pos = aos.StartContentDefiniteLength();

        OperationCode oc = new OperationCodeImpl();
        oc.setLocalOperationCode(20L);
        oc.encode(aos);

        aos.FinalizeContent(pos);

      } catch (AsnException e) {
        throw new EncodeException("AsnException while encoding Invoke: " + e.getMessage(), e);
      }
    }
コード例 #4
0
  @Override
  public void addSendRoutingInfoForGprsResponse(
      long invokeId,
      GSNAddress sgsnAddress,
      GSNAddress ggsnAddress,
      Integer mobileNotReachableReason,
      MAPExtensionContainer extensionContainer)
      throws MAPException {

    if ((this.appCntx.getApplicationContextName()
            != MAPApplicationContextName.gprsLocationInfoRetrievalContext)
        || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3
            && this.appCntx.getApplicationContextVersion()
                != MAPApplicationContextVersion.version4))
      throw new MAPException(
          "Bad application context name for addSendRoutingInfoForGprsResponse: must be gprsLocationInfoRetrievalContext_V3 or V4");

    ReturnResultLast resultLast =
        this.mapProviderImpl
            .getTCAPProvider()
            .getComponentPrimitiveFactory()
            .createTCResultLastRequest();

    resultLast.setInvokeId(invokeId);

    // Operation Code
    OperationCode oc =
        this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
    oc.setLocalOperationCode((long) MAPOperationCode.sendRoutingInfoForGprs);
    resultLast.setOperationCode(oc);

    SendRoutingInfoForGprsResponseImpl resp =
        new SendRoutingInfoForGprsResponseImpl(
            sgsnAddress, ggsnAddress, mobileNotReachableReason, extensionContainer);
    AsnOutputStream aos = new AsnOutputStream();
    resp.encodeData(aos);

    Parameter p =
        this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
    p.setTagClass(resp.getTagClass());
    p.setPrimitive(resp.getIsPrimitive());
    p.setTag(resp.getTag());
    p.setData(aos.toByteArray());
    resultLast.setParameter(p);

    this.sendReturnResultLastComponent(resultLast);
  }
コード例 #5
0
ファイル: Server.java プロジェクト: nacerix/jss7
  @Override
  public void sendContinue() throws TCAPSendException, TCAPException {

    Component[] comps = components;
    if (comps == null || comps.length != 2) {
      throw new TCAPSendException("Bad comps!");
    }
    Component c = comps[0];
    if (c.getType() != ComponentType.Invoke) {
      throw new TCAPSendException("Bad type: " + c.getType());
    }
    // lets kill this Invoke - sending ReturnResultLast
    Invoke invoke = (Invoke) c;
    ReturnResultLast rrlast =
        this.tcapProvider.getComponentPrimitiveFactory().createTCResultLastRequest();
    rrlast.setInvokeId(invoke.getInvokeId());
    // we need not set operationCode here because of no Parameter is sent and ReturnResultLast will
    // not carry
    // ReturnResultLast value
    // rrlast.setOperationCode(invoke.getOperationCode());
    super.dialog.sendComponent(rrlast);

    c = comps[1];
    if (c.getType() != ComponentType.Invoke) {
      throw new TCAPSendException("Bad type: " + c.getType());
    }

    // lets kill this Invoke - sending Invoke with linkedId
    invoke = (Invoke) c;
    Invoke invoke2 =
        this.tcapProvider.getComponentPrimitiveFactory().createTCInvokeRequest(InvokeClass.Class1);
    invoke2.setInvokeId(this.dialog.getNewInvokeId());
    invoke2.setLinkedId(invoke.getInvokeId());
    OperationCode oc = this.tcapProvider.getComponentPrimitiveFactory().createOperationCode();
    oc.setLocalOperationCode(new Long(14));
    invoke2.setOperationCode(oc);
    // no parameter
    this.dialog.sendComponent(invoke2);

    super.sendContinue();
  }
コード例 #6
0
ファイル: TCAPComponentsTest.java プロジェクト: nacerix/jss7
    public void addNewInvoke(Long invokeId, Long timout) throws Exception {

      Invoke invoke = this.tcapProvider.getComponentPrimitiveFactory().createTCInvokeRequest();
      invoke.setInvokeId(invokeId);

      OperationCode oc = TcapFactory.createOperationCode();

      oc.setLocalOperationCode(10L);
      invoke.setOperationCode(oc);

      invoke.setTimeout(timout);

      // Parameter p1 = TcapFactory.createParameter();
      // p1.setTagClass(Tag.CLASS_UNIVERSAL);
      // p1.setTag(Tag.STRING_OCTET);
      // p1.setData(new byte[]{0x0F});
      //
      // Parameter p2 = TcapFactory.createParameter();
      // p2.setTagClass(Tag.CLASS_UNIVERSAL);
      // p2.setTag(Tag.STRING_OCTET);
      // p2.setData(new byte[] { (byte) 0xaa, (byte) 0x98, (byte) 0xac, (byte) 0xa6, 0x5a, (byte)
      // 0xcd, 0x62, 0x36, 0x19,
      // 0x0e, 0x37, (byte) 0xcb, (byte) 0xe5,
      // 0x72, (byte) 0xb9, 0x11 });
      //
      // Parameter pm = TcapFactory.createParameter();
      // pm.setTagClass(Tag.CLASS_UNIVERSAL);
      // pm.setTag(Tag.SEQUENCE);
      // pm.setParameters(new Parameter[]{p1, p2});
      // invoke.setParameter(pm);

      TestEvent te = TestEvent.createSentEvent(EventType.Invoke, null, sequence++);
      this.observerdEvents.add(te);

      this.dialog.sendComponent(invoke);

      lastSentInvoke = invoke;
    }
コード例 #7
0
ファイル: InvokeTest.java プロジェクト: SergeyLee/jss7
  @Test(groups = {"functional.encode"})
  public void testEncode() throws IOException, EncodeException {

    byte[] expected = this.getData();

    Invoke invoke = TcapFactory.createComponentInvoke();
    invoke.setInvokeId(12l);

    OperationCode oc = TcapFactory.createOperationCode();

    oc.setLocalOperationCode(59L);
    invoke.setOperationCode(oc);

    Parameter p1 = TcapFactory.createParameter();
    p1.setTagClass(Tag.CLASS_UNIVERSAL);
    p1.setTag(Tag.STRING_OCTET);
    p1.setData(new byte[] {0x0F});

    Parameter p2 = TcapFactory.createParameter();
    p2.setTagClass(Tag.CLASS_UNIVERSAL);
    p2.setTag(Tag.STRING_OCTET);
    p2.setData(
        new byte[] {
          (byte) 0xaa,
          (byte) 0x98,
          (byte) 0xac,
          (byte) 0xa6,
          0x5a,
          (byte) 0xcd,
          0x62,
          0x36,
          0x19,
          0x0e,
          0x37,
          (byte) 0xcb,
          (byte) 0xe5,
          0x72,
          (byte) 0xb9,
          0x11
        });

    Parameter pm = TcapFactory.createParameter();
    pm.setTagClass(Tag.CLASS_UNIVERSAL);
    pm.setTag(Tag.SEQUENCE);
    pm.setParameters(new Parameter[] {p1, p2});
    invoke.setParameter(pm);

    AsnOutputStream asnos = new AsnOutputStream();

    invoke.encode(asnos);

    byte[] encodedData = asnos.toByteArray();
    assertTrue(Arrays.equals(expected, encodedData));

    expected = this.getDataFull();

    invoke = TcapFactory.createComponentInvoke();
    invoke.setInvokeId(-5L);
    invoke.setLinkedId(2L);
    oc = TcapFactory.createOperationCode();
    oc.setGlobalOperationCode(new long[] {1, 0, 0, 1});
    invoke.setOperationCode(oc);

    pm = TcapFactory.createParameter();
    pm.setTagClass(Tag.CLASS_UNIVERSAL);
    pm.setTag(Tag.STRING_OCTET);
    pm.setData(new byte[] {11, 22, 33});
    invoke.setParameter(pm);

    asnos = new AsnOutputStream();
    invoke.encode(asnos);

    encodedData = asnos.toByteArray();
    assertTrue(Arrays.equals(expected, encodedData));
  }
コード例 #8
0
ファイル: InvokeTest.java プロジェクト: SergeyLee/jss7
  @Test(groups = {"functional.decode"})
  public void testDecodeWithParaSequ() throws IOException, ParseException {

    byte[] b = this.getData();

    AsnInputStream asnIs = new AsnInputStream(b);

    Component comp = TcapFactory.createComponent(asnIs);
    assertEquals(ComponentType.Invoke, comp.getType());

    Invoke invokeComp = (Invoke) comp;
    assertTrue(12L == invokeComp.getInvokeId());
    OperationCode oc = invokeComp.getOperationCode();
    assertNotNull(oc);
    assertTrue(59 == oc.getLocalOperationCode());
    assertEquals(OperationCodeType.Local, oc.getOperationType());

    Parameter p = invokeComp.getParameter();
    assertEquals(Tag.CLASS_UNIVERSAL, p.getTagClass());
    assertEquals(false, p.isPrimitive());
    assertEquals(Tag.SEQUENCE, p.getTag());
    assertTrue(
        Arrays.equals(
            new byte[] {
              0x04,
              0x01,
              0x0f,
              0x04,
              0x10,
              (byte) 0xaa,
              (byte) 0x98,
              (byte) 0xac,
              (byte) 0xa6,
              0x5a,
              (byte) 0xcd,
              0x62,
              0x36,
              0x19,
              0x0e,
              0x37,
              (byte) 0xcb,
              (byte) 0xe5,
              0x72,
              (byte) 0xb9,
              0x11
            },
            p.getData()));

    Parameter[] params = invokeComp.getParameter().getParameters();
    assertEquals(2, params.length);
    p = params[0];
    assertEquals(Tag.CLASS_UNIVERSAL, p.getTagClass());
    assertEquals(true, p.isPrimitive());
    assertEquals(Tag.STRING_OCTET, p.getTag());
    assertTrue(Arrays.equals(new byte[] {0x0f}, p.getData()));
    p = params[1];
    assertEquals(Tag.CLASS_UNIVERSAL, p.getTagClass());
    assertEquals(true, p.isPrimitive());
    assertEquals(Tag.STRING_OCTET, p.getTag());
    assertTrue(
        Arrays.equals(
            new byte[] {
              (byte) 0xaa,
              (byte) 0x98,
              (byte) 0xac,
              (byte) 0xa6,
              0x5a,
              (byte) 0xcd,
              0x62,
              0x36,
              0x19,
              0x0e,
              0x37,
              (byte) 0xcb,
              (byte) 0xe5,
              0x72,
              (byte) 0xb9,
              0x11
            },
            p.getData()));

    b = this.getDataFull();
    asnIs = new AsnInputStream(b);

    comp = TcapFactory.createComponent(asnIs);
    assertEquals(ComponentType.Invoke, comp.getType());

    invokeComp = (Invoke) comp;
    assertEquals(-5L, (long) invokeComp.getInvokeId());
    assertEquals(2L, (long) invokeComp.getLinkedId());
    oc = invokeComp.getOperationCode();
    assertNotNull(oc);
    assertEquals(OperationCodeType.Global, oc.getOperationType());
    assertTrue(Arrays.equals(new long[] {1, 0, 0, 1}, oc.getGlobalOperationCode()));

    p = invokeComp.getParameter();
    assertEquals(Tag.CLASS_UNIVERSAL, p.getTagClass());
    assertEquals(true, p.isPrimitive());
    assertEquals(Tag.STRING_OCTET, p.getTag());
    assertTrue(Arrays.equals(new byte[] {11, 22, 33}, p.getData()));
  }