Java Code Examples for org.mobicents.protocols.api.IpChannelType#SCTP

The following examples show how to use org.mobicents.protocols.api.IpChannelType#SCTP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyAssociationImpl.java    From sctp with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void send(PayloadData payloadData) throws Exception {
    if (logger.isDebugEnabled()) {
        logger.debug(String.format("Tx : Ass=%s %s", this.getName(), payloadData));
    }

    NettySctpChannelInboundHandlerAdapter handler = checkSocketIsOpen();

    final ByteBuf byteBuf = payloadData.getByteBuf();
    if (this.ipChannelType == IpChannelType.SCTP) {
        SctpMessage sctpMessage = new SctpMessage(payloadData.getPayloadProtocolId(), payloadData.getStreamNumber(),
                payloadData.isUnordered(), byteBuf);
        handler.writeAndFlush(sctpMessage);
    } else {
        handler.writeAndFlush(byteBuf);
    }
}
 
Example 2
Source File: AssociationImpl.java    From sctp with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void read(javolution.xml.XMLFormat.InputElement xml, AssociationImpl association)
		throws XMLStreamException {
	association.name = xml.getAttribute(NAME, "");
	association.type = AssociationType.getAssociationType(xml.getAttribute(ASSOCIATION_TYPE, ""));
	association.hostAddress = xml.getAttribute(HOST_ADDRESS, "");
	association.hostPort = xml.getAttribute(HOST_PORT, 0);

	association.peerAddress = xml.getAttribute(PEER_ADDRESS, "");
	association.peerPort = xml.getAttribute(PEER_PORT, 0);

	association.serverName = xml.getAttribute(SERVER_NAME, "");
	association.ipChannelType = IpChannelType.getInstance(xml.getAttribute(IPCHANNEL_TYPE,
			IpChannelType.SCTP.getCode()));
	if (association.ipChannelType == null)
		association.ipChannelType = IpChannelType.SCTP;

	int extraHostAddressesSize = xml.getAttribute(EXTRA_HOST_ADDRESS_SIZE, 0);
	association.extraHostAddresses = new String[extraHostAddressesSize];

	for (int i = 0; i < extraHostAddressesSize; i++) {
		association.extraHostAddresses[i] = xml.get(EXTRA_HOST_ADDRESS, String.class);
	}

}
 
Example 3
Source File: SendRoutingInfoResp.java    From SigPloit with MIT License 6 votes vote down vote up
public static void main(String args[]) {
    System.out.println("*********************************************");
    System.out.println("***      Subscriber Information - HLR     ***");
    System.out.println("*********************************************");
    IpChannelType ipChannelType = IpChannelType.SCTP;

    final SendRoutingInfoResp victim = new SendRoutingInfoResp();

    logger.setLevel(org.apache.log4j.Level.DEBUG);

    try {
        victim.initializeStack(ipChannelType);

        // Lets pause for 20 seconds so stacks are initialized properly
        Thread.sleep(20000);


    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 4
Source File: ServerImpl.java    From sctp with GNU Affero General Public License v3.0 6 votes vote down vote up
private void initSocket() throws IOException {

		if (this.ipChannelType == IpChannelType.SCTP)
			doInitSocketSctp();
		else
			doInitSocketTcp();

		// Register the server socket channel, indicating an interest in
		// accepting new connections
		// this.serverChannel.register(socketSelector, SelectionKey.OP_ACCEPT);

		FastList<ChangeRequest> pendingChanges = this.management.getPendingChanges();
		synchronized (pendingChanges) {

			// Indicate we want the interest ops set changed
			pendingChanges.add(new ChangeRequest(this.getIpChannel(), null, ChangeRequest.REGISTER,
					SelectionKey.OP_ACCEPT));
		}

		this.management.getSocketSelector().wakeup();
	}
 
Example 5
Source File: SendIMSIResp.java    From SigPloit with MIT License 6 votes vote down vote up
public static void main(String args[]) {
    System.out.println("*********************************************");
    System.out.println("***      IMSI Information - HLR           ***");
    System.out.println("*********************************************");
    IpChannelType ipChannelType = IpChannelType.SCTP;

    final SendIMSIResp victim = new SendIMSIResp();

    logger.setLevel(org.apache.log4j.Level.DEBUG);

    try {
        victim.initializeStack(ipChannelType);

        // Lets pause for 20 seconds so stacks are initialized properly
        Thread.sleep(20000);


    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 6
Source File: NettyAssociationImpl.java    From sctp with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void read(javolution.xml.XMLFormat.InputElement xml, NettyAssociationImpl association) throws XMLStreamException {
    association.name = xml.getAttribute(NAME, "");
    association.type = AssociationType.getAssociationType(xml.getAttribute(ASSOCIATION_TYPE, ""));
    association.hostAddress = xml.getAttribute(HOST_ADDRESS, "");
    association.hostPort = xml.getAttribute(HOST_PORT, 0);

    association.peerAddress = xml.getAttribute(PEER_ADDRESS, "");
    association.peerPort = xml.getAttribute(PEER_PORT, 0);

    association.serverName = xml.getAttribute(SERVER_NAME, "");
    association.ipChannelType = IpChannelType
            .getInstance(xml.getAttribute(IPCHANNEL_TYPE, IpChannelType.SCTP.getCode()));
    if (association.ipChannelType == null)
        association.ipChannelType = IpChannelType.SCTP;

    int extraHostAddressesSize = xml.getAttribute(EXTRA_HOST_ADDRESS_SIZE, 0);
    association.extraHostAddresses = new String[extraHostAddressesSize];

    for (int i = 0; i < extraHostAddressesSize; i++) {
        association.extraHostAddresses[i] = xml.get(EXTRA_HOST_ADDRESS, String.class);
    }

}
 
Example 7
Source File: SelectorThread.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
private void finishConnection(SelectionKey key) throws IOException{
	AssociationImpl association = (AssociationImpl) key.attachment();
	if (association.getIpChannelType() == IpChannelType.SCTP)
		this.finishConnectionSctp(key);
	else
		this.finishConnectionTcp(key);
}
 
Example 8
Source File: AssociationImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
private void checkSocketIsOpen() throws Exception {
	if (this.ipChannelType == IpChannelType.SCTP) {
		if (!this.started || this.socketChannelSctp == null || !this.socketChannelSctp.isOpen()
				|| this.socketChannelSctp.association() == null)
			throw new Exception(String.format(
					"Underlying sctp channel doesn't open or doesn't have association for Association=%s",
					this.name));
	} else {
		if (!this.started || this.socketChannelTcp == null || !this.socketChannelTcp.isOpen()
				|| !this.socketChannelTcp.isConnected())
			throw new Exception(String.format("Underlying tcp channel doesn't open for Association=%s", this.name));
	}
}
 
Example 9
Source File: AssociationImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @param socketChannel
 *            the socketChannel to set
 */
protected void setSocketChannel(AbstractSelectableChannel socketChannel) {
	if (this.ipChannelType == IpChannelType.SCTP)
		this.socketChannelSctp = (SctpChannel) socketChannel;
	else
		this.socketChannelTcp = (SocketChannel) socketChannel;
}
 
Example 10
Source File: UpdateLocationResp.java    From SigPloit with MIT License 5 votes vote down vote up
public static void main(String args[]) {
    System.out.println("*********************************************");
    System.out.println("***          Updating New Location        ***");
    System.out.println("*********************************************");
    IpChannelType ipChannelType = IpChannelType.SCTP;
    //IpChannelType ipChannelType = IpChannelType.TCP;
    if (args.length >= 1 && args[0].toLowerCase().equals("tcp")) {
        ipChannelType = IpChannelType.TCP;
    }

    final UpdateLocationResp victim = new UpdateLocationResp();

    logger.setLevel(org.apache.log4j.Level.DEBUG);

    try {
        victim.initializeStack(ipChannelType);

        // Lets pause for 20 seconds so stacks are initialized properly
        Thread.sleep(20000);
        //victim.initiateSRISMResp();




    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 11
Source File: SS7Honeypot.java    From SigFW with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
    logger.debug("*************************************");
    logger.debug("***           SS7Server           ***");
    logger.debug("*************************************");
    
    // clear XML dir
    File index = new File(persistDir);
    if (!index.exists()) {
        index.mkdir();
    } else {
        String[]entries = index.list();
        for(String s: entries){
            File currentFile = new File(index.getPath(),s);
            currentFile.delete();
        }
    }
    //
    
    IpChannelType ipChannelType = IpChannelType.SCTP;
    if (args.length >= 1 && args[0].toLowerCase().equals("tcp")) {
        ipChannelType = IpChannelType.TCP;
    }

    logger.setLevel(org.apache.log4j.Level.DEBUG);
    
    final SS7Honeypot server = new SS7Honeypot();
    try {
        server.initializeStack(ipChannelType);
    } catch (Exception e) {
        e.printStackTrace();
    }
    
    try {
        while (true) {
            if(server.serverM3UAMgmt.isStarted() == true) {
                for (As a : server.serverM3UAMgmt.getAppServers()) {
                    if (a.isConnected() && a.isUp()) {
                        //server.initiateUSSD();
                    }
                }
                
            } else {
                //server.serverM3UAMgmt.start();
            }
            
            Thread.sleep(1000);
        }
    } catch (Exception ex) {
        java.util.logging.Logger.getLogger(SS7Honeypot.class.getName()).log(Level.SEVERE, null, ex);
    }
    
}
 
Example 12
Source File: SendRoutingInfoForGPRS.java    From SigPloit with MIT License 4 votes vote down vote up
public static void main(String args[]) {
    System.out.println("*********************************************");
    System.out.println("***          SRI-SM Response Simulator    ***");
    System.out.println("*********************************************");
    IpChannelType ipChannelType = IpChannelType.SCTP;


    final SendRoutingInfoForGPRS victim = new SendRoutingInfoForGPRS();

    logger.setLevel(org.apache.log4j.Level.DEBUG);

    try {
        victim.initializeStack(ipChannelType);

        // Lets pause for 20 seconds so stacks are initialized properly
        Thread.sleep(20000);





    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 13
Source File: ServerImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
protected AbstractSelectableChannel getIpChannel() {
	if (this.ipChannelType == IpChannelType.SCTP)
		return this.serverChannelSctp;
	else
		return this.serverChannelTcp;
}
 
Example 14
Source File: AssociationImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
private AbstractSelectableChannel getSocketChannel() {
	if (this.ipChannelType == IpChannelType.SCTP)
		return this.socketChannelSctp;
	else
		return this.socketChannelTcp;
}
 
Example 15
Source File: SriSMResp.java    From SigPloit with MIT License 4 votes vote down vote up
public static void main(String args[]) {
    System.out.println("*********************************************");
    System.out.println("***          SRI-SM Response Simulator    ***");
    System.out.println("*********************************************");
    IpChannelType ipChannelType = IpChannelType.SCTP;


    final SriSMResp victim = new SriSMResp();

    logger.setLevel(org.apache.log4j.Level.DEBUG);

    try {
        victim.initializeStack(ipChannelType);

        // Lets pause for 20 seconds so stacks are initialized properly
        Thread.sleep(20000);
        




    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 16
Source File: AnyTimeInterrogationResp.java    From SigPloit with MIT License 4 votes vote down vote up
public static void main(String args[]) {
    System.out.println("*********************************************");
    System.out.println("***          Subscriber Information       ***");
    System.out.println("*********************************************");
    IpChannelType ipChannelType = IpChannelType.SCTP;

    final AnyTimeInterrogationResp victim = new AnyTimeInterrogationResp();

    logger.setLevel(org.apache.log4j.Level.DEBUG);

    try {
        victim.initializeStack(ipChannelType);

        // Lets pause for 20 seconds so stacks are initialized properly
        Thread.sleep(20000);
        //victim.initiateSRISMResp();




    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 17
Source File: AssociationImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
private int doSend(ByteBuf buffer) throws IOException {
	if (this.ipChannelType == IpChannelType.SCTP)
		return this.doSendSctp(buffer);
	else
		return this.doSendTcp(buffer);
}
 
Example 18
Source File: NettyServerImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
protected ServerChannel getIpChannel() {
    if (this.ipChannelType == IpChannelType.SCTP)
        return this.serverChannelSctp;
    else
        return this.serverChannelTcp;
}
 
Example 19
Source File: NettyServerImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
private void initSocket() throws Exception {
    ServerBootstrap b = new ServerBootstrap();
    b.group(this.management.getBossGroup(), this.management.getWorkerGroup());
    if (this.ipChannelType == IpChannelType.SCTP) {
        b.channel(NioSctpServerChannel.class);
        b.option(ChannelOption.SO_BACKLOG, 100);
        b.childHandler(new NettySctpServerChannelInitializer(this, this.management));
        this.applySctpOptions(b);
    } else {
        b.channel(NioServerSocketChannel.class);
        b.option(ChannelOption.SO_BACKLOG, 100);
        b.childHandler(new NettyTcpServerChannelInitializer(this, this.management));
    }
    b.handler(new LoggingHandler(LogLevel.INFO));

    InetSocketAddress localAddress = new InetSocketAddress(this.hostAddress, this.hostport);

    // Bind the server to primary address.
    ChannelFuture channelFuture = b.bind(localAddress).sync();

    // Get the underlying sctp channel
    if (this.ipChannelType == IpChannelType.SCTP) {
        this.serverChannelSctp = (SctpServerChannel) channelFuture.channel();

        // Bind the secondary address.
        // Please note that, bindAddress in the client channel should be done before connecting if you have not
        // enable Dynamic Address Configuration. See net.sctp.addip_enable kernel param
        if (this.extraHostAddresses != null) {
            for (int count = 0; count < this.extraHostAddresses.length; count++) {
                String localSecondaryAddress = this.extraHostAddresses[count];
                InetAddress localSecondaryInetAddress = InetAddress.getByName(localSecondaryAddress);

                channelFuture = this.serverChannelSctp.bindAddress(localSecondaryInetAddress).sync();
            }
        }

        if (logger.isInfoEnabled()) {
            logger.info(String.format("SctpServerChannel bound to=%s ", this.serverChannelSctp.allLocalAddresses()));
        }
    } else {
        this.serverChannelTcp = (NioServerSocketChannel) channelFuture.channel();

        if (logger.isInfoEnabled()) {
            logger.info(String.format("ServerSocketChannel bound to=%s ", this.serverChannelTcp.localAddress()));
        }
    }
}
 
Example 20
Source File: ProvideSubscriberInformationResp.java    From SigPloit with MIT License 3 votes vote down vote up
public static void main(String args[]) {
    System.out.println("*********************************************");
    System.out.println("***          Subscriber Information       ***");
    System.out.println("*********************************************");
    IpChannelType ipChannelType = IpChannelType.SCTP;

    if (args.length >= 1 && args[0].toLowerCase().equals("tcp")) {
        ipChannelType = IpChannelType.TCP;
    }

    final ProvideSubscriberInformationResp victim = new ProvideSubscriberInformationResp();

    logger.setLevel(org.apache.log4j.Level.DEBUG);

    try {
        victim.initializeStack(ipChannelType);

        // Lets pause for 20 seconds so stacks are initialized properly
        Thread.sleep(20000);





    } catch (Exception e) {
        e.printStackTrace();
    }
}