PageRenderTime 44ms CodeModel.GetById 34ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/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
23package org.mobicents.protocols.ss7.m3ua.impl.router;
24
25import javolution.util.FastList;
26
27import org.mobicents.protocols.ss7.m3ua.impl.As;
28
29/**
30 * <p>
31 * dpc is mandatory in deciding the correct AS to route the MTP3 traffic.
32 * </p>
33 * 
34 * @author amit bhayani
35 * 
36 */
37public class DPCNode {
38	int dpc = -1;
39
40	private FastList<OPCNode> opcList = new FastList<OPCNode>();
41
42	private OPCNode wildCardOpcNode = null;
43
44	public DPCNode(int dpc) {
45		this.dpc = dpc;
46	}
47
48	protected void addSi(int opc, int si, As as) throws Exception {
49		for (FastList.Node<OPCNode> n = opcList.head(), end = opcList.tail(); (n = n.getNext()) != end;) {
50			OPCNode opcNode = n.getValue();
51			if (opcNode.opc == opc) {
52				opcNode.addSi(si, as);
53				return;
54			}
55		}
56
57		OPCNode opcNode = new OPCNode(this.dpc, opc);
58		opcNode.addSi(si, as);
59		opcList.add(opcNode);
60
61		if (opcNode.opc == -1) {
62			// we have wild card OPCNode. Use this if no matching OPCNode
63			// found while finding AS
64			wildCardOpcNode = opcNode;
65		}
66
67	}
68
69	protected As getAs(int opc, short si) {
70		for (FastList.Node<OPCNode> n = opcList.head(), end = opcList.tail(); (n = n.getNext()) != end;) {
71			OPCNode opcNode = n.getValue();
72			if (opcNode.opc == opc) {
73				return opcNode.getAs(si);
74			}
75		}
76
77		if (wildCardOpcNode != null) {
78			return wildCardOpcNode.getAs(si);
79		}
80		return null;
81	}
82}