/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/router/DPCNode.java

http://mobicents.googlecode.com/ · Java · 82 lines · 38 code · 13 blank · 31 comment · 12 complexity · eede251edae32922f265b78af78af82d MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.mobicents.protocols.ss7.m3ua.impl.router;
  23. import javolution.util.FastList;
  24. import org.mobicents.protocols.ss7.m3ua.impl.As;
  25. /**
  26. * <p>
  27. * dpc is mandatory in deciding the correct AS to route the MTP3 traffic.
  28. * </p>
  29. *
  30. * @author amit bhayani
  31. *
  32. */
  33. public class DPCNode {
  34. int dpc = -1;
  35. private FastList<OPCNode> opcList = new FastList<OPCNode>();
  36. private OPCNode wildCardOpcNode = null;
  37. public DPCNode(int dpc) {
  38. this.dpc = dpc;
  39. }
  40. protected void addSi(int opc, int si, As as) throws Exception {
  41. for (FastList.Node<OPCNode> n = opcList.head(), end = opcList.tail(); (n = n.getNext()) != end;) {
  42. OPCNode opcNode = n.getValue();
  43. if (opcNode.opc == opc) {
  44. opcNode.addSi(si, as);
  45. return;
  46. }
  47. }
  48. OPCNode opcNode = new OPCNode(this.dpc, opc);
  49. opcNode.addSi(si, as);
  50. opcList.add(opcNode);
  51. if (opcNode.opc == -1) {
  52. // we have wild card OPCNode. Use this if no matching OPCNode
  53. // found while finding AS
  54. wildCardOpcNode = opcNode;
  55. }
  56. }
  57. protected As getAs(int opc, short si) {
  58. for (FastList.Node<OPCNode> n = opcList.head(), end = opcList.tail(); (n = n.getNext()) != end;) {
  59. OPCNode opcNode = n.getValue();
  60. if (opcNode.opc == opc) {
  61. return opcNode.getAs(si);
  62. }
  63. }
  64. if (wildCardOpcNode != null) {
  65. return wildCardOpcNode.getAs(si);
  66. }
  67. return null;
  68. }
  69. }