public void visiteErrorCode(final ErrorCodeAttribute attribute) {
    writeHeader(attribute);

    // The first 21 bits are zero-filled for 32 bit alignment.  We skip
    // the first 16 here so we can just write a full byte for the class
    // on the next call.
    m_buf.skip(2);
    MinaUtils.putUnsignedByte(this.m_buf, attribute.getErrorClass());
    MinaUtils.putUnsignedByte(this.m_buf, attribute.getErrorNumber());
    try {
      m_buf.putString(attribute.getReasonPhrase(), UTF_8_ENCODER);
    } catch (final CharacterCodingException e) {
      LOG.error("Could not encode reason phrase", e);
      throw new IllegalArgumentException("Could not encode reason phrase", e);
    }
  }
  private void visitAddressAttribute(final StunAddressAttribute address) {
    writeHeader(address);

    // Now put the attribute body.

    // The first byte is ignored in address attributes.
    MinaUtils.putUnsignedByte(m_buf, 0x00);

    final int family = address.getAddressFamily();

    if (LOG.isDebugEnabled()) {
      LOG.debug("Writing family: " + family);
    }
    final InetSocketAddress socketAddress = address.getInetSocketAddress();
    final int port = socketAddress.getPort();
    final InetAddress ia = socketAddress.getAddress();
    final byte[] addressBytes = ia.getAddress();
    MinaUtils.putUnsignedByte(m_buf, family);
    MinaUtils.putUnsignedShort(m_buf, port);
    m_buf.put(addressBytes);
  }
 public void visitIceControlling(final IceControllingAttribute attribute) {
   writeHeader(attribute);
   final byte[] tieBreaker = attribute.getTieBreaker();
   LOG.debug("Encoding controlling: {}", tieBreaker);
   m_buf.put(tieBreaker);
 }
 public void visitData(final DataAttribute data) {
   writeHeader(data);
   final byte[] dataBytes = data.getData();
   m_buf.put(dataBytes);
 }