Commit cc7f28e0 authored by Jiachen,Chen's avatar Jiachen,Chen

Added TestLittleEndian

parent 722c6733
/*
* File: TestLittleEndian.cc
* Author: Jiachen Chen
*
* Created on April 30, 2019, 12:20 AM
*/
#include "TestLittleEndian.hh"
#include <arpa/inet.h>
#include <inttypes.h>
TestLittleEndian::TestLittleEndian() = default;
TestLittleEndian::~TestLittleEndian() = default;
int TestLittleEndian::initialize(ErrorHandler* errh __attribute ((__unused__))) {
unsigned i;
union {
uint32_t i;
uint8_t a[sizeof (uint32_t)];
} u;
u.i = 0x12345678;
for (i = 0; i < sizeof (uint32_t); i++)
printf("%02" PRIx8, u.a[i]);
printf("\n");
u.i = htonl(0x12345678);
for (i = 0; i < sizeof (uint32_t); i++)
printf("%02" PRIx8, u.a[i]);
printf("\n");
return 0;
}
EXPORT_ELEMENT(TestLittleEndian)
\ No newline at end of file
require(package "click_for_comnet");
test :: TestLittleEndian;
DriverManager(stop);
/*
* File: TestLittleEndian.hh
* Author: Jiachen Chen
*
* Created on April 30, 2019, 12:20 AM
*/
#include <click/config.h>
#include <click/element.hh>
#include <click/error.hh>
#ifndef TESTLITTLEENDIAN_HH
#define TESTLITTLEENDIAN_HH
class TestLittleEndian : public Element {
public:
TestLittleEndian();
~TestLittleEndian();
const char *class_name() const { return "TestLittleEndian"; }
int initialize(ErrorHandler *errh);
private:
};
#endif /* TESTLITTLEENDIAN_HH */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment