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
// http://www.sigcomm.org/sites/default/files/ccr/papers/2012/October/2378956-2378961.pdf | |
int dir_24_8_lookup(uint32_t dst) { | |
int nh = tbl_0_23[dst >> 8]; // index in the next hop table | |
if (nh & 0x8000)nh = tbl_24_31[((nh & 0x7fff) << 8) | (dst & 0xff)]; | |
return nh; | |
} |
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
#include <cstdint> | |
#include <arpa/inet.h> | |
/** Returns the IPv4 broadcast address for a given subnet. | |
* | |
* Assuming host is little endian. | |
* Assuming your host is Linux :) | |
* | |
* subtracting 1 from the return will yield last usable host address. | |
* |
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
/* | |
* for use with software DIR-24-8-basic. | |
* personal implementation. | |
*/ | |
void flip_state(uint32_t &prefix, uint8_t &position){ | |
prefix = prefix ^ 1<<position; | |
} |
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
int more(const char *buffer) { | |
pid_t pid(fork()); | |
int status(0); | |
if (!pid) { | |
FILE *output{}; | |
output = popen("more", "w"); | |
if (!output) { |