bool CTCPProfile::Matches(unsigned int profileID, const ROHC::iphdr *ip) const { if (profileID != ProfileID()) { return false; } const tcphdr* tcp = reinterpret_cast<const tcphdr*>(ip + 4*ip->ihl); return (ProtocolID() == ip->protocol) && (saddr == ip->saddr) && (daddr == ip->daddr) && (last_tcp.source == tcp->source) && (last_tcp.dest == tcp->dest); }
bool CProtocolCAN::HandleMsg( PASSTHRU_MSG * pMsg, char * flags) { LOG(PROTOCOL_MSG,"CProtocolCAN::HandleMsg: flags [%s]",flags); int flagslen=strlen(flags); if (flagslen<4) { LOG(ERR,"CProtocolCAN::HandleMsg: More flags required! flagslen %d",flagslen); return false; } char protocol_type = flags[0]; char message_type = flags[1]; char addr_type = flags[2]; int payload_len = convert_ascii_char_to_nibble(flags[3]); LOG(PROTOCOL_MSG,"CProtocolCAN::HandleMsg: protocol_type %c, msg_type %c, addr_type %c, payload_len %d",protocol_type,message_type,addr_type,payload_len); if (protocol_type=='c') // CAN bus message { // new CAN bus message pMsg->ProtocolID = ProtocolID(); // CAN; if (pMsg->DataSize != payload_len + 4) { LOG(ERR,"CProtocolCAN::HandleMsg: Mismatch in msg size (DataSize %d != specified payload length %d + 4)",pMsg->DataSize,payload_len); return false; } if (message_type=='n') { LOG(PROTOCOL_MSG_VERBOSE,"CProtocolCAN::HandleMsg: normal message"); } else if (message_type=='r') { LOG(PROTOCOL_MSG,"CProtocolCAN::HandleMsg: RTR message"); } else { LOG(ERR,"CProtocolCAN::HandleMsg: abnormal message type! [%c] ",protocol_type); return false; } if (addr_type=='x') { LOG(PROTOCOL_MSG_VERBOSE,"CProtocolCAN::HandleMsg: extended addressing (29 bit)"); pMsg->RxStatus |= CAN_29BIT_ID; } else if (addr_type=='b') { LOG(PROTOCOL_MSG_VERBOSE,"CProtocolCAN::HandleMsg: standard addressing (11 bit)"); pMsg->RxStatus &= ~CAN_29BIT_ID; } else { LOG(ERR,"CProtocolCAN::HandleMsg: abnormal addressing type! [%c] ",addr_type); return false; } pMsg->ExtraDataIndex = pMsg->DataSize; // we don't have any checksum return true; } else { LOG(PROTOCOL_MSG,"CProtocolCAN::HandleMsg: was not a CAN message"); } return false; }