Package de.fhkn.in.uce.stun.message

Examples of de.fhkn.in.uce.stun.message.Message.addAttribute()


                    ByteBuffer.wrap(connectionRequest.getHeader().getTransactionId()).getInt());
        } else {
            clientAddress = new XorMappedAddress(new InetSocketAddress(toSource.getInetAddress(), toSource.getPort()));
        }
        connectionRequest.addAttribute(clientAddress);
        connectionRequest.addAttribute(new EndpointClass(EndpointCategory.PUBLIC));
        connectionRequest.addAttribute(new ReversalAttribute());
        final Socket toTarget = user.getSocketToUser();
        connectionRequest.writeTo(toTarget.getOutputStream());
    }
View Full Code Here


        } else {
            clientAddress = new XorMappedAddress(new InetSocketAddress(toSource.getInetAddress(), toSource.getPort()));
        }
        connectionRequest.addAttribute(clientAddress);
        connectionRequest.addAttribute(new EndpointClass(EndpointCategory.PUBLIC));
        connectionRequest.addAttribute(new ReversalAttribute());
        final Socket toTarget = user.getSocketToUser();
        connectionRequest.writeTo(toTarget.getOutputStream());
    }

    private void sendFailureResponse(final Message message, final String errorReaon, final STUNErrorCode errorCode,
View Full Code Here

    private void sendIndicationWithChangeRequestAttribute(final int changeRequestFlag, final Socket sendSocket)
            throws IOException {
        logger.debug("Sending indication with change request flag = {}", changeRequestFlag); //$NON-NLS-1$
        final Message indication = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.INDICATION,
                STUNMessageMethod.BINDING);
        indication.addAttribute(new ChangeRequest(changeRequestFlag));
        indication.writeTo(sendSocket.getOutputStream());
    }

    private Message receiveMessageFromStunServer() throws IOException {
        final ServerSocket serverSocket = this.createBoundServerSocket();
View Full Code Here

    }

    private void handleSimpleBindingRequest(final Message toHandle) throws Exception {
        final Message response = toHandle.buildSuccessResponse();
        final OtherAddress otherAddress = new OtherAddress(this.secondaryAddress);
        response.addAttribute(otherAddress);
        final XorMappedAddress clientAddress = this.getPublicClientAddressAsAttribute(toHandle);
        response.addAttribute(clientAddress);
        response.writeTo(this.socket.getOutputStream());
    }
View Full Code Here

    private void handleSimpleBindingRequest(final Message toHandle) throws Exception {
        final Message response = toHandle.buildSuccessResponse();
        final OtherAddress otherAddress = new OtherAddress(this.secondaryAddress);
        response.addAttribute(otherAddress);
        final XorMappedAddress clientAddress = this.getPublicClientAddressAsAttribute(toHandle);
        response.addAttribute(clientAddress);
        response.writeTo(this.socket.getOutputStream());
    }

    private void handleMessageWithChangeRequestAttribute(final Message toHandle, final InetSocketAddress remoteAddress)
            throws Exception {
View Full Code Here

    private void sendIndicationViaNewSocket(final InetSocketAddress bindAddress, final Message message,
            final InetSocketAddress remoteAddress) {
        try {
            final Message indication = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.INDICATION,
                    STUNMessageMethod.BINDING);
            indication.addAttribute(this.getPublicClientAddressAsAttribute(message));
            final Socket newSocket = new Socket();
            newSocket.setReuseAddress(true);
            logger.debug("Binding new socket to {}", bindAddress); //$NON-NLS-1$
            newSocket.bind(bindAddress);
            logger.debug("Connecting to {}", remoteAddress.toString()); //$NON-NLS-1$
View Full Code Here

        this.mediatorUtil.checkForAttribute(message, Username.class);
        final Username username = message.getAttribute(Username.class);
        final UserData user = this.userList.getUserDataByUserId(username.getUsernameAsString());
        final NATBehavior userNat = user.getUserNat();
        final Message response = message.buildSuccessResponse();
        response.addAttribute(userNat);
        response.writeTo(controlConnection.getOutputStream());
        logger.debug("response to {}:{} sent", message.getMessageClass().toString(), message.getMessageMethod()
                .toString());
    }
View Full Code Here

        this.mediatorUtil.checkForAttribute(message, Username.class);
        final Username username = message.getAttribute(Username.class);
        final UserData user = this.userList.getUserDataByUserId(username.getUsernameAsString());
        final Message response = message.buildSuccessResponse();
        for (final NATTraversalTechniqueAttribute attr : user.getSupportedNatTraversalTechniques()) {
            response.addAttribute(attr);
        }
        response.writeTo(controlConnection.getOutputStream());
    }

    @Override
View Full Code Here

    @SuppressWarnings("unused")
    private void sendRegisterMessage() throws IOException {
        final Message registerMessage = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.REQUEST,
                STUNMessageMethod.REGISTER);
        // target id
        registerMessage.addAttribute(new Username(this.targetId));
        // private endpoint
        final InetAddress privateAddress = this.socketToMediator.getLocalAddress();
        if (privateAddress instanceof Inet6Address) {
            registerMessage.addAttribute(new XorMappedAddress(new InetSocketAddress(this.socketToMediator
                    .getLocalAddress(), this.socketToMediator.getLocalPort()), ByteBuffer.wrap(
View Full Code Here

        // target id
        registerMessage.addAttribute(new Username(this.targetId));
        // private endpoint
        final InetAddress privateAddress = this.socketToMediator.getLocalAddress();
        if (privateAddress instanceof Inet6Address) {
            registerMessage.addAttribute(new XorMappedAddress(new InetSocketAddress(this.socketToMediator
                    .getLocalAddress(), this.socketToMediator.getLocalPort()), ByteBuffer.wrap(
                    registerMessage.getHeader().getTransactionId()).getInt()));
        } else {
            registerMessage.addAttribute(new XorMappedAddress(new InetSocketAddress(this.socketToMediator
                    .getLocalAddress(), this.socketToMediator.getLocalPort())));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.