bool EthernetFrame::isExpectedType() const {
	ACE_TRACE("EthernetFrameT::isExpectedType");
	if ( getUnitLength() < minBytesToDetermineLength() )
		throw std::runtime_error("Not enough bytes loaded to determine packet type validity.");

	// Not much to go on here; only useful for packets coming/going through
	// Linux tap devices.
	switch (preambleLength_) {
		case LinuxTap:
			return (getPreamble() == 0) && (getPreambleType() == getEtherType());
		case IEEE:
			break;
	}
	
	// If the value of the type field is recognized, that's a good sign
	ACE_UINT16 eType = getEtherType();
	if ( eType == Eth_IPv4	|| eType == Eth_ARP	||
			eType == Eth_8021q || eType == Eth_IPv6 ) return true;
	
	return false; // We can't determine
}
Beispiel #2
0
void MumbleClient::processProtoMessage(QByteArray data)
{

    int total_size = data.size();
    quint8 bin_data[total_size];
    unsigned char *temp = reinterpret_cast<unsigned char*>(data.data());
    memcpy(bin_data,temp,total_size);
    int type, len;
    getPreamble(bin_data,&type,&len);
    int message_size = total_size-6;
    quint8 message[message_size];
    memcpy(message,bin_data+6,message_size);

    switch(type)
    {
    case 15:
        setupEncryption(message,message_size);
        break;
    case 5: // ServerSync
        processServerSync(message,message_size);
        break;
    case 3: // ping
        //qDebug() << "pong";
        break;
    case 7: // ChannelState
        processChannelState(message, message_size);
        break;
    case 9: // UserState
        processUserState(message, message_size);
        break;
    case 8: // UserRemove
        processUserRemove(message, message_size);
        break;
    case 1: // UDPTunnel
        processIncomingAudioPacket(message, message_size, type);
    default:
        break;
    }
}