You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.1 KiB
71 lines
2.1 KiB
/*
|
|
* Copyright 2019 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include "fields/checksum_field.h"
|
|
#include "util.h"
|
|
|
|
const std::string ChecksumField::kFieldType = "ChecksumField";
|
|
|
|
ChecksumField::ChecksumField(std::string name, std::string type_name, int size, ParseLocation loc)
|
|
: ScalarField(name, size, loc), type_name_(type_name) {}
|
|
|
|
const std::string& ChecksumField::GetFieldType() const {
|
|
return ChecksumField::kFieldType;
|
|
}
|
|
|
|
std::string ChecksumField::GetDataType() const {
|
|
return type_name_;
|
|
}
|
|
|
|
void ChecksumField::GenExtractor(std::ostream&, int, bool) const {}
|
|
|
|
std::string ChecksumField::GetGetterFunctionName() const {
|
|
return "";
|
|
}
|
|
|
|
void ChecksumField::GenGetter(std::ostream&, Size, Size) const {}
|
|
|
|
bool ChecksumField::GenBuilderParameter(std::ostream&) const {
|
|
return false;
|
|
}
|
|
|
|
bool ChecksumField::HasParameterValidator() const {
|
|
return false;
|
|
}
|
|
|
|
void ChecksumField::GenParameterValidator(std::ostream&) const {
|
|
// Do nothing.
|
|
}
|
|
|
|
void ChecksumField::GenInserter(std::ostream& s) const {
|
|
s << "packet::ByteObserver observer = i.UnregisterObserver();";
|
|
s << "insert(static_cast<" << util::GetTypeForSize(GetSize().bits()) << ">(observer.GetValue()), i);";
|
|
}
|
|
|
|
void ChecksumField::GenValidator(std::ostream&) const {
|
|
// Done in packet_def.cc
|
|
}
|
|
|
|
void ChecksumField::GenStringRepresentation(std::ostream& s, std::string) const {
|
|
// TODO: there is currently no way to get checksum value
|
|
s << "\"CHECKSUM\"";
|
|
}
|
|
|
|
void ChecksumField::GenRustGetter(std::ostream&, Size, Size) const {
|
|
}
|
|
|
|
void ChecksumField::GenRustWriter(std::ostream&, Size, Size) const {}
|