/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/AspFactory.java

http://mobicents.googlecode.com/ · Java · 641 lines · 503 code · 99 blank · 39 comment · 95 complexity · bdd7df16129929c2dacc161c66d74b38 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;
  23. import java.nio.ByteBuffer;
  24. import javolution.util.FastList;
  25. import javolution.xml.XMLFormat;
  26. import javolution.xml.XMLSerializable;
  27. import javolution.xml.stream.XMLStreamException;
  28. import org.apache.log4j.Logger;
  29. import org.mobicents.protocols.api.Association;
  30. import org.mobicents.protocols.api.AssociationListener;
  31. import org.mobicents.protocols.api.IpChannelType;
  32. import org.mobicents.protocols.api.Management;
  33. import org.mobicents.protocols.ss7.m3ua.ExchangeType;
  34. import org.mobicents.protocols.ss7.m3ua.Functionality;
  35. import org.mobicents.protocols.ss7.m3ua.IPSPType;
  36. import org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM;
  37. import org.mobicents.protocols.ss7.m3ua.impl.fsm.UnknownTransitionException;
  38. import org.mobicents.protocols.ss7.m3ua.impl.message.M3UAMessageImpl;
  39. import org.mobicents.protocols.ss7.m3ua.impl.message.MessageFactoryImpl;
  40. import org.mobicents.protocols.ss7.m3ua.impl.oam.M3UAOAMMessages;
  41. import org.mobicents.protocols.ss7.m3ua.impl.parameter.ParameterFactoryImpl;
  42. import org.mobicents.protocols.ss7.m3ua.message.M3UAMessage;
  43. import org.mobicents.protocols.ss7.m3ua.message.MessageClass;
  44. import org.mobicents.protocols.ss7.m3ua.message.MessageFactory;
  45. import org.mobicents.protocols.ss7.m3ua.message.MessageType;
  46. import org.mobicents.protocols.ss7.m3ua.message.aspsm.ASPDown;
  47. import org.mobicents.protocols.ss7.m3ua.message.aspsm.ASPDownAck;
  48. import org.mobicents.protocols.ss7.m3ua.message.aspsm.ASPUp;
  49. import org.mobicents.protocols.ss7.m3ua.message.aspsm.ASPUpAck;
  50. import org.mobicents.protocols.ss7.m3ua.message.aspsm.Heartbeat;
  51. import org.mobicents.protocols.ss7.m3ua.message.asptm.ASPActive;
  52. import org.mobicents.protocols.ss7.m3ua.message.asptm.ASPActiveAck;
  53. import org.mobicents.protocols.ss7.m3ua.message.asptm.ASPInactive;
  54. import org.mobicents.protocols.ss7.m3ua.message.asptm.ASPInactiveAck;
  55. import org.mobicents.protocols.ss7.m3ua.message.mgmt.Notify;
  56. import org.mobicents.protocols.ss7.m3ua.message.ssnm.DestinationAvailable;
  57. import org.mobicents.protocols.ss7.m3ua.message.ssnm.DestinationRestricted;
  58. import org.mobicents.protocols.ss7.m3ua.message.ssnm.DestinationStateAudit;
  59. import org.mobicents.protocols.ss7.m3ua.message.ssnm.DestinationUPUnavailable;
  60. import org.mobicents.protocols.ss7.m3ua.message.ssnm.DestinationUnavailable;
  61. import org.mobicents.protocols.ss7.m3ua.message.ssnm.SignallingCongestion;
  62. import org.mobicents.protocols.ss7.m3ua.message.transfer.PayloadData;
  63. import org.mobicents.protocols.ss7.m3ua.parameter.ASPIdentifier;
  64. import org.mobicents.protocols.ss7.m3ua.parameter.ParameterFactory;
  65. /**
  66. *
  67. * @author amit bhayani
  68. *
  69. */
  70. public class AspFactory implements AssociationListener, XMLSerializable {
  71. private static final Logger logger = Logger.getLogger(AspFactory.class);
  72. private static long ASP_ID = 1l;
  73. private static final String NAME = "name";
  74. private static final String STARTED = "started";
  75. private static final String ASSOCIATION_NAME = "assocName";
  76. private volatile boolean channelConnected = false;
  77. protected String name;
  78. protected boolean started = false;
  79. protected Association association = null;
  80. protected String associationName = null;
  81. protected FastList<Asp> aspList = new FastList<Asp>();
  82. private ByteBuffer txBuffer = ByteBuffer.allocateDirect(8192);
  83. protected Management transportManagement = null;
  84. private ASPIdentifier aspid;
  85. protected ParameterFactory parameterFactory = new ParameterFactoryImpl();
  86. protected MessageFactory messageFactory = new MessageFactoryImpl();
  87. private TransferMessageHandler transferMessageHandler = new TransferMessageHandler(this);
  88. private SignalingNetworkManagementHandler signalingNetworkManagementHandler = new SignalingNetworkManagementHandler(
  89. this);
  90. private ManagementMessageHandler managementMessageHandler = new ManagementMessageHandler(this);
  91. private AspStateMaintenanceHandler aspStateMaintenanceHandler = new AspStateMaintenanceHandler(this);
  92. private AspTrafficMaintenanceHandler aspTrafficMaintenanceHandler = new AspTrafficMaintenanceHandler(this);
  93. private RoutingKeyManagementHandler routingKeyManagementHandler = new RoutingKeyManagementHandler(this);
  94. protected Functionality functionality = null;
  95. protected IPSPType ipspType = null;
  96. protected ExchangeType exchangeType = null;
  97. private long aspupSentTime = 0l;
  98. public AspFactory() {
  99. this.aspid = parameterFactory.createASPIdentifier(this.generateId());
  100. // clean transmission buffer
  101. txBuffer.clear();
  102. txBuffer.rewind();
  103. txBuffer.flip();
  104. }
  105. public AspFactory(String name) {
  106. this();
  107. this.name = name;
  108. }
  109. public void start() throws Exception {
  110. this.transportManagement.startAssociation(this.association.getName());
  111. this.started = true;
  112. }
  113. public void stop() throws Exception {
  114. this.started = false;
  115. if (this.functionality == Functionality.AS
  116. || (this.functionality == Functionality.SGW && this.exchangeType == ExchangeType.DE)
  117. || (this.functionality == Functionality.IPSP && this.exchangeType == ExchangeType.DE)
  118. || (this.functionality == Functionality.IPSP && this.exchangeType == ExchangeType.SE && this.ipspType == IPSPType.CLIENT)) {
  119. if (this.channelConnected) {
  120. ASPDown aspDown = (ASPDown) this.messageFactory.createMessage(MessageClass.ASP_STATE_MAINTENANCE,
  121. MessageType.ASP_DOWN);
  122. this.write(aspDown);
  123. for (FastList.Node<Asp> n = aspList.head(), end = aspList.tail(); (n = n.getNext()) != end;) {
  124. Asp asp = n.getValue();
  125. try {
  126. FSM aspLocalFSM = asp.getLocalFSM();
  127. aspLocalFSM.signal(TransitionState.ASP_DOWN_SENT);
  128. As peerAs = asp.getAs();
  129. FSM asPeerFSM = peerAs.getPeerFSM();
  130. asPeerFSM.setAttribute(As.ATTRIBUTE_ASP, asp);
  131. asPeerFSM.signal(TransitionState.ASP_DOWN);
  132. } catch (UnknownTransitionException e) {
  133. logger.error(e.getMessage(), e);
  134. }
  135. }
  136. } else {
  137. for (FastList.Node<Asp> n = aspList.head(), end = aspList.tail(); (n = n.getNext()) != end;) {
  138. Asp asp = n.getValue();
  139. try {
  140. FSM aspLocalFSM = asp.getLocalFSM();
  141. aspLocalFSM.signal(TransitionState.COMM_DOWN);
  142. As peerAs = asp.getAs();
  143. FSM asPeerFSM = peerAs.getPeerFSM();
  144. asPeerFSM.setAttribute(As.ATTRIBUTE_ASP, asp);
  145. asPeerFSM.signal(TransitionState.ASP_DOWN);
  146. } catch (UnknownTransitionException e) {
  147. logger.error(e.getMessage(), e);
  148. }
  149. }
  150. }
  151. } else {
  152. if (this.channelConnected) {
  153. throw new Exception("Still few ASP's are connected. Bring down the ASP's first");
  154. }
  155. this.transportManagement.stopAssociation(this.association.getName());
  156. }
  157. }
  158. public boolean getStatus() {
  159. return this.started;
  160. }
  161. public Functionality getFunctionality() {
  162. return functionality;
  163. }
  164. public void setFunctionality(Functionality functionality) {
  165. this.functionality = functionality;
  166. }
  167. public IPSPType getIpspType() {
  168. return ipspType;
  169. }
  170. public void setIpspType(IPSPType ipspType) {
  171. this.ipspType = ipspType;
  172. }
  173. public ExchangeType getExchangeType() {
  174. return exchangeType;
  175. }
  176. public void setExchangeType(ExchangeType exchangeType) {
  177. this.exchangeType = exchangeType;
  178. }
  179. public void setTransportManagement(Management transportManagement) {
  180. this.transportManagement = transportManagement;
  181. }
  182. public void setAssociation(Association association) {
  183. // Unset the listener to previous association
  184. if (this.association != null) {
  185. this.association.setAssociationListener(null);
  186. }
  187. this.association = association;
  188. this.associationName = this.association.getName();
  189. // Set the listener for new association
  190. this.association.setAssociationListener(this);
  191. }
  192. public void unsetAssociation() throws Exception {
  193. if (this.association != null) {
  194. if (this.association.isStarted()) {
  195. throw new Exception(String.format("Association=%s is still started. Stop first",
  196. this.association.getName()));
  197. }
  198. this.association.setAssociationListener(null);
  199. this.association = null;
  200. }
  201. }
  202. public String getName() {
  203. return this.name;
  204. }
  205. public void read(M3UAMessage message) {
  206. switch (message.getMessageClass()) {
  207. case MessageClass.MANAGEMENT:
  208. switch (message.getMessageType()) {
  209. case MessageType.ERROR:
  210. this.managementMessageHandler
  211. .handleError((org.mobicents.protocols.ss7.m3ua.message.mgmt.Error) message);
  212. break;
  213. case MessageType.NOTIFY:
  214. Notify notify = (Notify) message;
  215. this.managementMessageHandler.handleNotify(notify);
  216. break;
  217. default:
  218. logger.error(String.format("Rx : MGMT with invalid MessageType=%d message=%s",
  219. message.getMessageType(), message));
  220. break;
  221. }
  222. break;
  223. case MessageClass.TRANSFER_MESSAGES:
  224. switch (message.getMessageType()) {
  225. case MessageType.PAYLOAD:
  226. PayloadData payload = (PayloadData) message;
  227. this.transferMessageHandler.handlePayload(payload);
  228. break;
  229. default:
  230. logger.error(String.format("Rx : Transfer message with invalid MessageType=%d message=%s",
  231. message.getMessageType(), message));
  232. break;
  233. }
  234. break;
  235. case MessageClass.SIGNALING_NETWORK_MANAGEMENT:
  236. switch (message.getMessageType()) {
  237. case MessageType.DESTINATION_UNAVAILABLE:
  238. DestinationUnavailable duna = (DestinationUnavailable) message;
  239. this.signalingNetworkManagementHandler.handleDestinationUnavailable(duna);
  240. break;
  241. case MessageType.DESTINATION_AVAILABLE:
  242. DestinationAvailable dava = (DestinationAvailable) message;
  243. this.signalingNetworkManagementHandler.handleDestinationAvailable(dava);
  244. break;
  245. case MessageType.DESTINATION_STATE_AUDIT:
  246. DestinationStateAudit daud = (DestinationStateAudit) message;
  247. this.signalingNetworkManagementHandler.handleDestinationStateAudit(daud);
  248. break;
  249. case MessageType.SIGNALING_CONGESTION:
  250. SignallingCongestion scon = (SignallingCongestion) message;
  251. this.signalingNetworkManagementHandler.handleSignallingCongestion(scon);
  252. break;
  253. case MessageType.DESTINATION_USER_PART_UNAVAILABLE:
  254. DestinationUPUnavailable dupu = (DestinationUPUnavailable) message;
  255. this.signalingNetworkManagementHandler.handleDestinationUPUnavailable(dupu);
  256. break;
  257. case MessageType.DESTINATION_RESTRICTED:
  258. DestinationRestricted drst = (DestinationRestricted) message;
  259. this.signalingNetworkManagementHandler.handleDestinationRestricted(drst);
  260. break;
  261. default:
  262. logger.error(String.format("Received SSNM with invalid MessageType=%d message=%s",
  263. message.getMessageType(), message));
  264. break;
  265. }
  266. break;
  267. case MessageClass.ASP_STATE_MAINTENANCE:
  268. switch (message.getMessageType()) {
  269. case MessageType.ASP_UP:
  270. ASPUp aspUp = (ASPUp) message;
  271. this.aspStateMaintenanceHandler.handleAspUp(aspUp);
  272. break;
  273. case MessageType.ASP_UP_ACK:
  274. ASPUpAck aspUpAck = (ASPUpAck) message;
  275. this.aspStateMaintenanceHandler.handleAspUpAck(aspUpAck);
  276. break;
  277. case MessageType.ASP_DOWN:
  278. ASPDown aspDown = (ASPDown) message;
  279. this.aspStateMaintenanceHandler.handleAspDown(aspDown);
  280. break;
  281. case MessageType.ASP_DOWN_ACK:
  282. ASPDownAck aspDownAck = (ASPDownAck) message;
  283. this.aspStateMaintenanceHandler.handleAspDownAck(aspDownAck);
  284. break;
  285. case MessageType.HEARTBEAT:
  286. Heartbeat hrtBeat = (Heartbeat) message;
  287. this.aspStateMaintenanceHandler.handleHeartbeat(hrtBeat);
  288. break;
  289. default:
  290. logger.error(String.format("Received ASPSM with invalid MessageType=%d message=%s",
  291. message.getMessageType(), message));
  292. break;
  293. }
  294. break;
  295. case MessageClass.ASP_TRAFFIC_MAINTENANCE:
  296. switch (message.getMessageType()) {
  297. case MessageType.ASP_ACTIVE:
  298. ASPActive aspActive = (ASPActive) message;
  299. this.aspTrafficMaintenanceHandler.handleAspActive(aspActive);
  300. break;
  301. case MessageType.ASP_ACTIVE_ACK:
  302. ASPActiveAck aspAciveAck = (ASPActiveAck) message;
  303. this.aspTrafficMaintenanceHandler.handleAspActiveAck(aspAciveAck);
  304. break;
  305. case MessageType.ASP_INACTIVE:
  306. ASPInactive aspInactive = (ASPInactive) message;
  307. this.aspTrafficMaintenanceHandler.handleAspInactive(aspInactive);
  308. break;
  309. case MessageType.ASP_INACTIVE_ACK:
  310. ASPInactiveAck aspInaciveAck = (ASPInactiveAck) message;
  311. this.aspTrafficMaintenanceHandler.handleAspInactiveAck(aspInaciveAck);
  312. break;
  313. default:
  314. logger.error(String.format("Received ASPTM with invalid MessageType=%d message=%s",
  315. message.getMessageType(), message));
  316. break;
  317. }
  318. break;
  319. case MessageClass.ROUTING_KEY_MANAGEMENT:
  320. break;
  321. default:
  322. logger.error(String.format("Received message with invalid MessageClass=%d message=%s",
  323. message.getMessageClass(), message));
  324. break;
  325. }
  326. }
  327. public void write(M3UAMessage message) {
  328. synchronized (txBuffer) {
  329. try {
  330. txBuffer.clear();
  331. ((M3UAMessageImpl) message).encode(txBuffer);
  332. txBuffer.flip();
  333. byte[] data = new byte[txBuffer.limit()];
  334. txBuffer.get(data);
  335. org.mobicents.protocols.api.PayloadData payloadData = null;
  336. switch (message.getMessageClass()) {
  337. case MessageClass.ASP_STATE_MAINTENANCE:
  338. case MessageClass.MANAGEMENT:
  339. case MessageClass.ROUTING_KEY_MANAGEMENT:
  340. payloadData = new org.mobicents.protocols.api.PayloadData(data.length, data, true, true, 3, 0);
  341. break;
  342. case MessageClass.TRANSFER_MESSAGES:
  343. PayloadData payload = (PayloadData) message;
  344. payloadData = new org.mobicents.protocols.api.PayloadData(data.length, data, true, false, 3,
  345. payload.getData().getSLS());
  346. break;
  347. default:
  348. payloadData = new org.mobicents.protocols.api.PayloadData(data.length, data, true, true, 3, 0);
  349. break;
  350. }
  351. this.association.send(payloadData);
  352. } catch (Exception e) {
  353. e.printStackTrace();
  354. }
  355. }
  356. }
  357. protected Asp createAsp() {
  358. Asp remAsp = new Asp(this.name, this);
  359. // We set ASP IP only if its AS or IPSP Client side
  360. if (this.getFunctionality() == Functionality.AS
  361. || (this.getFunctionality() == Functionality.IPSP && this.getIpspType() == IPSPType.CLIENT)) {
  362. remAsp.setASPIdentifier(aspid);
  363. }
  364. this.aspList.add(remAsp);
  365. return remAsp;
  366. }
  367. public boolean destroyAsp(Asp asp) {
  368. asp.aspFactory = null;
  369. return this.aspList.remove(asp);
  370. }
  371. public FastList<Asp> getAspList() {
  372. return this.aspList;
  373. }
  374. protected Asp getAsp(long rc) {
  375. for (FastList.Node<Asp> n = aspList.head(), end = aspList.tail(); (n = n.getNext()) != end;) {
  376. Asp asp = n.getValue();
  377. if (asp.getAs().getRoutingContext().getRoutingContexts()[0] == rc) {
  378. return asp;
  379. }
  380. }
  381. return null;
  382. }
  383. protected void sendAspActive(As as) {
  384. ASPActive aspActive = (ASPActive) this.messageFactory.createMessage(MessageClass.ASP_TRAFFIC_MAINTENANCE,
  385. MessageType.ASP_ACTIVE);
  386. aspActive.setRoutingContext(as.getRoutingContext());
  387. aspActive.setTrafficModeType(as.getTrafficModeType());
  388. this.write(aspActive);
  389. }
  390. private long generateId() {
  391. ASP_ID++;
  392. if (ASP_ID == 4294967295l) {
  393. ASP_ID = 1l;
  394. }
  395. return ASP_ID;
  396. }
  397. private void handleCommDown() {
  398. this.channelConnected = false;
  399. for (FastList.Node<Asp> n = aspList.head(), end = aspList.tail(); (n = n.getNext()) != end;) {
  400. Asp asp = n.getValue();
  401. try {
  402. FSM aspLocalFSM = asp.getLocalFSM();
  403. if (aspLocalFSM != null) {
  404. aspLocalFSM.signal(TransitionState.COMM_DOWN);
  405. }
  406. FSM aspPeerFSM = asp.getPeerFSM();
  407. if (aspPeerFSM != null) {
  408. aspPeerFSM.signal(TransitionState.COMM_DOWN);
  409. }
  410. As as = asp.getAs();
  411. FSM asLocalFSM = as.getLocalFSM();
  412. if (asLocalFSM != null) {
  413. asLocalFSM.setAttribute(As.ATTRIBUTE_ASP, asp);
  414. asLocalFSM.signal(TransitionState.ASP_DOWN);
  415. }
  416. FSM asPeerFSM = as.getPeerFSM();
  417. if (asPeerFSM != null) {
  418. asPeerFSM.setAttribute(As.ATTRIBUTE_ASP, asp);
  419. asPeerFSM.signal(TransitionState.ASP_DOWN);
  420. }
  421. } catch (UnknownTransitionException e) {
  422. logger.error(e.getMessage(), e);
  423. }
  424. }
  425. }
  426. protected void sendAspUp() {
  427. // TODO : Possibility of race condition?
  428. long now = System.currentTimeMillis();
  429. if ((now - aspupSentTime) > 2000) {
  430. ASPUp aspUp = (ASPUp) this.messageFactory.createMessage(MessageClass.ASP_STATE_MAINTENANCE,
  431. MessageType.ASP_UP);
  432. aspUp.setASPIdentifier(this.aspid);
  433. this.write(aspUp);
  434. aspupSentTime = now;
  435. }
  436. }
  437. private void handleCommUp() {
  438. this.channelConnected = true;
  439. if (this.functionality == Functionality.AS
  440. || (this.functionality == Functionality.SGW && this.exchangeType == ExchangeType.DE)
  441. || (this.functionality == Functionality.IPSP && this.exchangeType == ExchangeType.DE)
  442. || (this.functionality == Functionality.IPSP && this.exchangeType == ExchangeType.SE && this.ipspType == IPSPType.CLIENT)) {
  443. this.aspupSentTime = 0l;
  444. this.sendAspUp();
  445. }
  446. for (FastList.Node<Asp> n = aspList.head(), end = aspList.tail(); (n = n.getNext()) != end;) {
  447. Asp asp = n.getValue();
  448. try {
  449. FSM aspLocalFSM = asp.getLocalFSM();
  450. if (aspLocalFSM != null) {
  451. aspLocalFSM.signal(TransitionState.COMM_UP);
  452. }
  453. FSM aspPeerFSM = asp.getPeerFSM();
  454. if (aspPeerFSM != null) {
  455. aspPeerFSM.signal(TransitionState.COMM_UP);
  456. }
  457. } catch (UnknownTransitionException e) {
  458. logger.error(e.getMessage(), e);
  459. }
  460. }
  461. }
  462. /**
  463. * XML Serialization/Deserialization
  464. */
  465. protected static final XMLFormat<AspFactory> ASP_FACTORY_XML = new XMLFormat<AspFactory>(AspFactory.class) {
  466. @Override
  467. public void read(javolution.xml.XMLFormat.InputElement xml, AspFactory aspFactory) throws XMLStreamException {
  468. aspFactory.name = xml.getAttribute(NAME, "");
  469. aspFactory.associationName = xml.getAttribute(ASSOCIATION_NAME, "");
  470. aspFactory.started = xml.getAttribute(STARTED).toBoolean();
  471. }
  472. @Override
  473. public void write(AspFactory aspFactory, javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException {
  474. xml.setAttribute(NAME, aspFactory.name);
  475. xml.setAttribute(ASSOCIATION_NAME, aspFactory.associationName);
  476. xml.setAttribute(STARTED, aspFactory.started);
  477. }
  478. };
  479. /**
  480. * AssociationListener methods
  481. */
  482. @Override
  483. public void onCommunicationLost(Association association) {
  484. logger.warn(String.format("Communication channel lost for AspFactroy=%s Association=%s", this.name,
  485. association.getName()));
  486. this.handleCommDown();
  487. }
  488. @Override
  489. public void onCommunicationRestart(Association association) {
  490. // TODO Auto-generated method stub
  491. }
  492. @Override
  493. public void onCommunicationShutdown(Association association) {
  494. logger.warn(String.format("Communication channel shutdown for AspFactroy=%s Association=%s", this.name,
  495. association.getName()));
  496. this.handleCommDown();
  497. }
  498. @Override
  499. public void onCommunicationUp(Association association) {
  500. this.handleCommUp();
  501. }
  502. @Override
  503. public void onPayload(Association association, org.mobicents.protocols.api.PayloadData payloadData) {
  504. byte[] m3uadata = payloadData.getData();
  505. M3UAMessage m3UAMessage;
  506. if (association.getIpChannelType() == IpChannelType.SCTP) {
  507. // TODO where is streamNumber stored?
  508. m3UAMessage = this.messageFactory.createSctpMessage(m3uadata);
  509. this.read(m3UAMessage);
  510. } else {
  511. ByteBuffer buffer = ByteBuffer.wrap(m3uadata);
  512. while (true) {
  513. m3UAMessage = this.messageFactory.createMessage(buffer);
  514. if (m3UAMessage == null)
  515. break;
  516. this.read(m3UAMessage);
  517. }
  518. }
  519. }
  520. public void show(StringBuffer sb) {
  521. sb.append(M3UAOAMMessages.SHOW_ASP_NAME).append(this.name).append(M3UAOAMMessages.SHOW_SCTP_ASSOC)
  522. .append(this.associationName).append(M3UAOAMMessages.SHOW_STARTED).append(this.started);
  523. sb.append(M3UAOAMMessages.NEW_LINE);
  524. sb.append(M3UAOAMMessages.SHOW_ASSIGNED_TO);
  525. for (FastList.Node<Asp> n = aspList.head(), end = aspList.tail(); (n = n.getNext()) != end;) {
  526. Asp asp = n.getValue();
  527. sb.append(M3UAOAMMessages.TAB).append(M3UAOAMMessages.SHOW_AS_NAME).append(asp.getAs().getName())
  528. .append(M3UAOAMMessages.SHOW_FUNCTIONALITY).append(this.functionality)
  529. .append(M3UAOAMMessages.SHOW_MODE).append(this.exchangeType);
  530. if (this.functionality == Functionality.IPSP) {
  531. sb.append(M3UAOAMMessages.SHOW_IPSP_TYPE).append(this.ipspType);
  532. }
  533. if (asp.getLocalFSM() != null) {
  534. sb.append(M3UAOAMMessages.SHOW_LOCAL_FSM_STATE).append(asp.getLocalFSM().getState());
  535. }
  536. if (asp.getPeerFSM() != null) {
  537. sb.append(M3UAOAMMessages.SHOW_PEER_FSM_STATE).append(asp.getPeerFSM().getState());
  538. }
  539. sb.append(M3UAOAMMessages.NEW_LINE);
  540. }
  541. }
  542. }