-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TruncateFCS: new element to truncate the FCS
Removes FCS from ethernet frames. In practice, just removes 4 bytes...
- Loading branch information
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// -*- mode: c++; c-basic-offset: 4 -*- | ||
/* | ||
* truncate.{cc,hh} -- limits packet length | ||
* Eddie Kohler | ||
* | ||
* Copyright (c) 2004 Regents of the University of California | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, subject to the conditions | ||
* listed in the Click LICENSE file. These conditions include: you must | ||
* preserve this copyright notice, and you cannot mention the copyright | ||
* holders in advertising related to the Software without their permission. | ||
* The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This | ||
* notice is a summary of the Click LICENSE file; the license in that file is | ||
* legally binding. | ||
*/ | ||
|
||
#include <click/config.h> | ||
#include "truncatefcs.hh" | ||
#include <click/args.hh> | ||
#include <click/error.hh> | ||
#include <click/glue.hh> | ||
#include <click/packet_anno.hh> | ||
CLICK_DECLS | ||
|
||
TruncateFCS::TruncateFCS() | ||
{ | ||
} | ||
|
||
int | ||
TruncateFCS::configure(Vector<String> &conf, ErrorHandler *errh) | ||
{ | ||
_extra_anno = true; | ||
return Args(conf, this, errh) | ||
.read("EXTRA_LENGTH", _extra_anno) | ||
.complete(); | ||
} | ||
|
||
Packet * | ||
TruncateFCS::simple_action(Packet *p) | ||
{ | ||
if (_extra_anno && EXTRA_LENGTH_ANNO(p) > 4) | ||
SET_EXTRA_LENGTH_ANNO(p, EXTRA_LENGTH_ANNO(p) - 4); | ||
else | ||
p->take(4); | ||
return p; | ||
} | ||
|
||
void | ||
TruncateFCS::add_handlers() | ||
{ | ||
} | ||
|
||
CLICK_ENDDECLS | ||
EXPORT_ELEMENT(TruncateFCS) | ||
ELEMENT_MT_SAFE(TruncateFCS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// -*- mode: c++; c-basic-offset: 4 -*- | ||
#ifndef CLICK_TRUNCATECS_HH | ||
#define CLICK_TRUNCATEFCS_HH | ||
#include <click/element.hh> | ||
CLICK_DECLS | ||
|
||
/* | ||
* =c | ||
* TruncateFCS() | ||
* =s ethernet | ||
* remove the FCS from packet | ||
* =d | ||
* Does not check if the FCS is present, therefore the packets is always shortened by 4 bytes. | ||
* | ||
* The EXTRA_LENGTH keyword argument determines whether packets' extra length | ||
* annotations are updated to account for any dropped bytes. Default is true. | ||
* =a Strip, Pad, Truncate | ||
*/ | ||
|
||
class TruncateFCS : public Element { public: | ||
|
||
TruncateFCS() CLICK_COLD; | ||
|
||
const char *class_name() const override { return "TruncateFCS"; } | ||
const char *port_count() const override { return PORTS_1_1; } | ||
|
||
int configure(Vector<String> &, ErrorHandler *) CLICK_COLD; | ||
bool can_live_reconfigure() const { return true; } | ||
|
||
Packet *simple_action(Packet *); | ||
|
||
void add_handlers() CLICK_COLD; | ||
|
||
private: | ||
|
||
bool _extra_anno; | ||
|
||
}; | ||
|
||
CLICK_ENDDECLS | ||
#endif |