/usr/share/doc/crossroads/examples/iphashtest.cc is in crossroads 2.81-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | // C
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <netdb.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
// C++
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main () {
for (int a = 0; a <= 255; a++) {
ostringstream o;
o << "192.168.1." << a;
struct in_addr ad;
inet_aton (o.str().c_str(), &ad);
unsigned index = 0;
for (char *cp = (char*) &ad;
unsigned(cp - (char*)&ad) < sizeof(struct in_addr);
cp++) {
index += *cp;
index %= 60;
//cout << " " << "byte: " << hex << *cp
// << ", index: " << index << "\n";
}
cout << inet_ntoa(ad) << ": " << dec << index << "\n";
}
return (0);
}
|