コード例 #1
0
Tlv& TlvChain::addTlv(Word type)
{
    if ( m_tlvList.contains(type) ) {
        m_tlvList.remove(type);
    }
    return *(m_tlvList.insert( type, Tlv(type) ));
}
コード例 #2
0
ファイル: tlv.cpp プロジェクト: jofell/CocoaTag
TlvList Tlv::fromByteArray(const QByteArray& data, quint64 offset)
{
    TlvList list;

    QByteArray buffer = data.left(data.count() - offset);
    qint32 count = buffer.count();
    qint32 index = 0;

    while (count > index)
    {
        quint8 type = buffer.at(index);
        ++index;

        switch (type)
        {
            case Tlv::Null:
                break;

            case Tlv::Terminator:
            {
                list.append(Tlv::createTerminatorTlv());
                index = count;
            }
            break;

            default:
            {
                if ((count - index) > 0)
                {
                    quint16 length = buffer.at(index);
                    ++index;

                    if (length > 0xfe)
                    {
                        length = 0;

                        if ((count - index) > 2)
                        {
                            length = (quint8(buffer.at(index)) << 8) | quint8(buffer.at(index + 1));
                            index += 2;
                        }
                    }

                    if ((count - index) >= length)
                    {
                        list.append(Tlv(type, buffer.mid(index, length)));
                        index += length;
                    }
                    else
                    {
                        index = count;
                    }
                }
            }
            break;
        }
    }

    return list;
}
コード例 #3
0
TlvChain& TlvChain::addTlv(Word type, const QByteArray& data)
{
    if ( m_tlvList.contains(type) ) {
        m_tlvList.remove(type);
    }
    m_tlvList.insert(type, Tlv(type, data) );
    return *this;
}
コード例 #4
0
Tlv
IpcsClassifierRecord::ToTlv (void) const
{
  Ipv4AddressTlvValue ipv4AddrValSrc;
  for (std::vector<struct ipv4Addr>::const_iterator iter = m_srcAddr.begin (); iter != m_srcAddr.end (); ++iter)
    {
      ipv4AddrValSrc.Add ((*iter).Address, (*iter).Mask);
    }

  Ipv4AddressTlvValue ipv4AddrValDst;
  for (std::vector<struct ipv4Addr>::const_iterator iter = m_dstAddr.begin (); iter != m_dstAddr.end (); ++iter)
    {
      ipv4AddrValDst.Add ((*iter).Address, (*iter).Mask);
    }

  ProtocolTlvValue protoVal;
  for (std::vector<uint8_t>::const_iterator iter = m_protocol.begin (); iter != m_protocol.end (); ++iter)
    {
      protoVal.Add ((*iter));
    }

  PortRangeTlvValue portValueSrc;
  for (std::vector<struct PortRange>::const_iterator iter = m_srcPortRange.begin (); iter != m_srcPortRange.end (); ++iter)
    {
      portValueSrc.Add ((*iter).PortLow, (*iter).PortHigh);
    }

  PortRangeTlvValue portValueDst;
  for (std::vector<struct PortRange>::const_iterator iter = m_dstPortRange.begin (); iter != m_dstPortRange.end (); ++iter)
    {
      portValueDst.Add ((*iter).PortLow, (*iter).PortHigh);
    }

  ClassificationRuleVectorTlvValue ClassVectVal;
  ClassVectVal.Add (Tlv (ClassificationRuleVectorTlvValue::Priority, 1, U8TlvValue (m_priority)));
  ClassVectVal.Add (Tlv (ClassificationRuleVectorTlvValue::Protocol, protoVal.GetSerializedSize (), protoVal));
  ClassVectVal.Add (Tlv (ClassificationRuleVectorTlvValue::IP_src, ipv4AddrValSrc.GetSerializedSize (), ipv4AddrValSrc));
  ClassVectVal.Add (Tlv (ClassificationRuleVectorTlvValue::IP_dst, ipv4AddrValDst.GetSerializedSize (), ipv4AddrValDst));
  ClassVectVal.Add (Tlv (ClassificationRuleVectorTlvValue::Port_src, portValueSrc.GetSerializedSize (), portValueSrc));
  ClassVectVal.Add (Tlv (ClassificationRuleVectorTlvValue::Port_dst, portValueDst.GetSerializedSize (), portValueDst));
  ClassVectVal.Add (Tlv (ClassificationRuleVectorTlvValue::Index, 2, U16TlvValue (1)));

  Tlv tmp_tlv (CsParamVectorTlvValue::Packet_Classification_Rule, ClassVectVal.GetSerializedSize (), ClassVectVal);

  return tmp_tlv;
}
コード例 #5
0
TlvChain& TlvChain::operator<<(const QByteArray& data)
{
    *this << Tlv(data);
    return *this;
}
コード例 #6
0
ファイル: Num.c プロジェクト: BackupTheBerlios/toolbox
Tlv_t tb_num_toTlv(Num_t Self) {
	num_members_t m = XNum(Self);
	return Tlv(TB_NUM, sizeof(int), (char *)&(m->value));
}
コード例 #7
0
ファイル: tlv.cpp プロジェクト: jofell/CocoaTag
Tlv Tlv::createNDEFMessageTlv(const NDEFMessage& msg)
{
    return Tlv(Tlv::NDEF, msg.toByteArray());
}
コード例 #8
0
ファイル: tlv.cpp プロジェクト: jofell/CocoaTag
Tlv Tlv::createTerminatorTlv()
{
    return Tlv(Tlv::Terminator);
}
コード例 #9
0
ファイル: tlv.cpp プロジェクト: jofell/CocoaTag
Tlv Tlv::createNullTlv()
{
    return Tlv(Tlv::Null);
}