libtins-1.1/0000755000175000017500000000000012154360117012335 5ustar matiasmatiaslibtins-1.1/tests/0000775000175000017500000000000012154360113013475 5ustar matiasmatiaslibtins-1.1/tests/src/0000775000175000017500000000000012154360113014264 5ustar matiasmatiaslibtins-1.1/tests/src/wpa2_decrypt.cpp0000664000175000017500000004427012154360113017402 0ustar matiasmatias#include #include #include #include #include "crypto.h" #include "radiotap.h" #include "udp.h" #include "tcp.h" using namespace Tins; class WPA2DecryptTest : public testing::Test { public: static const uint8_t ccmp_packets[7][652]; static const uint8_t tkip_packets[7][211]; static const size_t ccmp_packets_size[], tkip_packets_size[]; void check_ccmp_packet5(const PDU &pdu); void check_ccmp_packet6(const PDU &pdu); void check_tkip_packet5(const PDU &pdu); void check_tkip_packet6(const PDU &pdu); }; // packet taken from aircrack's site. const uint8_t WPA2DecryptTest::ccmp_packets[7][652] = { // Beacon {0, 0, 24, 0, 142, 88, 0, 0, 16, 2, 108, 9, 160, 0, 96, 0, 0, 42, 0, 0, 71, 123, 147, 9, 128, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 12, 65, 130, 178, 85, 0, 12, 65, 130, 178, 85, 128, 252, 134, 225, 42, 28, 1, 0, 0, 0, 100, 0, 17, 4, 0, 7, 67, 111, 104, 101, 114, 101, 114, 1, 8, 130, 132, 139, 150, 36, 48, 72, 108, 3, 1, 1, 5, 4, 0, 1, 0, 0, 42, 1, 2, 47, 1, 2, 48, 24, 1, 0, 0, 15, 172, 2, 2, 0, 0, 15, 172, 4, 0, 15, 172, 2, 1, 0, 0, 15, 172, 2, 0, 0, 50, 4, 12, 18, 24, 96, 221, 6, 0, 16, 24, 2, 0, 4, 221, 28, 0, 80, 242, 1, 1, 0, 0, 80, 242, 2, 2, 0, 0, 80, 242, 4, 0, 80, 242, 2, 1, 0, 0, 80, 242, 2, 0, 0, 71, 123, 147, 9}, // EAPOL keys {0, 0, 24, 0, 142, 88, 0, 0, 16, 108, 108, 9, 192, 0, 100, 0, 0, 39, 0, 0, 183, 8, 75, 112, 8, 2, 44, 0, 0, 13, 147, 130, 54, 58, 0, 12, 65, 130, 178, 85, 0, 12, 65, 130, 178, 85, 176, 252, 170, 170, 3, 0, 0, 0, 136, 142, 2, 3, 0, 117, 2, 0, 138, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 62, 142, 150, 125, 172, 217, 96, 50, 76, 172, 91, 106, 167, 33, 35, 91, 245, 123, 148, 151, 113, 200, 103, 152, 159, 73, 208, 78, 212, 124, 105, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 221, 20, 0, 15, 172, 4, 89, 45, 168, 128, 150, 196, 97, 218, 36, 108, 105, 0, 30, 135, 127, 61, 183, 8, 75, 112}, {0, 0, 24, 0, 142, 88, 0, 0, 16, 108, 108, 9, 192, 0, 100, 0, 0, 56, 0, 0, 138, 11, 46, 247, 8, 1, 44, 0, 0, 12, 65, 130, 178, 85, 0, 13, 147, 130, 54, 58, 0, 12, 65, 130, 178, 85, 144, 1, 170, 170, 3, 0, 0, 0, 136, 142, 2, 3, 0, 117, 2, 1, 10, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 205, 244, 5, 206, 185, 216, 137, 239, 61, 236, 66, 96, 152, 40, 250, 229, 70, 183, 173, 215, 186, 236, 187, 26, 57, 78, 172, 82, 20, 177, 211, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 98, 167, 2, 154, 213, 186, 48, 182, 175, 13, 243, 145, 152, 142, 69, 0, 22, 48, 20, 1, 0, 0, 15, 172, 2, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 2, 0, 0, 138, 11, 46, 247}, {0, 0, 24, 0, 142, 88, 0, 0, 16, 108, 108, 9, 192, 0, 100, 0, 0, 40, 0, 0, 108, 57, 145, 12, 8, 2, 44, 0, 0, 13, 147, 130, 54, 58, 0, 12, 65, 130, 178, 85, 0, 12, 65, 130, 178, 85, 192, 252, 170, 170, 3, 0, 0, 0, 136, 142, 2, 3, 0, 175, 2, 19, 202, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 62, 142, 150, 125, 172, 217, 96, 50, 76, 172, 91, 106, 167, 33, 35, 91, 245, 123, 148, 151, 113, 200, 103, 152, 159, 73, 208, 78, 212, 124, 105, 51, 245, 123, 148, 151, 113, 200, 103, 152, 159, 73, 208, 78, 212, 124, 105, 52, 207, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 10, 246, 223, 81, 233, 156, 222, 122, 24, 116, 83, 240, 249, 53, 55, 0, 80, 207, 167, 44, 222, 53, 178, 193, 226, 49, 146, 85, 128, 106, 179, 100, 23, 159, 217, 103, 48, 65, 185, 165, 147, 159, 161, 162, 1, 13, 42, 199, 148, 226, 81, 104, 5, 95, 121, 77, 220, 31, 223, 174, 53, 33, 244, 68, 107, 253, 17, 218, 152, 52, 95, 84, 61, 246, 206, 25, 157, 248, 254, 72, 248, 205, 209, 122, 220, 168, 123, 244, 87, 17, 24, 60, 73, 109, 65, 170, 12, 108, 57, 145, 12}, {0, 0, 24, 0, 142, 88, 0, 0, 16, 108, 108, 9, 192, 0, 100, 0, 0, 56, 0, 0, 239, 69, 111, 112, 8, 1, 44, 0, 0, 12, 65, 130, 178, 85, 0, 13, 147, 130, 54, 58, 0, 12, 65, 130, 178, 85, 160, 1, 170, 170, 3, 0, 0, 0, 136, 142, 2, 3, 0, 95, 2, 3, 10, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 187, 163, 189, 251, 207, 222, 43, 197, 55, 80, 157, 113, 242, 236, 209, 0, 0, 239, 69, 111, 112}, // DHCP {0, 0, 24, 0, 142, 88, 0, 0, 16, 108, 108, 9, 192, 0, 100, 0, 0, 57, 0, 0, 44, 168, 148, 39, 8, 65, 44, 0, 0, 12, 65, 130, 178, 85, 0, 13, 147, 130, 54, 58, 255, 255, 255, 255, 255, 255, 176, 1, 1, 0, 0, 32, 0, 0, 0, 0, 126, 204, 246, 10, 193, 221, 255, 176, 71, 150, 195, 11, 161, 156, 146, 198, 18, 30, 128, 3, 144, 245, 239, 74, 121, 190, 64, 178, 90, 240, 84, 27, 111, 77, 28, 231, 39, 8, 194, 149, 207, 88, 25, 69, 140, 24, 213, 31, 100, 86, 122, 124, 197, 255, 133, 231, 166, 139, 35, 138, 51, 94, 68, 68, 247, 222, 12, 94, 239, 114, 29, 159, 219, 13, 81, 68, 3, 209, 201, 6, 70, 21, 35, 62, 252, 226, 75, 65, 109, 83, 140, 136, 132, 94, 70, 13, 41, 99, 14, 218, 114, 151, 253, 219, 181, 102, 172, 10, 5, 249, 33, 31, 191, 36, 57, 154, 21, 169, 21, 17, 4, 57, 189, 12, 12, 81, 10, 8, 74, 136, 144, 80, 1, 252, 100, 204, 154, 79, 202, 210, 81, 214, 224, 241, 85, 0, 183, 19, 251, 66, 194, 68, 96, 88, 42, 104, 208, 165, 185, 156, 128, 142, 1, 44, 32, 10, 197, 39, 176, 235, 50, 15, 117, 125, 96, 234, 1, 250, 121, 246, 92, 47, 195, 85, 102, 144, 98, 217, 37, 227, 228, 76, 2, 145, 193, 167, 54, 213, 15, 11, 140, 108, 104, 222, 158, 83, 110, 217, 127, 235, 67, 147, 130, 128, 75, 115, 146, 58, 97, 127, 204, 239, 55, 96, 207, 101, 152, 247, 126, 57, 185, 144, 166, 209, 103, 171, 92, 166, 169, 87, 118, 56, 254, 168, 52, 44, 151, 171, 213, 84, 245, 111, 234, 72, 235, 72, 190, 82, 223, 200, 39, 102, 123, 28, 9, 8, 120, 88, 185, 150, 154, 116, 16, 45, 83, 227, 125, 53, 46, 228, 98, 68, 132, 61, 2, 245, 27, 4, 67, 100, 203, 38, 51, 253, 46, 140, 22, 10, 33, 49, 36, 86, 229, 116, 116, 137, 51, 224, 216, 73, 91, 232, 35, 151, 216, 156, 183, 57, 247, 171, 160, 232, 68, 194, 184, 220, 58, 61, 87, 209, 167, 176, 126, 169, 255, 151, 163, 215, 23, 255, 2, 131, 11, 88, 44, 168, 148, 39}, // DHCP {0, 0, 24, 0, 142, 88, 0, 0, 16, 108, 108, 9, 192, 0, 100, 0, 0, 41, 0, 0, 190, 202, 53, 174, 8, 66, 44, 0, 0, 13, 147, 130, 54, 58, 0, 12, 65, 130, 178, 85, 0, 12, 65, 130, 178, 83, 240, 252, 1, 0, 0, 32, 0, 0, 0, 0, 119, 49, 71, 116, 105, 136, 85, 205, 132, 196, 180, 119, 142, 132, 254, 142, 107, 185, 34, 64, 127, 182, 129, 59, 98, 183, 207, 159, 167, 27, 149, 169, 74, 170, 255, 149, 57, 187, 223, 19, 162, 165, 18, 63, 50, 153, 100, 9, 247, 29, 231, 199, 141, 125, 148, 9, 183, 62, 244, 101, 50, 254, 146, 237, 122, 204, 152, 151, 197, 153, 31, 122, 219, 59, 230, 26, 123, 231, 100, 31, 201, 119, 175, 228, 12, 189, 233, 235, 65, 148, 46, 143, 49, 144, 44, 76, 79, 143, 126, 163, 219, 81, 122, 250, 102, 252, 179, 97, 116, 151, 128, 138, 29, 29, 171, 64, 93, 233, 245, 44, 35, 244, 249, 140, 160, 198, 188, 44, 120, 38, 104, 52, 107, 70, 115, 34, 239, 117, 195, 195, 20, 193, 85, 224, 22, 142, 205, 27, 155, 34, 62, 19, 32, 199, 200, 3, 59, 253, 188, 180, 177, 41, 150, 247, 98, 199, 127, 43, 239, 236, 116, 51, 19, 185, 188, 97, 156, 151, 64, 144, 20, 103, 61, 23, 210, 236, 235, 23, 216, 116, 121, 14, 191, 150, 210, 255, 195, 230, 167, 53, 254, 207, 35, 28, 18, 209, 240, 112, 156, 181, 151, 30, 81, 215, 6, 225, 106, 153, 48, 91, 102, 171, 115, 62, 46, 70, 255, 39, 183, 219, 199, 73, 97, 127, 92, 18, 153, 206, 150, 200, 7, 153, 82, 151, 34, 170, 177, 94, 178, 149, 202, 164, 210, 176, 112, 106, 73, 213, 101, 14, 195, 115, 168, 153, 217, 52, 76, 130, 116, 159, 226, 247, 234, 238, 6, 250, 141, 149, 133, 208, 40, 106, 172, 130, 187, 114, 216, 250, 124, 47, 4, 227, 198, 97, 125, 69, 2, 219, 87, 123, 79, 150, 116, 187, 239, 120, 236, 199, 185, 96, 30, 112, 233, 237, 179, 28, 46, 149, 102, 253, 150, 133, 179, 71, 7, 119, 201, 39, 196, 106, 251, 100, 195, 201, 47, 109, 227, 158, 27, 70, 207, 241, 222, 179, 225, 220, 189, 224, 97, 134, 11, 150, 127, 235, 224, 222, 110, 141, 224, 0, 167, 126, 72, 155, 185, 162, 128, 141, 120, 39, 165, 5, 211, 222, 20, 11, 129, 222, 142, 149, 130, 136, 106, 105, 118, 135, 9, 220, 180, 196, 117, 66, 82, 215, 186, 107, 252, 85, 41, 131, 238, 85, 233, 197, 228, 157, 49, 42, 57, 52, 40, 235, 240, 208, 248, 180, 26, 153, 227, 223, 33, 247, 236, 162, 226, 253, 63, 144, 199, 157, 164, 56, 185, 19, 8, 197, 210, 129, 90, 177, 16, 119, 165, 208, 244, 247, 253, 121, 10, 51, 15, 215, 140, 231, 51, 198, 168, 11, 54, 126, 135, 145, 13, 161, 192, 119, 16, 184, 30, 235, 23, 133, 20, 247, 139, 30, 235, 110, 211, 13, 39, 76, 4, 153, 83, 236, 215, 52, 107, 75, 188, 73, 74, 60, 203, 80, 194, 127, 7, 65, 225, 195, 139, 166, 176, 22, 151, 54, 204, 159, 5, 254, 82, 145, 230, 163, 254, 191, 206, 29, 198, 78, 198, 232, 238, 247, 104, 245, 100, 67, 108, 90, 88, 177, 136, 32, 28, 76, 108, 195, 172, 251, 121, 158, 23, 52, 33, 118, 205, 239, 50, 163, 118, 65, 150, 69, 109, 152, 70, 31, 235, 102, 126, 254, 209, 228, 148, 203, 137, 34, 20, 69, 141, 180, 177, 154, 155, 35, 101, 1, 78, 207, 67, 117, 29, 104, 9, 244, 3, 220, 131, 61, 190, 202, 53, 174} }; const uint8_t WPA2DecryptTest::tkip_packets[7][211] = { // Beacon {0, 0, 18, 0, 46, 72, 0, 0, 0, 2, 108, 9, 160, 0, 221, 3, 0, 0, 128, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 27, 17, 210, 27, 235, 0, 27, 17, 210, 27, 235, 128, 178, 129, 97, 244, 15, 0, 0, 0, 0, 100, 0, 17, 0, 0, 4, 78, 79, 68, 79, 1, 4, 130, 132, 139, 150, 3, 1, 1, 5, 4, 0, 1, 0, 0, 48, 20, 1, 0, 0, 15, 172, 2, 1, 0, 0, 15, 172, 2, 1, 0, 0, 15, 172, 2, 0, 0, 221, 9, 0, 3, 127, 1, 1, 0, 32, 255, 127}, // EAPOL keys {0, 0, 18, 0, 46, 72, 0, 0, 0, 22, 108, 9, 160, 0, 220, 3, 0, 0, 8, 2, 212, 0, 148, 12, 109, 143, 147, 136, 0, 27, 17, 210, 27, 235, 0, 27, 17, 210, 27, 235, 208, 178, 170, 170, 3, 0, 0, 0, 136, 142, 1, 3, 0, 95, 2, 0, 137, 0, 32, 0, 0, 0, 0, 0, 0, 0, 1, 22, 241, 158, 216, 151, 86, 157, 129, 160, 33, 116, 210, 24, 191, 213, 40, 130, 92, 75, 22, 151, 22, 95, 91, 248, 168, 188, 129, 250, 161, 255, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 18, 0, 46, 72, 0, 0, 0, 4, 108, 9, 160, 0, 217, 3, 0, 0, 8, 1, 2, 1, 0, 27, 17, 210, 27, 235, 148, 12, 109, 143, 147, 136, 0, 27, 17, 210, 27, 235, 16, 0, 170, 170, 3, 0, 0, 0, 136, 142, 1, 3, 0, 117, 2, 1, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 218, 108, 51, 136, 69, 196, 171, 10, 209, 139, 6, 156, 170, 155, 110, 241, 223, 96, 73, 83, 201, 28, 222, 131, 70, 209, 158, 97, 95, 244, 21, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 47, 4, 90, 85, 130, 65, 3, 66, 245, 143, 64, 146, 174, 5, 207, 0, 22, 48, 20, 1, 0, 0, 15, 172, 2, 1, 0, 0, 15, 172, 2, 1, 0, 0, 15, 172, 2, 0, 0}, {0, 0, 18, 0, 46, 72, 0, 0, 0, 11, 108, 9, 160, 0, 221, 3, 0, 0, 8, 2, 222, 0, 148, 12, 109, 143, 147, 136, 0, 27, 17, 210, 27, 235, 0, 27, 17, 210, 27, 235, 224, 178, 170, 170, 3, 0, 0, 0, 136, 142, 1, 3, 0, 157, 2, 19, 201, 0, 32, 0, 0, 0, 0, 0, 0, 0, 2, 22, 241, 158, 216, 151, 86, 157, 129, 160, 33, 116, 210, 24, 191, 213, 40, 130, 92, 75, 22, 151, 22, 95, 91, 248, 168, 188, 129, 250, 161, 255, 151, 130, 92, 75, 22, 151, 22, 95, 91, 248, 168, 188, 129, 250, 161, 255, 152, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 200, 127, 245, 65, 126, 225, 15, 125, 92, 194, 78, 120, 25, 55, 127, 161, 0, 62, 177, 70, 196, 230, 213, 190, 41, 84, 138, 229, 131, 21, 227, 143, 239, 152, 60, 170, 35, 101, 197, 230, 223, 109, 20, 24, 167, 6, 69, 155, 148, 212, 94, 203, 228, 45, 8, 69, 76, 47, 148, 124, 147, 146, 141, 231, 60, 11, 189, 254, 170, 106, 73, 190, 229, 99, 202, 247, 41, 133, 130, 175}, {0, 0, 18, 0, 46, 72, 0, 0, 0, 4, 108, 9, 160, 0, 218, 3, 0, 0, 8, 1, 2, 1, 0, 27, 17, 210, 27, 235, 148, 12, 109, 143, 147, 136, 0, 27, 17, 210, 27, 235, 32, 0, 170, 170, 3, 0, 0, 0, 136, 142, 1, 3, 0, 95, 2, 3, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 178, 109, 5, 166, 193, 94, 143, 159, 84, 66, 114, 244, 166, 240, 46, 1, 0, 0}, // HTTP data {0, 0, 18, 0, 46, 72, 0, 0, 0, 22, 108, 9, 160, 0, 217, 3, 0, 0, 8, 65, 213, 0, 0, 27, 17, 210, 27, 235, 148, 12, 109, 143, 147, 136, 0, 27, 17, 210, 27, 235, 176, 50, 3, 35, 41, 32, 0, 0, 0, 0, 119, 117, 235, 153, 200, 251, 227, 211, 149, 31, 231, 139, 36, 2, 146, 81, 132, 63, 193, 42, 220, 53, 70, 104, 119, 139, 60, 76, 204, 96, 218, 54, 101, 218, 192, 111, 144, 148, 97, 141, 252, 180, 201, 214, 206, 191, 242, 102, 114, 76, 237, 61, 190, 167, 5, 132, 128, 149, 38, 88, 155, 242, 191, 244, 202, 206, 175, 80, 15, 124, 44, 108, 39, 224, 72, 217, 38, 175, 70, 187, 224, 215, 21, 143}, {0, 0, 18, 0, 46, 72, 0, 0, 0, 22, 108, 9, 160, 0, 218, 3, 0, 0, 8, 65, 213, 0, 0, 27, 17, 210, 27, 235, 148, 12, 109, 143, 147, 136, 0, 27, 17, 210, 27, 235, 192, 50, 3, 35, 42, 32, 0, 0, 0, 0, 168, 193, 175, 225, 65, 44, 37, 61, 12, 214, 29, 41, 12, 133, 137, 107, 94, 99, 138, 118, 238, 219, 83, 108, 25, 181, 195, 163, 47, 193, 177, 2, 53, 152, 111, 13, 169, 165, 84, 127, 163, 139, 194, 120, 242, 195, 144, 28, 13, 162, 53, 143, 220, 86, 40, 217, 222, 38, 69, 206, 184, 38, 125, 79, 210, 85, 1, 129, 2, 190, 26, 109, 243, 227, 75, 176, 160, 86, 158, 124, 41, 153, 11, 0} }; const size_t WPA2DecryptTest::ccmp_packets_size[] = { 168, 181, 181, 239, 159, 404, 652 }; const size_t WPA2DecryptTest::tkip_packets_size[] = { 108, 149, 171, 211, 149, 134, 134 }; void WPA2DecryptTest::check_ccmp_packet5(const PDU &pdu) { const UDP *udp = pdu.find_pdu(); ASSERT_TRUE(udp); EXPECT_EQ(udp->sport(), 68); EXPECT_EQ(udp->dport(), 67); } void WPA2DecryptTest::check_ccmp_packet6(const PDU &pdu) { const UDP *udp = pdu.find_pdu(); ASSERT_TRUE(udp); EXPECT_EQ(udp->sport(), 67); EXPECT_EQ(udp->dport(), 68); } void WPA2DecryptTest::check_tkip_packet5(const PDU &pdu) { const TCP *tcp = pdu.find_pdu(); ASSERT_TRUE(tcp); EXPECT_EQ(tcp->sport(), 44934); EXPECT_EQ(tcp->dport(), 80); EXPECT_EQ(tcp->window(), 1215); } void WPA2DecryptTest::check_tkip_packet6(const PDU &pdu) { const TCP *tcp = pdu.find_pdu(); ASSERT_TRUE(tcp); EXPECT_EQ(tcp->sport(), 44934); EXPECT_EQ(tcp->dport(), 80); EXPECT_EQ(tcp->window(), 1204); } TEST_F(WPA2DecryptTest, DecryptCCMPUsingBeacon) { Crypto::WPA2Decrypter decrypter; decrypter.add_ap_data("Induction", "Coherer"); for(size_t i = 0; i < 7; ++i) { RadioTap radio(ccmp_packets[i], ccmp_packets_size[i]); if(i > 4) { ASSERT_TRUE(decrypter.decrypt(radio)); if(i == 5) check_ccmp_packet5(radio); else check_ccmp_packet6(radio); } else ASSERT_FALSE(decrypter.decrypt(radio)); } } TEST_F(WPA2DecryptTest, DecryptCCMPWithoutUsingBeacon) { Crypto::WPA2Decrypter decrypter; decrypter.add_ap_data("Induction", "Coherer", "00:0c:41:82:b2:55"); for(size_t i = 1; i < 7; ++i) { RadioTap radio(ccmp_packets[i], ccmp_packets_size[i]); if(i > 4) { ASSERT_TRUE(decrypter.decrypt(radio)); if(i == 5) check_ccmp_packet5(radio); else check_ccmp_packet6(radio); } else ASSERT_FALSE(decrypter.decrypt(radio)); } } TEST_F(WPA2DecryptTest, DecryptTKIPUsingBeacon) { Crypto::WPA2Decrypter decrypter; decrypter.add_ap_data("libtinstest", "NODO"); for(size_t i = 0; i < 7; ++i) { RadioTap radio(tkip_packets[i], tkip_packets_size[i]); if(i > 4) { ASSERT_TRUE(decrypter.decrypt(radio)); if(i == 5) check_tkip_packet5(radio); else check_tkip_packet6(radio); } else ASSERT_FALSE(decrypter.decrypt(radio)); } } TEST_F(WPA2DecryptTest, DecryptTKIPWithoutUsingBeacon) { Crypto::WPA2Decrypter decrypter; decrypter.add_ap_data("libtinstest", "NODO", "00:1b:11:d2:1b:eb"); for(size_t i = 1; i < 7; ++i) { RadioTap radio(tkip_packets[i], tkip_packets_size[i]); if(i > 4) { ASSERT_TRUE(decrypter.decrypt(radio)); if(i == 5) check_tkip_packet5(radio); else check_tkip_packet6(radio); } else ASSERT_FALSE(decrypter.decrypt(radio)); } } TEST_F(WPA2DecryptTest, DecryptCCMPAndTKIPUsingBeacon) { Crypto::WPA2Decrypter decrypter; decrypter.add_ap_data("libtinstest", "NODO"); decrypter.add_ap_data("Induction", "Coherer"); for(size_t i = 0; i < 7; ++i) { RadioTap radio(ccmp_packets[i], ccmp_packets_size[i]); if(i > 4) { ASSERT_TRUE(decrypter.decrypt(radio)); if(i == 5) check_ccmp_packet5(radio); else check_ccmp_packet6(radio); } else ASSERT_FALSE(decrypter.decrypt(radio)); } for(size_t i = 0; i < 7; ++i) { RadioTap radio(tkip_packets[i], tkip_packets_size[i]); if(i > 4) { ASSERT_TRUE(decrypter.decrypt(radio)); if(i == 5) check_tkip_packet5(radio); else check_tkip_packet6(radio); } else ASSERT_FALSE(decrypter.decrypt(radio)); } } TEST_F(WPA2DecryptTest, DecryptCCMPAndTKIPWithoutUsingBeacon) { Crypto::WPA2Decrypter decrypter; decrypter.add_ap_data("libtinstest", "NODO", "00:1b:11:d2:1b:eb"); decrypter.add_ap_data("Induction", "Coherer", "00:0c:41:82:b2:55"); for(size_t i = 1; i < 7; ++i) { RadioTap radio(ccmp_packets[i], ccmp_packets_size[i]); if(i > 4) { ASSERT_TRUE(decrypter.decrypt(radio)); if(i == 5) check_ccmp_packet5(radio); else check_ccmp_packet6(radio); } else ASSERT_FALSE(decrypter.decrypt(radio)); } for(size_t i = 1; i < 7; ++i) { RadioTap radio(tkip_packets[i], tkip_packets_size[i]); if(i > 4) { ASSERT_TRUE(decrypter.decrypt(radio)); if(i == 5) check_tkip_packet5(radio); else check_tkip_packet6(radio); } else ASSERT_FALSE(decrypter.decrypt(radio)); } } libtins-1.1/tests/src/wep_decrypt.cpp0000664000175000017500000000265012154360113017320 0ustar matiasmatias#include #include #include #include #include "crypto.h" #include "arp.h" #include "dot11/dot11_data.h" using namespace Tins; class WEPDecryptTest : public testing::Test { public: static const uint8_t expected_packet[]; }; // packet taken from aircrack's site. const uint8_t WEPDecryptTest::expected_packet[] = { 8, 66, 0, 0, 255, 255, 255, 255, 255, 255, 0, 18, 191, 18, 50, 41, 0, 13, 84, 161, 160, 76, 224, 123, 205, 210, 58, 0, 197, 228, 176, 195, 234, 135, 161, 205, 155, 75, 35, 247, 7, 96, 17, 234, 15, 141, 137, 251, 20, 68, 48, 171, 27, 11, 244, 76, 43, 50, 130, 40, 129, 37, 30, 61, 8, 41, 145, 93, 88, 55, 194, 210, 247, 237, 236, 134, 182, 216, 85, 225, 102, 139, 93, 178, 214, 154 }; TEST_F(WEPDecryptTest, Decrypt1) { Dot11Data dot11(expected_packet, sizeof(expected_packet)); Crypto::WEPDecrypter decrypter; decrypter.add_password("00:12:bf:12:32:29", "\x1f\x1f\x1f\x1f\x1f"); ASSERT_TRUE(decrypter.decrypt(dot11)); ARP *arp = dot11.find_pdu(); ASSERT_TRUE(arp); EXPECT_EQ(arp->sender_hw_addr(), "00:0e:a6:6b:fb:69"); EXPECT_EQ(arp->target_hw_addr(), "00:00:00:00:00:00"); EXPECT_EQ(arp->sender_ip_addr(), "172.16.0.1"); EXPECT_EQ(arp->target_ip_addr(), "172.16.0.240"); decrypter.add_password("00:12:bf:12:32:29", "\x1f\x1f\x1f\x1f\x1e"); EXPECT_FALSE(decrypter.decrypt(dot11)); } libtins-1.1/tests/src/utils.cpp0000664000175000017500000001013112154360113016124 0ustar matiasmatias#include #include #include #include "utils.h" #include "endianness.h" #include "ip_address.h" #include "ipv6_address.h" using namespace Tins; class UtilsTest : public testing::Test { public: static const uint32_t zero_int_ip; // "0.0.0.0" static const uint32_t full_int_ip; // "255.255.255.255" static const uint32_t mix_int_ip; // "1.2.255.3" static const uint8_t zero_hw_addr[]; static const uint8_t full_hw_addr[]; static const uint8_t mix_hw_addr[]; static const uint8_t data[]; static const uint32_t data_len; }; const uint32_t UtilsTest::zero_int_ip = 0; // "0.0.0.0" const uint32_t UtilsTest::full_int_ip = 0xFFFFFFFF; // "255.255.255.255" const uint32_t UtilsTest::mix_int_ip = 0x0102FF03; // "1.2.255.3" const uint8_t UtilsTest::zero_hw_addr[] = { 0, 0, 0, 0, 0, 0 }; const uint8_t UtilsTest::full_hw_addr[] = { 255, 255, 255, 255, 255, 255 }; const uint8_t UtilsTest::mix_hw_addr[] = { 1, 2, 3, 4, 5, 6 }; const uint8_t UtilsTest::data[] = { 215, 3, 132, 147, 170, 153, 240, 223, 227, 47, 144, 146, 52, 154, 192, 106, 195, 167, 160, 119, 154, 134, 59, 150, 6, 236, 67, 216, 7, 19, 110, 226, 228, 99, 103, 18, 39, 23, 157, 192, 38, 37, 23, 211, 77, 86, 176, 103, 62, 226, 235, 236, 114, 39, 216, 202, 236, 251, 158, 249, 89, 248, 80, 95, 245, 35, 61, 97, 242, 90, 122, 196, 187, 202, 15, 197, 204, 180, 183, 68, 65, 99, 209, 172, 80, 189, 188, 18, 216, 82, 103, 53, 3, 246, 183, 4, 56, 201, 5, 42, 94, 108, 30, 90, 183, 203, 193, 19, 128, 79, 156, 189, 18, 163, 67, 152, 153, 114, 151, 125, 114, 87, 105, 31, 212, 238, 154, 238, 82, 216, 244, 2, 33, 137, 126, 67, 176, 224, 95, 175, 205, 175, 91, 41, 101, 34, 178, 199, 88, 211, 91, 235, 42, 21, 182, 138, 185, 61, 205, 61, 245, 85, 18, 119, 253, 214, 127, 164, 31, 225, 140, 58, 103, 235, 231, 226, 119, 97, 86, 11, 56, 95, 218, 207, 137, 216, 141, 46, 82, 39, 158, 243, 131, 217, 197, 177, 239, 30, 145, 249, 162, 141, 252, 213, 132, 87, 42, 130, 213, 92, 47, 163, 113, 230, 59, 205, 19, 90, 65, 134, 181, 44, 150, 254, 73, 186, 194, 122, 96, 65, 114, 233, 245, 25, 194, 80, 174, 223, 158, 45, 131, 188, 222, 52, 212, 250, 96, 172, 181, 115, 252, 40, 249, 99, 65, 23, 118, 71, 124, 112, 228, 204, 106, 169, 40, 148, 72, 183, 252, 234, 83, 116, 109, 54, 233, 58, 231, 5, 88, 36, 77, 253, 75, 90, 250, 177, 159, 199, 180, 134, 211, 161, 175, 75, 161, 72, 80, 73, 163, 76, 160, 119, 226, 248, 231, 62, 91, 74, 32, 156, 9, 64, 170, 79, 38, 45, 204, 58, 144, 76, 226, 130, 21, 151, 239, 40, 116, 52, 77, 18, 6, 199, 42, 200, 213, 232, 12, 61, 156, 51, 23, 165, 11, 7, 149, 30, 27, 119, 216, 246, 93, 24, 111, 105, 218, 100, 45, 57, 69, 229, 168, 105, 99, 35, 41, 71, 255, 80, 255, 22, 7, 61, 211, 134, 113, 48, 255, 220, 26, 32, 6, 184, 204, 40, 194, 47, 201, 249, 133, 194, 203, 172, 123, 186, 77, 39, 92, 64, 52, 91, 187, 83, 58, 73, 65, 192, 150, 103, 230, 187, 165, 149, 84, 71, 142, 55, 69, 87, 102, 97, 20, 134, 184, 107, 133, 57, 57, 220, 121, 211, 241, 97, 172, 67, 208, 9, 151, 14, 200, 73, 31, 140, 34, 176, 215, 111, 4, 143, 13, 173, 193, 145, 255, 112, 249, 191, 88, 181, 113, 221, 50, 45, 34, 176, 203, 154, 65, 193, 6, 120, 182, 235, 250, 21, 136, 44, 21, 29, 6, 150, 194, 117, 118, 237, 0, 223, 207, 161, 58, 229, 174, 101, 101, 195, 17, 249, 12, 137, 177, 161 }; const uint32_t UtilsTest::data_len = 500; TEST_F(UtilsTest, Crc32) { uint32_t crc = Utils::crc32(data, data_len); EXPECT_EQ(crc, 0x78840f54); } TEST_F(UtilsTest, ResolveDomain) { IPv4Address localhost_ip("127.0.0.1"); EXPECT_EQ(Utils::resolve_domain("localhost"), localhost_ip); } TEST_F(UtilsTest, ResolveDomain6) { IPv6Address localhost_ip("2001:500:88:200::10"); EXPECT_EQ(Utils::resolve_domain6("example.com"), localhost_ip); } // FIXME TEST_F(UtilsTest, Checksum) { /*uint16_t checksum = Utils::do_checksum(data, data + data_len); //EXPECT_EQ(checksum, 0x231a); uint8_t my_data[] = {0, 0, 0, 0}; checksum = Utils::do_checksum(my_data, my_data + 4); //EXPECT_EQ(checksum, 0xFFFF); */ } libtins-1.1/tests/src/udp.cpp0000664000175000017500000000740512154360113015566 0ustar matiasmatias#include #include #include #include "udp.h" #include "ip.h" using namespace std; using namespace Tins; class UDPTest : public testing::Test { public: static const uint8_t expected_packet[], checksum_packet[]; void test_equals(const UDP& udp1, const UDP& udp2); }; const uint8_t UDPTest::expected_packet[] = { 245, 26, 71, 241, 8, 0, 0, 0 }; const uint8_t UDPTest::checksum_packet[] = { 69, 0, 0, 48, 35, 109, 64, 0, 64, 17, 25, 78, 0, 0, 0, 0, 127, 0, 0, 1, 5, 57, 155, 11, 0, 28, 84, 167, 97, 115, 100, 97, 115, 100, 115, 97, 115, 100, 97, 115, 100, 115, 97, 100, 97, 115, 100, 10 }; void UDPTest::test_equals(const UDP& udp1, const UDP& udp2) { EXPECT_EQ(udp1.dport(), udp2.dport()); EXPECT_EQ(udp1.sport(), udp2.sport()); EXPECT_EQ(udp1.length(), udp2.length()); EXPECT_EQ(udp1.size(), udp2.size()); EXPECT_EQ(udp1.header_size(), udp2.header_size()); EXPECT_EQ(bool(udp1.inner_pdu()), bool(udp2.inner_pdu())); } TEST_F(UDPTest, DefaultContructor) { UDP udp; EXPECT_EQ(udp.dport(), 0); EXPECT_EQ(udp.sport(), 0); EXPECT_FALSE(udp.inner_pdu()); } TEST_F(UDPTest, ChecksumCheck) { IP pkt1(checksum_packet, sizeof(checksum_packet)); const UDP &udp1 = pkt1.rfind_pdu(); uint16_t checksum = udp1.checksum(); IP::serialization_type buffer = pkt1.serialize(); IP pkt2(&buffer[0], buffer.size()); const UDP &udp2 = pkt2.rfind_pdu(); EXPECT_EQ(checksum, udp2.checksum()); EXPECT_EQ(udp1.checksum(), udp2.checksum()); } TEST_F(UDPTest, CopyContructor) { UDP udp1(expected_packet, sizeof(expected_packet)); UDP udp2(udp1); test_equals(udp1, udp2); } TEST_F(UDPTest, CopyAssignmentOperator) { UDP udp1(expected_packet, sizeof(expected_packet)); UDP udp2; udp2 = udp1; test_equals(udp1, udp2); } TEST_F(UDPTest, CompleteConstructor) { UDP udp(0x1234, 0x4321); EXPECT_EQ(udp.dport(), 0x1234); EXPECT_EQ(udp.sport(), 0x4321); } TEST_F(UDPTest, DPort) { UDP udp; uint16_t port = 0x1234; udp.dport(port); ASSERT_EQ(udp.dport(), port); } TEST_F(UDPTest, SPort) { UDP udp; uint16_t port = 0x1234; udp.sport(port); ASSERT_EQ(udp.sport(), port); } TEST_F(UDPTest, Length) { UDP udp; uint16_t length = 0x1234; udp.length(length); ASSERT_EQ(udp.length(), length); } TEST_F(UDPTest, PDUType) { UDP udp; EXPECT_EQ(udp.pdu_type(), PDU::UDP); } TEST_F(UDPTest, ClonePDU) { UDP udp1; uint16_t sport = 0x1234, dport = 0x4321, length = 0xdead; udp1.dport(dport); udp1.sport(sport); udp1.length(length); UDP *udp2 = udp1.clone(); ASSERT_TRUE(udp2); EXPECT_EQ(udp2->sport(), sport); EXPECT_EQ(udp2->dport(), dport); EXPECT_EQ(udp2->length(), length); EXPECT_EQ(udp2->pdu_type(), PDU::UDP); delete udp2; } TEST_F(UDPTest, Serialize) { UDP udp1; uint16_t sport = 0x1234, dport = 0x4321, length = 0xdead; udp1.dport(dport); udp1.sport(sport); udp1.length(length); PDU::serialization_type buffer = udp1.serialize(); UDP udp2(udp1); PDU::serialization_type buffer2 = udp2.serialize(); EXPECT_EQ(buffer, buffer2); } TEST_F(UDPTest, ConstructorFromBuffer) { UDP udp1(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = udp1.serialize(); EXPECT_EQ(buffer.size(), sizeof(expected_packet)); EXPECT_EQ(udp1.dport(), 0x47f1); EXPECT_EQ(udp1.sport(), 0xf51a); EXPECT_EQ(udp1.length(), 8); UDP udp2(&buffer[0], buffer.size()); EXPECT_EQ(udp1.dport(), udp2.dport()); EXPECT_EQ(udp1.sport(), udp2.sport()); EXPECT_EQ(udp1.length(), udp2.length()); EXPECT_EQ(udp1.size(), udp2.size()); EXPECT_EQ(udp1.header_size(), udp2.header_size()); } libtins-1.1/tests/src/tcp_stream.cpp0000664000175000017500000004602412154360113017137 0ustar matiasmatias#include #include #include #include #include "tcp_stream.h" #include "tcp.h" #include "utils.h" using namespace Tins; class TCPStreamTest : public testing::Test { public: static const size_t num_packets = 20; static EthernetII packets[]; static const size_t indexes[][num_packets]; static const std::string payload; static void end_handle(TCPStream& session); static size_t index; static bool processed_stream; }; size_t TCPStreamTest::index; bool TCPStreamTest::processed_stream; EthernetII TCPStreamTest::packets[] = { EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x3c\xfd\x03\x40\x00\x40\x06\x3f\xb6\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x0f\x76\x00\x00\x00\x00\xa0\x02\x80\x18\xfe\x30\x00\x00\x02\x04\x40\x0c\x04\x02\x08\x0a\x2d\x1a\xf2\x75\x00\x00\x00\x00\x01\x03\x03\x04", 74), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x3c\x00\x00\x40\x00\x40\x06\x3c\xba\x7f\x00\x00\x01\x7f\x00\x00\x01\x0b\xb8\xa3\x78\x37\x67\x56\xd3\xb1\xe6\x0f\x77\xa0\x12\x80\x00\xfe\x30\x00\x00\x02\x04\x40\x0c\x04\x02\x08\x0a\x2d\x1a\xf2\x75\x2d\x1a\xf2\x75\x01\x03\x03\x04", 74), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xfd\x04\x40\x00\x40\x06\x3f\xbd\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x0f\x77\x37\x67\x56\xd4\x80\x10\x08\x02\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1a\xf2\x75\x2d\x1a\xf2\x75", 66), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x01\xb1\xfd\x05\x40\x00\x40\x06\x3e\x3f\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x0f\x77\x37\x67\x56\xd4\x80\x18\x08\x02\xff\xa5\x00\x00\x01\x01\x08\x0a\x2d\x1a\xf4\x86\x2d\x1a\xf2\x75\x4c\x6f\x72\x65\x6d\x20\x69\x70\x73\x75\x6d\x20\x64\x6f\x6c\x6f\x72\x20\x73\x69\x74\x20\x61\x6d\x65\x74\x2c\x20\x63\x6f\x6e\x73\x65\x63\x74\x65\x74\x75\x72\x20\x61\x64\x69\x70\x69\x73\x63\x69\x6e\x67\x20\x65\x6c\x69\x74\x2e\x20\x53\x65\x64\x20\x61\x74\x20\x61\x6c\x69\x71\x75\x61\x6d\x20\x61\x72\x63\x75\x2e\x20\x53\x65\x64\x20\x61\x74\x20\x69\x61\x63\x75\x6c\x69\x73\x20\x6d\x61\x67\x6e\x61\x2e\x20\x4e\x61\x6d\x20\x75\x74\x20\x64\x6f\x6c\x6f\x72\x20\x65\x67\x65\x74\x20\x76\x65\x6c\x69\x74\x20\x6d\x61\x74\x74\x69\x73\x20\x70\x6f\x73\x75\x65\x72\x65\x20\x75\x74\x20\x6e\x6f\x6e\x20\x64\x75\x69\x2e\x20\x41\x6c\x69\x71\x75\x61\x6d\x20\x66\x61\x75\x63\x69\x62\x75\x73\x20\x65\x72\x61\x74\x20\x70\x72\x65\x74\x69\x75\x6d\x20\x6c\x69\x67\x75\x6c\x61\x20\x74\x69\x6e\x63\x69\x64\x75\x6e\x74\x20\x65\x67\x65\x74\x20\x74\x72\x69\x73\x74\x69\x71\x75\x65\x20\x6a\x75\x73\x74\x6f\x20\x70\x6c\x61\x63\x65\x72\x61\x74\x2e\x20\x50\x68\x61\x73\x65\x6c\x6c\x75\x73\x20\x74\x75\x72\x70\x69\x73\x20\x74\x65\x6c\x6c\x75\x73\x2c\x20\x6f\x72\x6e\x61\x72\x65\x20\x75\x6c\x74\x72\x69\x63\x69\x65\x73\x20\x65\x67\x65\x73\x74\x61\x73\x20\x76\x69\x74\x61\x65\x2c\x20\x6d\x6f\x6c\x6c\x69\x73\x20\x73\x65\x64\x20\x6e\x65\x71\x75\x65\x2e\x20\x53\x65\x64\x20\x65\x74\x20\x6c\x69\x62\x65\x72\x6f\x20\x69\x6e\x20\x6e\x75\x6e\x63\x20\x70\x68\x61\x72\x65\x74\x72\x61\x20\x61\x75\x63\x74\x6f\x72\x20\x75\x74\x20\x61\x20\x65\x72\x6f\x73\x2e\x20\x4d\x61\x75\x72\x69\x73\x20\x71\x75\x69\x73\x20\x66\x61\x75\x63\x69\x62\x75\x73\x20\x6e\x69\x62\x68\x2e\x20\x0a", 447), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xa4\xa1\x40\x00\x40\x06\x98\x20\x7f\x00\x00\x01\x7f\x00\x00\x01\x0b\xb8\xa3\x78\x37\x67\x56\xd4\xb1\xe6\x10\xf4\x80\x10\x08\x43\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1a\xf4\x86\x2d\x1a\xf4\x86", 66), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x01\xb1\xfd\x06\x40\x00\x40\x06\x3e\x3e\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x10\xf4\x37\x67\x56\xd4\x80\x18\x08\x02\xff\xa5\x00\x00\x01\x01\x08\x0a\x2d\x1a\xf8\xba\x2d\x1a\xf4\x86\x4c\x6f\x72\x65\x6d\x20\x69\x70\x73\x75\x6d\x20\x64\x6f\x6c\x6f\x72\x20\x73\x69\x74\x20\x61\x6d\x65\x74\x2c\x20\x63\x6f\x6e\x73\x65\x63\x74\x65\x74\x75\x72\x20\x61\x64\x69\x70\x69\x73\x63\x69\x6e\x67\x20\x65\x6c\x69\x74\x2e\x20\x53\x65\x64\x20\x61\x74\x20\x61\x6c\x69\x71\x75\x61\x6d\x20\x61\x72\x63\x75\x2e\x20\x53\x65\x64\x20\x61\x74\x20\x69\x61\x63\x75\x6c\x69\x73\x20\x6d\x61\x67\x6e\x61\x2e\x20\x4e\x61\x6d\x20\x75\x74\x20\x64\x6f\x6c\x6f\x72\x20\x65\x67\x65\x74\x20\x76\x65\x6c\x69\x74\x20\x6d\x61\x74\x74\x69\x73\x20\x70\x6f\x73\x75\x65\x72\x65\x20\x75\x74\x20\x6e\x6f\x6e\x20\x64\x75\x69\x2e\x20\x41\x6c\x69\x71\x75\x61\x6d\x20\x66\x61\x75\x63\x69\x62\x75\x73\x20\x65\x72\x61\x74\x20\x70\x72\x65\x74\x69\x75\x6d\x20\x6c\x69\x67\x75\x6c\x61\x20\x74\x69\x6e\x63\x69\x64\x75\x6e\x74\x20\x65\x67\x65\x74\x20\x74\x72\x69\x73\x74\x69\x71\x75\x65\x20\x6a\x75\x73\x74\x6f\x20\x70\x6c\x61\x63\x65\x72\x61\x74\x2e\x20\x50\x68\x61\x73\x65\x6c\x6c\x75\x73\x20\x74\x75\x72\x70\x69\x73\x20\x74\x65\x6c\x6c\x75\x73\x2c\x20\x6f\x72\x6e\x61\x72\x65\x20\x75\x6c\x74\x72\x69\x63\x69\x65\x73\x20\x65\x67\x65\x73\x74\x61\x73\x20\x76\x69\x74\x61\x65\x2c\x20\x6d\x6f\x6c\x6c\x69\x73\x20\x73\x65\x64\x20\x6e\x65\x71\x75\x65\x2e\x20\x53\x65\x64\x20\x65\x74\x20\x6c\x69\x62\x65\x72\x6f\x20\x69\x6e\x20\x6e\x75\x6e\x63\x20\x70\x68\x61\x72\x65\x74\x72\x61\x20\x61\x75\x63\x74\x6f\x72\x20\x75\x74\x20\x61\x20\x65\x72\x6f\x73\x2e\x20\x4d\x61\x75\x72\x69\x73\x20\x71\x75\x69\x73\x20\x66\x61\x75\x63\x69\x62\x75\x73\x20\x6e\x69\x62\x68\x2e\x20\x0a", 447), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xa4\xa2\x40\x00\x40\x06\x98\x1f\x7f\x00\x00\x01\x7f\x00\x00\x01\x0b\xb8\xa3\x78\x37\x67\x56\xd4\xb1\xe6\x12\x71\x80\x10\x08\x86\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1a\xf8\xba\x2d\x1a\xf8\xba", 66), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x35\xfd\x07\x40\x00\x40\x06\x3f\xb9\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x12\x71\x37\x67\x56\xd4\x80\x18\x08\x02\xfe\x29\x00\x00\x01\x01\x08\x0a\x2d\x1b\x00\x4a\x2d\x1a\xf8\xba\x0a", 67), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xa4\xa3\x40\x00\x40\x06\x98\x1e\x7f\x00\x00\x01\x7f\x00\x00\x01\x0b\xb8\xa3\x78\x37\x67\x56\xd4\xb1\xe6\x12\x72\x80\x10\x08\x86\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1b\x00\x4a\x2d\x1b\x00\x4a", 66), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x35\xfd\x08\x40\x00\x40\x06\x3f\xb8\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x12\x72\x37\x67\x56\xd4\x80\x18\x08\x02\xfe\x29\x00\x00\x01\x01\x08\x0a\x2d\x1b\x00\x4a\x2d\x1b\x00\x4a\x0a", 67), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xa4\xa4\x40\x00\x40\x06\x98\x1d\x7f\x00\x00\x01\x7f\x00\x00\x01\x0b\xb8\xa3\x78\x37\x67\x56\xd4\xb1\xe6\x12\x73\x80\x10\x08\x86\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1b\x00\x4a\x2d\x1b\x00\x4a", 66), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x01\xfa\xfd\x09\x40\x00\x40\x06\x3d\xf2\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x12\x73\x37\x67\x56\xd4\x80\x18\x08\x02\xff\xee\x00\x00\x01\x01\x08\x0a\x2d\x1b\x00\x96\x2d\x1b\x00\x4a\x43\x75\x72\x61\x62\x69\x74\x75\x72\x20\x73\x65\x6d\x20\x65\x72\x61\x74\x2c\x20\x62\x69\x62\x65\x6e\x64\x75\x6d\x20\x71\x75\x69\x73\x20\x63\x6f\x6e\x64\x69\x6d\x65\x6e\x74\x75\x6d\x20\x75\x74\x2c\x20\x69\x6d\x70\x65\x72\x64\x69\x65\x74\x20\x61\x74\x20\x65\x73\x74\x2e\x20\x44\x75\x69\x73\x20\x73\x61\x67\x69\x74\x74\x69\x73\x20\x72\x68\x6f\x6e\x63\x75\x73\x20\x66\x65\x6c\x69\x73\x20\x61\x74\x20\x75\x6c\x74\x72\x69\x63\x69\x65\x73\x2e\x20\x49\x6e\x20\x6c\x69\x62\x65\x72\x6f\x20\x75\x72\x6e\x61\x2c\x20\x64\x69\x67\x6e\x69\x73\x73\x69\x6d\x20\x65\x75\x20\x65\x6c\x65\x6d\x65\x6e\x74\x75\x6d\x20\x71\x75\x69\x73\x2c\x20\x63\x6f\x6e\x73\x65\x63\x74\x65\x74\x75\x72\x20\x61\x20\x6e\x65\x71\x75\x65\x2e\x20\x50\x72\x61\x65\x73\x65\x6e\x74\x20\x6c\x65\x6f\x20\x73\x65\x6d\x2c\x20\x63\x75\x72\x73\x75\x73\x20\x73\x65\x64\x20\x6c\x6f\x62\x6f\x72\x74\x69\x73\x20\x73\x69\x74\x20\x61\x6d\x65\x74\x2c\x20\x6f\x72\x6e\x61\x72\x65\x20\x61\x63\x20\x61\x75\x67\x75\x65\x2e\x20\x4d\x61\x75\x72\x69\x73\x20\x74\x72\x69\x73\x74\x69\x71\x75\x65\x20\x73\x65\x6d\x70\x65\x72\x20\x69\x70\x73\x75\x6d\x20\x61\x74\x20\x63\x6f\x6e\x73\x65\x71\x75\x61\x74\x2e\x20\x53\x65\x64\x20\x66\x72\x69\x6e\x67\x69\x6c\x6c\x61\x20\x64\x6f\x6c\x6f\x72\x20\x75\x74\x20\x6c\x61\x63\x75\x73\x20\x73\x61\x67\x69\x74\x74\x69\x73\x20\x71\x75\x69\x73\x20\x75\x6c\x74\x72\x69\x63\x69\x65\x73\x20\x6c\x65\x6f\x20\x76\x75\x6c\x70\x75\x74\x61\x74\x65\x2e\x20\x4d\x61\x65\x63\x65\x6e\x61\x73\x20\x64\x69\x67\x6e\x69\x73\x73\x69\x6d\x20\x69\x6d\x70\x65\x72\x64\x69\x65\x74\x20\x6a\x75\x73\x74\x6f\x2e\x20\x43\x72\x61\x73\x20\x6c\x69\x62\x65\x72\x6f\x20\x6f\x64\x69\x6f\x2c\x20\x76\x65\x68\x69\x63\x75\x6c\x61\x20\x65\x74\x20\x61\x64\x69\x70\x69\x73\x63\x69\x6e\x67\x20\x71\x75\x69\x73\x2c\x20\x6c\x75\x63\x74\x75\x73\x20\x76\x65\x6c\x20\x61\x6e\x74\x65\x2e\x20\x0a", 520), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xa4\xa5\x40\x00\x40\x06\x98\x1c\x7f\x00\x00\x01\x7f\x00\x00\x01\x0b\xb8\xa3\x78\x37\x67\x56\xd4\xb1\xe6\x14\x39\x80\x10\x08\xc9\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1b\x00\x96\x2d\x1b\x00\x96", 66), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x02\x35\xfd\x0a\x40\x00\x40\x06\x3d\xb6\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x14\x39\x37\x67\x56\xd4\x80\x18\x08\x02\x00\x2a\x00\x00\x01\x01\x08\x0a\x2d\x1b\x04\xba\x2d\x1b\x00\x96\x41\x6c\x69\x71\x75\x61\x6d\x20\x69\x6d\x70\x65\x72\x64\x69\x65\x74\x20\x65\x73\x74\x20\x71\x75\x69\x73\x20\x6e\x75\x6e\x63\x20\x6d\x61\x6c\x65\x73\x75\x61\x64\x61\x20\x65\x67\x65\x74\x20\x63\x6f\x6e\x76\x61\x6c\x6c\x69\x73\x20\x74\x65\x6c\x6c\x75\x73\x20\x75\x6c\x6c\x61\x6d\x63\x6f\x72\x70\x65\x72\x2e\x20\x56\x69\x76\x61\x6d\x75\x73\x20\x75\x6c\x6c\x61\x6d\x63\x6f\x72\x70\x65\x72\x20\x65\x72\x6f\x73\x20\x73\x69\x74\x20\x61\x6d\x65\x74\x20\x6f\x64\x69\x6f\x20\x73\x6f\x6c\x6c\x69\x63\x69\x74\x75\x64\x69\x6e\x20\x72\x75\x74\x72\x75\x6d\x2e\x20\x44\x6f\x6e\x65\x63\x20\x70\x65\x6c\x6c\x65\x6e\x74\x65\x73\x71\x75\x65\x20\x66\x61\x75\x63\x69\x62\x75\x73\x20\x6e\x75\x6c\x6c\x61\x2c\x20\x75\x74\x20\x66\x72\x69\x6e\x67\x69\x6c\x6c\x61\x20\x72\x69\x73\x75\x73\x20\x61\x6c\x69\x71\x75\x61\x6d\x20\x65\x67\x65\x74\x2e\x20\x53\x65\x64\x20\x65\x74\x20\x61\x6e\x74\x65\x20\x6d\x69\x2e\x20\x4d\x6f\x72\x62\x69\x20\x61\x20\x74\x75\x72\x70\x69\x73\x20\x65\x74\x20\x74\x65\x6c\x6c\x75\x73\x20\x64\x61\x70\x69\x62\x75\x73\x20\x69\x61\x63\x75\x6c\x69\x73\x2e\x20\x45\x74\x69\x61\x6d\x20\x66\x61\x75\x63\x69\x62\x75\x73\x20\x74\x65\x6c\x6c\x75\x73\x20\x73\x65\x64\x20\x6d\x65\x74\x75\x73\x20\x63\x6f\x6e\x73\x65\x71\x75\x61\x74\x20\x72\x75\x74\x72\x75\x6d\x2e\x20\x46\x75\x73\x63\x65\x20\x73\x69\x74\x20\x61\x6d\x65\x74\x20\x6e\x75\x6c\x6c\x61\x20\x6d\x61\x73\x73\x61\x2c\x20\x74\x65\x6d\x70\x75\x73\x20\x76\x75\x6c\x70\x75\x74\x61\x74\x65\x20\x73\x65\x6d\x2e\x20\x43\x72\x61\x73\x20\x74\x69\x6e\x63\x69\x64\x75\x6e\x74\x20\x71\x75\x61\x6d\x20\x69\x6e\x20\x6c\x69\x62\x65\x72\x6f\x20\x72\x75\x74\x72\x75\x6d\x20\x69\x6e\x74\x65\x72\x64\x75\x6d\x2e\x20\x41\x6c\x69\x71\x75\x61\x6d\x20\x71\x75\x61\x6d\x20\x73\x61\x70\x69\x65\x6e\x2c\x20\x66\x61\x63\x69\x6c\x69\x73\x69\x73\x20\x61\x74\x20\x76\x65\x73\x74\x69\x62\x75\x6c\x75\x6d\x20\x65\x74\x2c\x20\x76\x65\x6e\x65\x6e\x61\x74\x69\x73\x20\x69\x64\x20\x6d\x61\x75\x72\x69\x73\x2e\x20\x4d\x6f\x72\x62\x69\x20\x72\x75\x74\x72\x75\x6d\x20\x67\x72\x61\x76\x69\x64\x61\x20\x75\x6c\x74\x72\x69\x63\x69\x65\x73\x2e\x20\x0a", 579), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xa4\xa6\x40\x00\x40\x06\x98\x1b\x7f\x00\x00\x01\x7f\x00\x00\x01\x0b\xb8\xa3\x78\x37\x67\x56\xd4\xb1\xe6\x16\x3a\x80\x10\x0c\x00\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1b\x04\xba\x2d\x1b\x04\xba", 66), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x02\x6a\xfd\x0b\x40\x00\x40\x06\x3d\x80\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x16\x3a\x37\x67\x56\xd4\x80\x18\x08\x02\x00\x5f\x00\x00\x01\x01\x08\x0a\x2d\x1b\x09\xa2\x2d\x1b\x04\xba\x41\x65\x6e\x65\x61\x6e\x20\x65\x74\x20\x6a\x75\x73\x74\x6f\x20\x75\x74\x20\x6c\x69\x62\x65\x72\x6f\x20\x65\x75\x69\x73\x6d\x6f\x64\x20\x73\x6f\x6c\x6c\x69\x63\x69\x74\x75\x64\x69\x6e\x2e\x20\x4e\x75\x6c\x6c\x61\x6d\x20\x65\x6e\x69\x6d\x20\x64\x75\x69\x2c\x20\x69\x61\x63\x75\x6c\x69\x73\x20\x76\x69\x74\x61\x65\x20\x62\x69\x62\x65\x6e\x64\x75\x6d\x20\x65\x74\x2c\x20\x63\x6f\x6d\x6d\x6f\x64\x6f\x20\x69\x6e\x20\x74\x65\x6c\x6c\x75\x73\x2e\x20\x4e\x75\x6c\x6c\x61\x6d\x20\x65\x67\x65\x74\x20\x70\x75\x72\x75\x73\x20\x6d\x69\x2c\x20\x61\x20\x75\x6c\x6c\x61\x6d\x63\x6f\x72\x70\x65\x72\x20\x6c\x6f\x72\x65\x6d\x2e\x20\x53\x75\x73\x70\x65\x6e\x64\x69\x73\x73\x65\x20\x70\x6f\x74\x65\x6e\x74\x69\x2e\x20\x44\x75\x69\x73\x20\x61\x63\x20\x6a\x75\x73\x74\x6f\x20\x75\x74\x20\x6c\x65\x6f\x20\x65\x75\x69\x73\x6d\x6f\x64\x20\x67\x72\x61\x76\x69\x64\x61\x20\x73\x69\x74\x20\x61\x6d\x65\x74\x20\x61\x74\x20\x6c\x65\x63\x74\x75\x73\x2e\x20\x4c\x6f\x72\x65\x6d\x20\x69\x70\x73\x75\x6d\x20\x64\x6f\x6c\x6f\x72\x20\x73\x69\x74\x20\x61\x6d\x65\x74\x2c\x20\x63\x6f\x6e\x73\x65\x63\x74\x65\x74\x75\x72\x20\x61\x64\x69\x70\x69\x73\x63\x69\x6e\x67\x20\x65\x6c\x69\x74\x2e\x20\x4d\x61\x65\x63\x65\x6e\x61\x73\x20\x73\x65\x64\x20\x61\x72\x63\x75\x20\x76\x69\x74\x61\x65\x20\x6e\x69\x73\x69\x20\x73\x6f\x6c\x6c\x69\x63\x69\x74\x75\x64\x69\x6e\x20\x67\x72\x61\x76\x69\x64\x61\x2e\x20\x4e\x75\x6c\x6c\x61\x20\x66\x61\x63\x69\x6c\x69\x73\x69\x73\x20\x6e\x69\x62\x68\x20\x74\x75\x72\x70\x69\x73\x2e\x20\x4d\x61\x65\x63\x65\x6e\x61\x73\x20\x71\x75\x69\x73\x20\x69\x6d\x70\x65\x72\x64\x69\x65\x74\x20\x61\x72\x63\x75\x2e\x20\x53\x65\x64\x20\x73\x69\x74\x20\x61\x6d\x65\x74\x20\x6e\x75\x6c\x6c\x61\x20\x75\x72\x6e\x61\x2c\x20\x61\x74\x20\x76\x65\x73\x74\x69\x62\x75\x6c\x75\x6d\x20\x6d\x61\x75\x72\x69\x73\x2e\x20\x53\x75\x73\x70\x65\x6e\x64\x69\x73\x73\x65\x20\x71\x75\x69\x73\x20\x65\x6c\x69\x74\x20\x64\x75\x69\x2e\x20\x43\x6c\x61\x73\x73\x20\x61\x70\x74\x65\x6e\x74\x20\x74\x61\x63\x69\x74\x69\x20\x73\x6f\x63\x69\x6f\x73\x71\x75\x20\x61\x64\x20\x6c\x69\x74\x6f\x72\x61\x20\x74\x6f\x72\x71\x75\x65\x6e\x74\x20\x70\x65\x72\x20\x63\x6f\x6e\x75\x62\x69\x61\x20\x6e\x6f\x73\x74\x72\x61\x2c\x20\x70\x65\x72\x20\x69\x6e\x63\x65\x70\x74\x6f\x73\x20\x68\x69\x6d\x65\x6e\x61\x65\x6f\x73\x2e\x20\x0a", 632), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xa4\xa7\x40\x00\x40\x06\x98\x1a\x7f\x00\x00\x01\x7f\x00\x00\x01\x0b\xb8\xa3\x78\x37\x67\x56\xd4\xb1\xe6\x18\x70\x80\x10\x0c\x00\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1b\x09\xa2\x2d\x1b\x09\xa2", 66), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xfd\x0c\x40\x00\x40\x06\x3f\xb5\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x18\x70\x37\x67\x56\xd4\x80\x11\x08\x02\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1b\x0d\xd2\x2d\x1b\x09\xa2", 66), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xa4\xa8\x40\x00\x40\x06\x98\x19\x7f\x00\x00\x01\x7f\x00\x00\x01\x0b\xb8\xa3\x78\x37\x67\x56\xd4\xb1\xe6\x18\x71\x80\x11\x0c\x00\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1b\x0d\xd2\x2d\x1b\x0d\xd2", 66), EthernetII((const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x45\x00\x00\x34\xfd\x0d\x40\x00\x40\x06\x3f\xb4\x7f\x00\x00\x01\x7f\x00\x00\x01\xa3\x78\x0b\xb8\xb1\xe6\x18\x71\x37\x67\x56\xd5\x80\x10\x08\x02\xfe\x28\x00\x00\x01\x01\x08\x0a\x2d\x1b\x0d\xd2\x2d\x1b\x0d\xd2", 66) }; const size_t TCPStreamTest::indexes[][num_packets] = { {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}, {0,1,2,3,5,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19}, {0,1,2,5,3,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19}, {0,1,2,5,3,4,6,7,8,9,10,11,13,15,14,12,16,17,18,19}, {0,1,2,5,3,4,6,7,8,9,10,15,13,11,14,12,16,17,18,19} }; const std::string TCPStreamTest::payload = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at aliquam arcu. Sed at iaculis magna. Nam ut dolor eget velit mattis posuere ut non dui. Aliquam faucibus erat pretium ligula tincidunt eget tristique justo placerat. Phasellus turpis tellus, ornare ultricies egestas vitae, mollis sed neque. Sed et libero in nunc pharetra auctor ut a eros. Mauris quis faucibus nibh. \nLorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at aliquam arcu. Sed at iaculis magna. Nam ut dolor eget velit mattis posuere ut non dui. Aliquam faucibus erat pretium ligula tincidunt eget tristique justo placerat. Phasellus turpis tellus, ornare ultricies egestas vitae, mollis sed neque. Sed et libero in nunc pharetra auctor ut a eros. Mauris quis faucibus nibh. \n\n\nCurabitur sem erat, bibendum quis condimentum ut, imperdiet at est. Duis sagittis rhoncus felis at ultricies. In libero urna, dignissim eu elementum quis, consectetur a neque. Praesent leo sem, cursus sed lobortis sit amet, ornare ac augue. Mauris tristique semper ipsum at consequat. Sed fringilla dolor ut lacus sagittis quis ultricies leo vulputate. Maecenas dignissim imperdiet justo. Cras libero odio, vehicula et adipiscing quis, luctus vel ante. \nAliquam imperdiet est quis nunc malesuada eget convallis tellus ullamcorper. Vivamus ullamcorper eros sit amet odio sollicitudin rutrum. Donec pellentesque faucibus nulla, ut fringilla risus aliquam eget. Sed et ante mi. Morbi a turpis et tellus dapibus iaculis. Etiam faucibus tellus sed metus consequat rutrum. Fusce sit amet nulla massa, tempus vulputate sem. Cras tincidunt quam in libero rutrum interdum. Aliquam quam sapien, facilisis at vestibulum et, venenatis id mauris. Morbi rutrum gravida ultricies. \nAenean et justo ut libero euismod sollicitudin. Nullam enim dui, iaculis vitae bibendum et, commodo in tellus. Nullam eget purus mi, a ullamcorper lorem. Suspendisse potenti. Duis ac justo ut leo euismod gravida sit amet at lectus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed arcu vitae nisi sollicitudin gravida. Nulla facilisis nibh turpis. Maecenas quis imperdiet arcu. Sed sit amet nulla urna, at vestibulum mauris. Suspendisse quis elit dui. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. \n"; void data_handle(TCPStream&) { } void TCPStreamTest::end_handle(TCPStream& session) { processed_stream = true; ASSERT_EQ(session.client_payload().size(), payload.size()) << "Sizes differ for index " << index; EXPECT_TRUE(std::equal(payload.begin(), payload.end(), session.client_payload().begin())) << "Payload differs for index " << index; } TEST_F(TCPStreamTest, FollowStreams) { TCPStreamFollower follower; for(index = 0; index < (sizeof(indexes) / sizeof(indexes[0])); index++) { std::vector pdus; for(size_t i = 0; i < num_packets; ++i) pdus.push_back(packets[indexes[index][i]]); processed_stream = false; follower.follow_streams(pdus.begin(), pdus.end(), data_handle, &TCPStreamTest::end_handle); EXPECT_TRUE(processed_stream); } } libtins-1.1/tests/src/tcp.cpp0000664000175000017500000001427612154360113015570 0ustar matiasmatias#include #include #include #include #include #include "tcp.h" #include "ip.h" #include "utils.h" using namespace std; using namespace Tins; class TCPTest : public testing::Test { public: static const uint8_t expected_packet[], checksum_packet[]; void test_equals(const TCP &tcp1, const TCP &tcp2); }; const uint8_t TCPTest::expected_packet[] = { 127, 77, 79, 29, 241, 218, 229, 70, 95, 174, 209, 35, 208, 2, 113, 218, 0, 0, 31, 174, 2, 4, 152, 250, 8, 10, 79, 210, 58, 203, 137, 254, 18, 52, 3, 3, 122, 4, 2, 5, 10, 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0 }; // IP + TCP const uint8_t TCPTest::checksum_packet[] = { 69, 0, 0, 40, 0, 0, 64, 0, 64, 6, 60, 206, 0, 0, 0, 0, 127, 0, 0, 1, 5, 57, 199, 49, 0, 0, 0, 0, 255, 216, 70, 222, 80, 20, 0, 0, 158, 172, 0, 0 }; TEST_F(TCPTest, DefaultConstructor) { TCP tcp; EXPECT_EQ(tcp.dport(), 0); EXPECT_EQ(tcp.sport(), 0); EXPECT_EQ(tcp.pdu_type(), PDU::TCP); } TEST_F(TCPTest, ChecksumCheck) { IP pkt1(checksum_packet, sizeof(checksum_packet)); const TCP &tcp1 = pkt1.rfind_pdu(); uint16_t checksum = tcp1.checksum(); IP::serialization_type buffer = pkt1.serialize(); IP pkt2(&buffer[0], buffer.size()); const TCP &tcp2 = pkt2.rfind_pdu(); EXPECT_EQ(checksum, tcp2.checksum()); EXPECT_EQ(tcp1.checksum(), tcp2.checksum()); } TEST_F(TCPTest, CopyConstructor) { TCP tcp1(0x6d1f, 0x78f2); TCP tcp2(tcp1); test_equals(tcp1, tcp2); } TEST_F(TCPTest, CopyAssignmentOperator) { TCP tcp1(0x6d1f, 0x78f2); TCP tcp2 = tcp1; test_equals(tcp1, tcp2); } TEST_F(TCPTest, NestedCopy) { TCP *nested_tcp = new TCP(0x6d1f, 0x78f2); TCP tcp1(0x6d1f, 0x78f2); tcp1.inner_pdu(nested_tcp); TCP tcp2(tcp1); test_equals(tcp1, tcp2); } TEST_F(TCPTest, CompleteConstructor) { TCP tcp(0x6d1f, 0x78f2); EXPECT_EQ(tcp.dport(), 0x6d1f); EXPECT_EQ(tcp.sport(), 0x78f2); } TEST_F(TCPTest, DPort) { TCP tcp; tcp.dport(0x5fad); EXPECT_EQ(tcp.dport(), 0x5fad); } TEST_F(TCPTest, SPort) { TCP tcp; tcp.sport(0x5fad); EXPECT_EQ(tcp.sport(), 0x5fad); } TEST_F(TCPTest, Seq) { TCP tcp; tcp.seq(0x5fad65fb); EXPECT_EQ(tcp.seq(), 0x5fad65fb); } TEST_F(TCPTest, AckSeq) { TCP tcp; tcp.ack_seq(0x5fad65fb); EXPECT_EQ(tcp.ack_seq(), 0x5fad65fb); } TEST_F(TCPTest, Window) { TCP tcp; tcp.window(0x5fad); EXPECT_EQ(tcp.window(), 0x5fad); } TEST_F(TCPTest, UrgPtr) { TCP tcp; tcp.urg_ptr(0x5fad); EXPECT_EQ(tcp.urg_ptr(), 0x5fad); } TEST_F(TCPTest, DataOffset) { TCP tcp; tcp.data_offset(0xe); EXPECT_EQ(tcp.data_offset(), 0xe); } TEST_F(TCPTest, SetFlag) { TCP tcp; tcp.set_flag(TCP::SYN, 1); tcp.set_flag(TCP::FIN, 1); EXPECT_EQ(tcp.get_flag(TCP::SYN), 1); EXPECT_EQ(tcp.get_flag(TCP::FIN), 1); EXPECT_EQ(tcp.get_flag(TCP::RST), 0); EXPECT_EQ(tcp.get_flag(TCP::PSH), 0); EXPECT_EQ(tcp.get_flag(TCP::ACK), 0); EXPECT_EQ(tcp.get_flag(TCP::URG), 0); EXPECT_EQ(tcp.get_flag(TCP::ECE), 0); EXPECT_EQ(tcp.get_flag(TCP::CWR), 0); } TEST_F(TCPTest, MSS) { TCP tcp; tcp.mss(0x456f); EXPECT_EQ(0x456f, tcp.mss()); } TEST_F(TCPTest, WindowScale) { TCP tcp; tcp.winscale(0x4f); EXPECT_EQ(0x4f, tcp.winscale()); } TEST_F(TCPTest, SackPermitted) { TCP tcp; tcp.sack_permitted(); ASSERT_TRUE(tcp.has_sack_permitted()); } TEST_F(TCPTest, Sack) { TCP tcp; TCP::sack_type edges; edges.push_back(0x13); edges.push_back(0x63fa1d7a); edges.push_back(0xff1c); tcp.sack(edges); ASSERT_EQ(edges, tcp.sack()); } TEST_F(TCPTest, AlternateChecksum) { TCP tcp; tcp.altchecksum(TCP::CHK_16FLETCHER); EXPECT_EQ(TCP::CHK_16FLETCHER, tcp.altchecksum()); } TEST_F(TCPTest, Timestamp) { TCP tcp; std::pair data(0x456fa23d, 0xfa12d345); tcp.timestamp(data.first, data.second); EXPECT_EQ(tcp.timestamp(), data); } void TCPTest::test_equals(const TCP &tcp1, const TCP &tcp2) { EXPECT_EQ(tcp1.dport(), tcp2.dport()); EXPECT_EQ(tcp2.sport(), tcp2.sport()); EXPECT_EQ(tcp1.seq(), tcp2.seq()); EXPECT_EQ(tcp1.ack_seq(), tcp2.ack_seq()); EXPECT_EQ(tcp1.window(), tcp2.window()); EXPECT_EQ(tcp1.checksum(), tcp2.checksum()); EXPECT_EQ(tcp1.urg_ptr(), tcp2.urg_ptr()); EXPECT_EQ(tcp1.data_offset(), tcp2.data_offset()); EXPECT_EQ((bool)tcp1.inner_pdu(), (bool)tcp2.inner_pdu()); } // This is not working, but i don't want to fix it right now. TEST_F(TCPTest, ConstructorFromBuffer) { TCP tcp1(expected_packet, sizeof(expected_packet)); EXPECT_EQ(tcp1.dport(), 0x4f1d); EXPECT_EQ(tcp1.sport(), 0x7f4d); EXPECT_EQ(tcp1.seq(), 0xf1dae546); EXPECT_EQ(tcp1.ack_seq(), 0x5faed123); EXPECT_EQ(tcp1.window(), 0x71da); EXPECT_EQ(tcp1.urg_ptr(), 0x1fae); EXPECT_EQ(tcp1.data_offset(), 0xd); EXPECT_EQ(tcp1.timestamp(), (std::pair(0x4fd23acb, 0x89fe1234))); EXPECT_TRUE(tcp1.has_sack_permitted()); EXPECT_EQ(tcp1.winscale(), 0x7a); EXPECT_EQ(tcp1.mss(), 0x98fa); TCP::sack_type edges = tcp1.sack(); TCP::sack_type::const_iterator iter = edges.begin(); ASSERT_EQ(edges.size(), 2); EXPECT_EQ(*iter++, 0x00010203); EXPECT_EQ(*iter++, 0x04050607); PDU::serialization_type buffer = tcp1.serialize(); TCP tcp2(&buffer[0], buffer.size()); test_equals(tcp1, tcp2); } TEST_F(TCPTest, Serialize) { TCP tcp1(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = tcp1.serialize(); ASSERT_EQ(buffer.size(), sizeof(expected_packet)); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } TEST_F(TCPTest, SpoofedOptions) { TCP pdu; uint8_t a[] = { 1,2,3,4,5,6 }; pdu.add_option( TCP::option(TCP::SACK, 250, a, a + sizeof(a)) ); pdu.add_option( TCP::option(TCP::SACK, 250, a, a + sizeof(a)) ); pdu.add_option( TCP::option(TCP::SACK, 250, a, a + sizeof(a)) ); // probably we'd expect it to crash if it's not working, valgrind plx EXPECT_EQ(3, pdu.options().size()); EXPECT_EQ(pdu.serialize().size(), pdu.size()); } libtins-1.1/tests/src/stp.cpp0000664000175000017500000001107712154360113015604 0ustar matiasmatias#include #include #include #include #include "stp.h" #include "dot3.h" #include "llc.h" using namespace std; using namespace Tins; class STPTest : public testing::Test { public: static const uint8_t expected_packet[]; static void test_equals(const STP::bpdu_id_type &lhs, const STP::bpdu_id_type &rhs); }; const uint8_t STPTest::expected_packet[] = { 146, 131, 138, 146, 146, 128, 0, 0, 144, 76, 8, 23, 181, 0, 146, 131, 120, 128, 0, 0, 144, 76, 8, 23, 181, 128, 1, 15, 0, 20, 0, 2, 0, 0, 0 }; void STPTest::test_equals(const STP::bpdu_id_type &lhs, const STP::bpdu_id_type &rhs) { EXPECT_EQ(lhs.priority, rhs.priority); EXPECT_EQ(lhs.ext_id, rhs.ext_id); EXPECT_EQ(lhs.id, rhs.id); } TEST_F(STPTest, DefaultConstructor) { STP pdu; EXPECT_EQ(0, pdu.proto_id()); EXPECT_EQ(0, pdu.proto_version()); EXPECT_EQ(0, pdu.bpdu_type()); EXPECT_EQ(0, pdu.bpdu_flags()); EXPECT_EQ(0, pdu.root_path_cost()); EXPECT_EQ(0, pdu.port_id()); EXPECT_EQ(0, pdu.msg_age()); EXPECT_EQ(0, pdu.max_age()); EXPECT_EQ(0, pdu.hello_time()); EXPECT_EQ(0, pdu.fwd_delay()); } TEST_F(STPTest, ConstructorFromBuffer) { STP pdu(expected_packet, sizeof(expected_packet)); STP::bpdu_id_type bpdu(0x8, 0, "00:90:4c:08:17:b5"); EXPECT_EQ(0x9283, pdu.proto_id()); EXPECT_EQ(0x8a, pdu.proto_version()); EXPECT_EQ(0x92, pdu.bpdu_type()); EXPECT_EQ(0x92, pdu.bpdu_flags()); test_equals(bpdu, pdu.root_id()); // root identifier(32768. 0, 00:90:4c:08:17:b5 EXPECT_EQ(0x928378, pdu.root_path_cost()); test_equals(bpdu, pdu.bridge_id()); // bridge identifier(32768. 0, 00:90:4c:08:17:b5 EXPECT_EQ(0x8001, pdu.port_id()); EXPECT_EQ(15, pdu.msg_age()); EXPECT_EQ(20, pdu.max_age()); EXPECT_EQ(2, pdu.hello_time()); EXPECT_EQ(0, pdu.fwd_delay()); } TEST_F(STPTest, BPDUId) { const uint8_t expected_packet[] = { 0, 0, 0, 0, 0, 128, 100, 0, 28, 14, 135, 120, 0, 0, 0, 0, 4, 128, 100, 0, 28, 14, 135, 133, 0, 128, 4, 1, 0, 20, 0, 2, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; STP pdu(expected_packet, sizeof(expected_packet)); STP::bpdu_id_type bpdu(0x8, 100, "00:1c:0e:87:78:00"); test_equals(bpdu, pdu.root_id()); } TEST_F(STPTest, ChainedPDUs) { const uint8_t input[] = { 1, 128, 194, 0, 0, 0, 0, 144, 76, 8, 23, 181, 0, 38, 66, 66, 3, 0, 0, 0, 0, 0, 128, 0, 0, 144, 76, 8, 23, 181, 0, 0, 0, 0, 128, 0, 0, 144, 76, 8, 23, 181, 128, 1, 0, 0, 20, 0, 2, 0, 0, 0 }; Dot3 pkt(input, sizeof(input)); STP *stp = pkt.find_pdu(); LLC *llc = pkt.find_pdu(); ASSERT_TRUE(stp); ASSERT_TRUE(llc); EXPECT_EQ(0x8001, stp->port_id()); EXPECT_EQ(0, stp->msg_age()); EXPECT_EQ(20, stp->max_age()); EXPECT_EQ(2, stp->hello_time()); llc->dsap(0); llc->ssap(0); EXPECT_EQ( PDU::serialization_type(input, input + sizeof(input)), pkt.serialize() ); } TEST_F(STPTest, Serialize) { STP pdu(expected_packet, sizeof(expected_packet)); EXPECT_EQ( PDU::serialization_type(expected_packet, expected_packet + sizeof(expected_packet)), pdu.serialize() ); } TEST_F(STPTest, ProtoID) { STP pdu; pdu.proto_id(0x9283); EXPECT_EQ(0x9283, pdu.proto_id()); } TEST_F(STPTest, ProtoVersion) { STP pdu; pdu.proto_version(0x15); EXPECT_EQ(0x15, pdu.proto_version()); } TEST_F(STPTest, BPDUType) { STP pdu; pdu.bpdu_type(0x15); EXPECT_EQ(0x15, pdu.bpdu_type()); } TEST_F(STPTest, BPDUFlags) { STP pdu; pdu.bpdu_flags(0x15); EXPECT_EQ(0x15, pdu.bpdu_flags()); } TEST_F(STPTest, RootPathCost) { STP pdu; pdu.root_path_cost(0x28378462); EXPECT_EQ(0x28378462, pdu.root_path_cost()); } TEST_F(STPTest, PortID) { STP pdu; pdu.port_id(0x9283); EXPECT_EQ(0x9283, pdu.port_id()); } TEST_F(STPTest, MsgAge) { STP pdu; pdu.msg_age(15); EXPECT_EQ(15, pdu.msg_age()); } TEST_F(STPTest, MaxAge) { STP pdu; pdu.max_age(15); EXPECT_EQ(15, pdu.max_age()); } TEST_F(STPTest, FwdDelay) { STP pdu; pdu.fwd_delay(15); EXPECT_EQ(15, pdu.fwd_delay()); } TEST_F(STPTest, HelloTime) { STP pdu; pdu.hello_time(15); EXPECT_EQ(15, pdu.hello_time()); } TEST_F(STPTest, RootID) { STP pdu; STP::bpdu_id_type bpdu(0x8, 100, "00:1c:0e:87:78:00"); pdu.root_id(bpdu); test_equals(bpdu, pdu.root_id()); } TEST_F(STPTest, BridgeID) { STP pdu; STP::bpdu_id_type bpdu(0x8, 100, "00:1c:0e:87:78:00"); pdu.bridge_id(bpdu); test_equals(bpdu, pdu.bridge_id()); } libtins-1.1/tests/src/snap.cpp0000664000175000017500000000526512154360113015741 0ustar matiasmatias#include #include #include #include #include "snap.h" #include "utils.h" using namespace std; using namespace Tins; class SNAPTest : public testing::Test { public: static const uint8_t expected_packet[]; void test_equals(const SNAP &snap1, const SNAP &snap2); }; const uint8_t SNAPTest::expected_packet[] = { 170, 170, 3, 0, 0, 1, 8, 0 }; TEST_F(SNAPTest, DefaultConstructor) { SNAP snap; EXPECT_EQ(snap.pdu_type(), PDU::SNAP); EXPECT_EQ(snap.dsap(), 0xaa); EXPECT_EQ(snap.ssap(), 0xaa); EXPECT_EQ(snap.eth_type(), 0); EXPECT_EQ(snap.org_code(), 0); EXPECT_EQ(snap.control(), 3); } TEST_F(SNAPTest, CopyConstructor) { SNAP snap1; snap1.eth_type(0xfab1); snap1.org_code(0xfab1c3); snap1.control(0x1); SNAP snap2(snap1); test_equals(snap1, snap2); } TEST_F(SNAPTest, CopyAssignmentOperator) { SNAP snap1; snap1.eth_type(0xfab1); snap1.org_code(0xfab1c3); snap1.control(0x1); SNAP snap2 = snap1; test_equals(snap1, snap2); } TEST_F(SNAPTest, OrgCode) { SNAP snap; snap.org_code(0xfab1c3); EXPECT_EQ(snap.org_code(), 0xfab1c3); EXPECT_EQ(snap.control(), 3); } TEST_F(SNAPTest, Control) { SNAP snap; snap.control(0xfa); EXPECT_EQ(snap.control(), 0xfa); EXPECT_EQ(snap.org_code(), 0); } TEST_F(SNAPTest, EthType) { SNAP snap; snap.eth_type(0xfab1); EXPECT_EQ(snap.eth_type(), 0xfab1); } TEST_F(SNAPTest, Serialize) { SNAP snap1; snap1.eth_type(0xfab1); snap1.org_code(0xfab1c3); snap1.control(0x1); PDU::serialization_type buffer = snap1.serialize(); SNAP snap2(snap1); PDU::serialization_type buffer2 = snap2.serialize(); EXPECT_EQ(buffer, buffer2); } TEST_F(SNAPTest, ClonePDU) { SNAP snap1; snap1.eth_type(0xfab1); snap1.org_code(0xfab1c3); snap1.control(0x1); SNAP *snap2 = static_cast(snap1.clone()); ASSERT_TRUE(snap2); test_equals(snap1, *snap2); delete snap2; } TEST_F(SNAPTest, ConstructorFromBuffer) { SNAP snap1(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = snap1.serialize(); EXPECT_EQ(3, snap1.control()); EXPECT_EQ(0xaa, snap1.dsap()); EXPECT_EQ(0xaa, snap1.ssap()); EXPECT_EQ(0x0800, snap1.eth_type()); EXPECT_EQ(1, snap1.org_code()); SNAP snap2(&buffer[0], buffer.size()); test_equals(snap1, snap2); } void SNAPTest::test_equals(const SNAP &snap1, const SNAP &snap2) { EXPECT_EQ(snap1.dsap(), snap2.dsap()); EXPECT_EQ(snap1.ssap(), snap2.ssap()); EXPECT_EQ(snap1.control(), snap2.control()); EXPECT_EQ(snap1.eth_type(), snap2.eth_type()); } libtins-1.1/tests/src/sll.cpp0000664000175000017500000000511512154360113015564 0ustar matiasmatias#include #include #include #include #include "sll.h" #include "hw_address.h" #include "constants.h" #include "ip.h" using namespace std; using namespace Tins; class SLLTest : public testing::Test { public: static const uint8_t expected_packet[]; void test_equals(const SLL &sll1, const SLL &sll2); }; const uint8_t SLLTest::expected_packet[] = { 0, 0, 0, 1, 0, 6, 0, 27, 17, 210, 27, 235, 0, 0, 8, 0, 69, 0, 0, 116, 65, 18, 0, 0, 44, 6, 156, 54, 173, 194, 66, 109, 192, 168, 0, 100, 3, 225, 141, 4, 55, 61, 150, 161, 85, 106, 73, 189, 128, 24, 1, 0, 202, 119, 0, 0, 1, 1, 8, 10, 71, 45, 40, 171, 0, 19, 78, 86, 23, 3, 1, 0, 59, 168, 147, 182, 150, 159, 178, 204, 116, 62, 85, 80, 167, 23, 24, 173, 236, 55, 46, 190, 205, 255, 19, 248, 129, 198, 140, 208, 60, 79, 59, 38, 165, 131, 33, 105, 212, 112, 174, 80, 211, 48, 37, 116, 108, 109, 33, 36, 231, 154, 131, 112, 246, 3, 180, 199, 158, 205, 123, 238 }; TEST_F(SLLTest, DefaultConstructor) { SLL sll; EXPECT_EQ(0, sll.packet_type()); EXPECT_EQ(0, sll.lladdr_type()); EXPECT_EQ(0, sll.lladdr_len()); EXPECT_EQ(0, sll.protocol()); EXPECT_EQ(SLL::address_type("00:00:00:00:00:00:00:00"), sll.address()); } TEST_F(SLLTest, ConstructorFromBuffer) { typedef HWAddress<6> address_type; address_type addr("00:1b:11:d2:1b:eb"); SLL sll(expected_packet, sizeof(expected_packet)); EXPECT_EQ(0, sll.packet_type()); EXPECT_EQ(1, sll.lladdr_type()); EXPECT_EQ(6, sll.lladdr_len()); EXPECT_EQ(Constants::Ethernet::IP, sll.protocol()); EXPECT_EQ(addr, sll.address()); ASSERT_TRUE(sll.inner_pdu()); EXPECT_EQ(sll.find_pdu(), sll.inner_pdu()); } TEST_F(SLLTest, Serialize) { SLL sll(expected_packet, sizeof(expected_packet)); SLL::serialization_type buffer = sll.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } TEST_F(SLLTest, PacketType) { SLL sll; sll.packet_type(0x923f); EXPECT_EQ(0x923f, sll.packet_type()); } TEST_F(SLLTest, LLADDRType) { SLL sll; sll.lladdr_type(0x923f); EXPECT_EQ(0x923f, sll.lladdr_type()); } TEST_F(SLLTest, LLADDRLen) { SLL sll; sll.lladdr_len(0x923f); EXPECT_EQ(0x923f, sll.lladdr_len()); } TEST_F(SLLTest, Protocol) { SLL sll; sll.protocol(0x923f); EXPECT_EQ(0x923f, sll.protocol()); } TEST_F(SLLTest, Address) { HWAddress<6> addr = "00:01:02:03:04:05"; SLL sll; sll.address(addr); EXPECT_EQ(addr, sll.address()); } libtins-1.1/tests/src/rsn_eapol.cpp0000664000175000017500000001543612154360113016763 0ustar matiasmatias#include #include #include #include #include "eapol.h" #include "utils.h" #include "rsn_information.h" using namespace std; using namespace Tins; class RSNEAPOLTest : public testing::Test { public: static const uint8_t expected_packet[]; void test_equals(const RSNEAPOL &eapol1, const RSNEAPOL &eapol2); }; uint8_t empty_iv[RSNEAPOL::key_iv_size] = { 0 }; const uint8_t nonce[RSNEAPOL::nonce_size] = { 185, 111, 231, 250, 202, 91, 39, 226, 77, 4, 241, 230, 108, 6, 225, 155, 179, 58, 107, 36, 180, 57, 187, 228, 222, 217, 10, 204, 209, 51, 30, 158 }; const uint8_t mic[RSNEAPOL::mic_size] = { 177, 186, 172, 85, 150, 74, 189, 48, 86, 133, 101, 42, 178, 38, 117, 130 }; const uint8_t key[56] = { 226, 197, 79, 71, 243, 14, 201, 47, 66, 216, 213, 30, 49, 157, 245, 72, 96, 109, 78, 227, 217, 132, 211, 67, 90, 21, 252, 88, 15, 62, 116, 96, 64, 145, 16, 96, 239, 177, 67, 248, 253, 182, 10, 54, 203, 164, 68, 152, 38, 7, 26, 255, 139, 147, 211, 46 }; const uint8_t rsc[RSNEAPOL::rsc_size] = { 177, 6 }; const uint8_t id[RSNEAPOL::id_size] = { 0 }; const uint8_t RSNEAPOLTest::expected_packet[] = { 1, 3, 0, 151, 2, 19, 202, 0, 16, 0, 0, 0, 0, 0, 0, 0, 2, 185, 111, 231, 250, 202, 91, 39, 226, 77, 4, 241, 230, 108, 6, 225, 155, 179, 58, 107, 36, 180, 57, 187, 228, 222, 217, 10, 204, 209, 51, 30, 158, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 177, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 177, 186, 172, 85, 150, 74, 189, 48, 86, 133, 101, 42, 178, 38, 117, 130, 0, 56, 226, 197, 79, 71, 243, 14, 201, 47, 66, 216, 213, 30, 49, 157, 245, 72, 96, 109, 78, 227, 217, 132, 211, 67, 90, 21, 252, 88, 15, 62, 116, 96, 64, 145, 16, 96, 239, 177, 67, 248, 253, 182, 10, 54, 203, 164, 68, 152, 38, 7, 26, 255, 139, 147, 211, 46 }; void RSNEAPOLTest::test_equals(const RSNEAPOL &eapol1, const RSNEAPOL &eapol2) { EXPECT_EQ(eapol1.version(), eapol2.version()); EXPECT_EQ(eapol1.packet_type(), eapol2.packet_type()); EXPECT_EQ(eapol1.type(), eapol2.type()); EXPECT_EQ(eapol1.length(), eapol2.length()); EXPECT_EQ(eapol1.key_length(), eapol2.key_length()); EXPECT_EQ(eapol1.replay_counter(), eapol2.replay_counter()); EXPECT_TRUE(std::equal(eapol1.key_iv(), eapol1.key_iv() + RSNEAPOL::key_iv_size, eapol2.key_iv())); EXPECT_TRUE(std::equal(eapol1.id(), eapol1.id() + RSNEAPOL::id_size, eapol2.id())); EXPECT_TRUE(std::equal(eapol1.rsc(), eapol1.rsc() + RSNEAPOL::rsc_size, eapol2.rsc())); EXPECT_EQ(eapol1.wpa_length(), eapol2.wpa_length()); EXPECT_TRUE(std::equal(eapol1.nonce(), eapol1.nonce() + RSNEAPOL::nonce_size, eapol2.nonce())); EXPECT_TRUE(std::equal(eapol1.mic(), eapol1.mic() + RSNEAPOL::mic_size, eapol2.mic())); EXPECT_EQ(eapol1.key(), eapol2.key()); } TEST_F(RSNEAPOLTest, DefaultConstructor) { uint8_t empty_nonce[RSNEAPOL::nonce_size] = { 0 }; uint8_t empty_rsc[RSNEAPOL::rsc_size] = { 0 }; RSNEAPOL eapol; EXPECT_EQ(1, eapol.version()); EXPECT_EQ(0x3, eapol.packet_type()); EXPECT_EQ(EAPOL::RSN, eapol.type()); EXPECT_EQ(0, eapol.length()); EXPECT_EQ(0, eapol.key_length()); EXPECT_EQ(0, eapol.replay_counter()); EXPECT_TRUE(std::equal(empty_iv, empty_iv + sizeof(empty_iv), eapol.key_iv())); EXPECT_TRUE(std::equal(empty_rsc, empty_rsc + sizeof(empty_rsc), eapol.id())); EXPECT_TRUE(std::equal(empty_rsc, empty_rsc + sizeof(empty_rsc), eapol.rsc())); EXPECT_EQ(0, eapol.wpa_length()); EXPECT_TRUE(std::equal(empty_nonce, empty_nonce + sizeof(empty_nonce), eapol.nonce())); EXPECT_TRUE(std::equal(empty_iv, empty_iv + sizeof(empty_iv), eapol.mic())); EXPECT_EQ(RSNEAPOL::key_type(), eapol.key()); } TEST_F(RSNEAPOLTest, ConstructorFromBuffer) { RSNEAPOL eapol(expected_packet, sizeof(expected_packet)); EXPECT_EQ(1, eapol.version()); EXPECT_EQ(3, eapol.packet_type()); EXPECT_EQ(151, eapol.length()); EXPECT_EQ(EAPOL::RSN, eapol.type()); EXPECT_EQ(1, eapol.key_t()); EXPECT_EQ(0, eapol.key_index()); EXPECT_EQ(1, eapol.install()); EXPECT_EQ(1, eapol.key_ack()); EXPECT_EQ(1, eapol.key_mic()); EXPECT_EQ(1, eapol.secure()); EXPECT_EQ(0, eapol.error()); EXPECT_EQ(0, eapol.request()); EXPECT_EQ(1, eapol.encrypted()); EXPECT_EQ(16, eapol.key_length()); EXPECT_EQ(2, eapol.replay_counter()); EXPECT_TRUE(std::equal(nonce, nonce + sizeof(nonce), eapol.nonce())); EXPECT_TRUE(std::equal(empty_iv, empty_iv + sizeof(empty_iv), eapol.key_iv())); EXPECT_TRUE(std::equal(rsc, rsc + sizeof(rsc), eapol.rsc())); EXPECT_TRUE(std::equal(id, id + sizeof(id), eapol.id())); EXPECT_TRUE(std::equal(mic, mic + sizeof(mic), eapol.mic())); ASSERT_EQ(56, eapol.wpa_length()); RSNEAPOL::key_type key_found = eapol.key(); ASSERT_EQ(56, key_found.size()); EXPECT_TRUE(std::equal(key, key + sizeof(key), key_found.begin())); } TEST_F(RSNEAPOLTest, Serialize) { RSNEAPOL eapol(expected_packet, sizeof(expected_packet)); RSNEAPOL::serialization_type buffer = eapol.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } TEST_F(RSNEAPOLTest, ConstructionTest) { RSNEAPOL eapol; eapol.version(1); eapol.packet_type(3); eapol.length(151); eapol.key_length(16); eapol.replay_counter(2); eapol.nonce(nonce); eapol.key_iv(empty_iv); eapol.rsc(rsc); eapol.id(id); eapol.mic(mic); eapol.key(RSNEAPOL::key_type(key, key + sizeof(key))); eapol.key_descriptor(2); eapol.key_t(1); eapol.install(1); eapol.key_ack(1); eapol.key_mic(1); eapol.secure(1); eapol.encrypted(1); RSNEAPOL::serialization_type buffer = eapol.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); RSNEAPOL eapol2(&buffer[0], buffer.size()); test_equals(eapol, eapol2); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } TEST_F(RSNEAPOLTest, ReplayCounter) { RSNEAPOL eapol; eapol.replay_counter(0x7af3d91a1fd3abLL); EXPECT_EQ(0x7af3d91a1fd3abLL, eapol.replay_counter()); } TEST_F(RSNEAPOLTest, WPALength) { RSNEAPOL eapol; eapol.wpa_length(0x9af1); EXPECT_EQ(0x9af1, eapol.wpa_length()); } TEST_F(RSNEAPOLTest, KeyIV) { RSNEAPOL eapol; eapol.key_iv(empty_iv); EXPECT_TRUE(std::equal(empty_iv, empty_iv + sizeof(empty_iv), eapol.key_iv())); } TEST_F(RSNEAPOLTest, Nonce) { RSNEAPOL eapol; eapol.nonce(nonce); EXPECT_TRUE(std::equal(nonce, nonce + sizeof(nonce), eapol.nonce())); } TEST_F(RSNEAPOLTest, Key) { RSNEAPOL eapol; uint8_t arr[] = { 1, 9, 2, 0x71, 0x87, 0xfa, 0xdf }; RSNEAPOL::key_type key(arr, arr + sizeof(arr)); eapol.key(key); EXPECT_EQ(key, eapol.key()); } libtins-1.1/tests/src/rc4eapol.cpp0000664000175000017500000000521012154360113016477 0ustar matiasmatias#include #include #include #include #include "eapol.h" #include "utils.h" using namespace std; using namespace Tins; class RC4EAPOLTest : public testing::Test { public: }; TEST_F(RC4EAPOLTest, DefaultConstructor) { uint8_t empty_iv[RC4EAPOL::key_iv_size] = { 0 }; RC4EAPOL eapol; EXPECT_EQ(1, eapol.version()); EXPECT_EQ(0x3, eapol.packet_type()); EXPECT_EQ(EAPOL::RC4, eapol.type()); EXPECT_EQ(0, eapol.length()); EXPECT_EQ(0, eapol.key_length()); EXPECT_EQ(0, eapol.replay_counter()); EXPECT_TRUE(std::equal(empty_iv, empty_iv + sizeof(empty_iv), eapol.key_iv())); EXPECT_EQ(0, eapol.key_flag()); EXPECT_EQ(0, eapol.key_index()); EXPECT_TRUE(std::equal(empty_iv, empty_iv + sizeof(empty_iv), eapol.key_sign())); EXPECT_EQ(RC4EAPOL::key_type(), eapol.key()); } TEST_F(RC4EAPOLTest, Version) { RC4EAPOL eapol; eapol.version(0x7a); EXPECT_EQ(0x7a, eapol.version()); } TEST_F(RC4EAPOLTest, PacketType) { RC4EAPOL eapol; eapol.packet_type(0x7a); EXPECT_EQ(0x7a, eapol.packet_type()); } TEST_F(RC4EAPOLTest, Length) { RC4EAPOL eapol; eapol.length(0x7af2); EXPECT_EQ(0x7af2, eapol.length()); } TEST_F(RC4EAPOLTest, Type) { RC4EAPOL eapol; eapol.type(0x7a); EXPECT_EQ(0x7a, eapol.type()); } TEST_F(RC4EAPOLTest, KeyLength) { RC4EAPOL eapol; eapol.key_length(0x7af3); EXPECT_EQ(0x7af3, eapol.key_length()); } TEST_F(RC4EAPOLTest, ReplayCounter) { RC4EAPOL eapol; eapol.replay_counter(0x7af3d91a1fd3abLL); EXPECT_EQ(0x7af3d91a1fd3abLL, eapol.replay_counter()); } TEST_F(RC4EAPOLTest, KeyIV) { uint8_t iv[RC4EAPOL::key_iv_size]; for(unsigned i = 0; i < RC4EAPOL::key_iv_size; ++i) iv[i] = i; RC4EAPOL eapol; eapol.key_iv(iv); EXPECT_TRUE(std::equal(iv, iv + sizeof(iv), eapol.key_iv())); } TEST_F(RC4EAPOLTest, KeyFlag) { RC4EAPOL eapol; eapol.key_flag(1); EXPECT_EQ(1, eapol.key_flag()); eapol.key_flag(0); EXPECT_EQ(0, eapol.key_flag()); } TEST_F(RC4EAPOLTest, KeyIndex) { RC4EAPOL eapol; eapol.key_index(0x7d); EXPECT_EQ(0x7d, eapol.key_index()); } TEST_F(RC4EAPOLTest, KeySign) { uint8_t sign[RC4EAPOL::key_sign_size]; for(unsigned i = 0; i < RC4EAPOL::key_sign_size; ++i) sign[i] = i; RC4EAPOL eapol; eapol.key_sign(sign); EXPECT_TRUE(std::equal(sign, sign + sizeof(sign), eapol.key_sign())); } TEST_F(RC4EAPOLTest, Key) { RC4EAPOL eapol; uint8_t arr[] = { 1, 9, 2, 0x71, 0x87, 0xfa, 0xdf }; RC4EAPOL::key_type key(arr, arr + sizeof(arr)); eapol.key(key); EXPECT_EQ(key, eapol.key()); } libtins-1.1/tests/src/radiotap.cpp0000664000175000017500000001514312154360113016577 0ustar matiasmatias#include #include #include #include #include "radiotap.h" #include "dot11/dot11_data.h" #include "dot11/dot11_beacon.h" #include "utils.h" using namespace std; using namespace Tins; class RadioTapTest : public testing::Test { public: static const uint8_t expected_packet[], expected_packet1[], expected_packet2[]; }; const uint8_t RadioTapTest::expected_packet[] = { 0, 0, 32, 0, 103, 8, 4, 0, 84, 198, 184, 36, 0, 0, 0, 0, 16, 12, 218, 160, 2, 0, 0, 0, 64, 1, 0, 0, 60, 20, 36, 17, 128, 0, 0, 0, 255, 255, 255, 255, 255, 255, 6, 3, 127, 7, 160, 22, 6, 3, 127, 7, 160, 22, 176, 119, 58, 64, 203, 38, 0, 0, 0, 0, 100, 0, 1, 5, 0, 10, 102, 114, 101, 101, 98, 115, 100, 45, 97, 112, 1, 8, 140, 18, 152, 36, 176, 72, 96, 108, 3, 1, 36, 5, 4, 0, 1, 0, 0, 7, 42, 85, 83, 32, 36, 1, 17, 40, 1, 17, 44, 1, 17, 48, 1, 17, 52, 1, 23, 56, 1, 23, 60, 1, 23, 64, 1, 23, 149, 1, 30, 153, 1, 30, 157, 1, 30, 161, 1, 30, 165, 1, 30, 32, 1, 0, 221, 24, 0, 80, 242, 2, 1, 1, 0, 0, 3, 164, 0, 0, 39, 164, 0, 0, 66, 67, 94, 0, 98, 50, 47, 0, 229, 45, 146, 17 }; const uint8_t RadioTapTest::expected_packet1[] = { 0, 0, 26, 0, 47, 72, 0, 0, 7, 214, 110, 166, 0, 0, 0, 0, 16, 2, 108, 9, 160, 0, 176, 1, 0, 0, 128, 0, 0, 0, 255, 255, 255, 255, 255, 255, 124, 79, 181, 147, 114, 92, 124, 79, 181, 147, 114, 92, 128, 104, 71, 81, 56, 61, 145, 8, 0, 0, 100, 0, 17, 4, 0, 13, 65, 82, 86, 55, 53, 49, 57, 57, 51, 55, 50, 53, 67, 1, 8, 130, 132, 139, 150, 18, 36, 72, 108, 3, 1, 1, 50, 4, 12, 24, 48, 96, 7, 6, 78, 76, 32, 1, 13, 20, 51, 8, 32, 1, 2, 3, 4, 5, 6, 7, 51, 8, 33, 5, 6, 7, 8, 9, 10, 11, 221, 14, 0, 80, 242, 4, 16, 74, 0, 1, 16, 16, 68, 0, 1, 2, 5, 4, 0, 1, 0, 0, 42, 1, 4, 45, 26, 108, 0, 23, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, 22, 1, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 1, 1, 221, 24, 0, 80, 242, 1, 1, 0, 0, 80, 242, 2, 1, 0, 0, 80, 242, 2, 1, 0, 0, 80, 242, 2, 0, 0, 48, 20, 1, 0, 0, 15, 172, 2, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 2, 1, 0, 221, 24, 0, 80, 242, 2, 1, 1, 0, 0, 3, 164, 0, 0, 39, 164, 0, 0, 66, 67, 94, 0, 98, 50, 47, 0, 11, 5, 0, 0, 39, 122, 18, 221, 30, 0, 144, 76, 51, 108, 0, 23, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 221, 26, 0, 144, 76, 52, 1, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 139, 60, 178 }; const uint8_t RadioTapTest::expected_packet2[] = { 0, 0, 34, 0, 47, 72, 0, 0, 166, 1, 78, 68, 1, 0, 0, 0, 2, 18, 143, 9, 192, 0, 185, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 136, 66, 223, 0, 0, 33, 106, 120, 24, 244, 0, 37, 156, 66, 159, 63, 132, 24, 136, 177, 96, 139, 160, 246, 0, 0, 105, 15, 0, 32, 0, 0, 0, 0, 144, 70, 21, 19, 239, 128, 176, 53, 109, 131, 215, 214, 175, 122, 48, 125, 96, 224, 165, 112, 100, 218, 16, 165, 71, 12, 251, 231, 214, 69, 86, 10, 41, 95, 147, 149, 126, 177, 131, 158, 124, 227, 49, 222, 97, 79, 200, 223, 132, 241, 42, 135, 151, 94, 223, 190, 109, 180, 255, 115, 238, 211 }; TEST_F(RadioTapTest, DefaultConstructor) { RadioTap radio; EXPECT_TRUE(radio.flags() & RadioTap::FCS); EXPECT_EQ(Utils::mhz_to_channel(radio.channel_freq()), 1); EXPECT_EQ(radio.channel_type(), 0xa0); EXPECT_EQ(radio.tsft(), 0); EXPECT_EQ(radio.dbm_signal(), 0xce); EXPECT_EQ(radio.antenna(), 0); EXPECT_EQ(radio.rx_flags(), 0); } TEST_F(RadioTapTest, ConstructorFromBuffer) { RadioTap radio(expected_packet, sizeof(expected_packet)); EXPECT_EQ(radio.version(), 0); EXPECT_EQ(radio.length(), 32); EXPECT_EQ(radio.rate(), 0xc); EXPECT_EQ(radio.flags(), 0x10); EXPECT_TRUE(radio.flags() & RadioTap::FCS); EXPECT_EQ(radio.channel_type(), 0x140); EXPECT_EQ(radio.tsft(), 616089172); EXPECT_EQ(radio.dbm_signal(), 0xda); EXPECT_EQ(radio.dbm_noise(), 0xa0); EXPECT_EQ(radio.antenna(), 2); } TEST_F(RadioTapTest, ConstructorFromBuffer1) { RadioTap radio(expected_packet1, sizeof(expected_packet1)); EXPECT_EQ(radio.version(), 0); EXPECT_EQ(radio.length(), 26); EXPECT_EQ(radio.rate(), 2); EXPECT_EQ(radio.flags(), 0x10); EXPECT_TRUE(radio.flags() & RadioTap::FCS); EXPECT_EQ(radio.antenna(), 1); EXPECT_TRUE(radio.find_pdu()); } TEST_F(RadioTapTest, ConstructorFromBuffer2) { RadioTap radio(expected_packet2, sizeof(expected_packet2)); EXPECT_TRUE(radio.present() & RadioTap::RATE); EXPECT_TRUE(radio.present() & RadioTap::CHANNEL); EXPECT_TRUE(radio.present() & RadioTap::DBM_SIGNAL); EXPECT_TRUE(radio.present() & RadioTap::ANTENNA); EXPECT_TRUE(radio.present() & RadioTap::RX_FLAGS); EXPECT_EQ(radio.version(), 0); EXPECT_EQ(radio.length(), 34); EXPECT_EQ(radio.rate(), 0x12); EXPECT_EQ(radio.flags(), 0x02); EXPECT_EQ(radio.dbm_signal(), 0xb9); EXPECT_EQ(radio.channel_type(), 192); EXPECT_EQ(radio.channel_freq(), 2447); EXPECT_EQ(radio.antenna(), 0); EXPECT_TRUE(radio.find_pdu()); } TEST_F(RadioTapTest, Serialize) { RadioTap radio(expected_packet, sizeof(expected_packet)); RadioTap::serialization_type buffer = radio.serialize(); ASSERT_EQ(buffer.size(), sizeof(expected_packet)); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } TEST_F(RadioTapTest, Channel) { RadioTap radio; radio.channel(0xfa23, 0xfb6a); EXPECT_EQ(radio.channel_freq(), 0xfa23); EXPECT_EQ(radio.channel_type(), 0xfb6a); } TEST_F(RadioTapTest, Antenna) { RadioTap radio; radio.antenna(0x7a); EXPECT_EQ(radio.antenna(), 0x7a); } TEST_F(RadioTapTest, Padding) { RadioTap radio; radio.padding(0x7a); EXPECT_EQ(radio.padding(), 0x7a); } TEST_F(RadioTapTest, Version) { RadioTap radio; radio.version(0x7a); EXPECT_EQ(radio.version(), 0x7a); } TEST_F(RadioTapTest, Length) { RadioTap radio; radio.length(0x7a); EXPECT_EQ(radio.length(), 0x7a); } TEST_F(RadioTapTest, DBMSignal) { RadioTap radio; radio.dbm_signal(0x7a); EXPECT_EQ(radio.dbm_signal(), 0x7a); } TEST_F(RadioTapTest, DBMNoise) { RadioTap radio; radio.dbm_noise(0x7a); EXPECT_EQ(radio.dbm_noise(), 0x7a); } TEST_F(RadioTapTest, RXFlags) { RadioTap radio; radio.rx_flags(0x7afb); EXPECT_EQ(radio.rx_flags(), 0x7afb); } TEST_F(RadioTapTest, Rate) { RadioTap radio; radio.rate(0x7a); EXPECT_EQ(radio.rate(), 0x7a); } TEST_F(RadioTapTest, TSFT) { RadioTap radio; radio.tsft(0x7afb9a8d); EXPECT_EQ(radio.tsft(), 0x7afb9a8d); } libtins-1.1/tests/src/pppoe.cpp0000664000175000017500000001037012154360113016114 0ustar matiasmatias#include #include #include #include #include "pppoe.h" #include "ethernetII.h" using namespace std; using namespace Tins; class PPPoETest : public testing::Test { public: static const uint8_t expected_packet[]; }; const uint8_t PPPoETest::expected_packet[] = { 17, 9, 0, 0, 0, 16, 1, 1, 0, 0, 1, 2, 0, 0, 1, 3, 0, 4, 97, 98, 99, 100 }; TEST_F(PPPoETest, DefaultConstructor) { PPPoE pdu; EXPECT_EQ(1, pdu.version()); EXPECT_EQ(1, pdu.type()); EXPECT_EQ(0, pdu.code()); EXPECT_EQ(0, pdu.session_id()); EXPECT_EQ(0, pdu.payload_length()); } TEST_F(PPPoETest, ConstructorFromBuffer) { PPPoE pdu(expected_packet, sizeof(expected_packet)); EXPECT_EQ(1, pdu.version()); EXPECT_EQ(1, pdu.type()); EXPECT_EQ(0x09, pdu.code()); EXPECT_EQ(0, pdu.session_id()); EXPECT_EQ(16, pdu.payload_length()); EXPECT_EQ(3, pdu.tags().size()); EXPECT_EQ("", pdu.service_name()); ASSERT_TRUE(pdu.search_tag(PPPoE::SERVICE_NAME)); } TEST_F(PPPoETest, StackedOnEthernet) { EthernetII eth = EthernetII() / PPPoE(); PDU::serialization_type buffer = eth.serialize(); EthernetII eth2(&buffer[0], buffer.size()); ASSERT_TRUE(eth2.find_pdu()); } TEST_F(PPPoETest, Serialize) { PPPoE pdu(expected_packet, sizeof(expected_packet)); PPPoE::serialization_type buffer = pdu.serialize(); EXPECT_EQ( PPPoE::serialization_type(expected_packet, expected_packet + sizeof(expected_packet)), buffer ); } TEST_F(PPPoETest, Version) { PPPoE pdu; pdu.version(6); EXPECT_EQ(6, pdu.version()); } TEST_F(PPPoETest, Type) { PPPoE pdu; pdu.type(6); EXPECT_EQ(6, pdu.type()); } TEST_F(PPPoETest, Code) { PPPoE pdu; pdu.code(0x7a); EXPECT_EQ(0x7a, pdu.code()); } TEST_F(PPPoETest, SessionID) { PPPoE pdu; pdu.session_id(0x9182); EXPECT_EQ(0x9182, pdu.session_id()); } TEST_F(PPPoETest, PayloadLength) { PPPoE pdu; pdu.payload_length(0x9182); EXPECT_EQ(0x9182, pdu.payload_length()); } TEST_F(PPPoETest, ServiceName) { PPPoE pdu; pdu.service_name("carlos"); EXPECT_EQ("carlos", pdu.service_name()); } TEST_F(PPPoETest, ACName) { PPPoE pdu; pdu.ac_name("carlos"); EXPECT_EQ("carlos", pdu.ac_name()); } TEST_F(PPPoETest, HostUniq) { PPPoE pdu; uint8_t a[] = { 1,2,3,4,5,6 }; byte_array data(a, a + sizeof(a)); pdu.host_uniq(data); EXPECT_EQ(data, pdu.host_uniq()); } TEST_F(PPPoETest, ACCookie) { PPPoE pdu; uint8_t a[] = { 1,2,3,4,5,6 }; byte_array data(a, a + sizeof(a)); pdu.ac_cookie(data); EXPECT_EQ(data, pdu.ac_cookie()); } TEST_F(PPPoETest, VendorSpecific) { PPPoE pdu; uint8_t a[] = { 1,2,3,4,5,6 }; PPPoE::vendor_spec_type output, data( 0x9283f78, PPPoE::vendor_spec_type::data_type(a, a + sizeof(a)) ); pdu.vendor_specific(data); output = pdu.vendor_specific(); EXPECT_EQ(data.data, output.data); EXPECT_EQ(data.vendor_id, output.vendor_id); } TEST_F(PPPoETest, RelaySessionID) { PPPoE pdu; uint8_t a[] = { 1,2,3,4,5,6 }; byte_array data(a, a + sizeof(a)); pdu.relay_session_id(data); EXPECT_EQ(data, pdu.relay_session_id()); } TEST_F(PPPoETest, ServiceNameError) { { PPPoE pdu; pdu.service_name_error("carlos"); EXPECT_EQ("carlos", pdu.service_name_error()); } { PPPoE pdu; pdu.service_name_error(""); EXPECT_EQ("", pdu.service_name_error()); } } TEST_F(PPPoETest, ACSystemError) { PPPoE pdu; pdu.ac_system_error("carlos"); EXPECT_EQ("carlos", pdu.ac_system_error()); } TEST_F(PPPoETest, GenericError) { PPPoE pdu; pdu.generic_error("carlos"); EXPECT_EQ("carlos", pdu.generic_error()); } TEST_F(PPPoETest, SpoofedOptions) { PPPoE pdu; uint8_t a[] = { 1,2,3,4,5,6 }; pdu.add_tag( PPPoE::tag(PPPoE::VENDOR_SPECIFIC, 65000, a, a + sizeof(a)) ); pdu.add_tag( PPPoE::tag(PPPoE::VENDOR_SPECIFIC, 65000, a, a + sizeof(a)) ); pdu.add_tag( PPPoE::tag(PPPoE::VENDOR_SPECIFIC, 65000, a, a + sizeof(a)) ); // probably we'd expect it to crash if it's not working, valgrind plx EXPECT_EQ(3, pdu.tags().size()); EXPECT_EQ(pdu.serialize().size(), pdu.size()); } libtins-1.1/tests/src/pdu.cpp0000664000175000017500000000413612154360113015564 0ustar matiasmatias#include #include #include #include #include "ip.h" #include "tcp.h" #include "udp.h" #include "rawpdu.h" #include "pdu.h" #include "packet.h" using namespace std; using namespace Tins; class PDUTest : public testing::Test { public: }; TEST_F(PDUTest, FindPDU) { IP ip = IP("192.168.0.1") / TCP(22, 52) / RawPDU("Test"); EXPECT_TRUE(ip.find_pdu()); EXPECT_TRUE(ip.find_pdu()); EXPECT_FALSE(ip.find_pdu()); TCP &t1 = ip.rfind_pdu(); const TCP &t2 = ip.rfind_pdu(); (void)t1; (void)t2; EXPECT_THROW(ip.rfind_pdu(), pdu_not_found); } TEST_F(PDUTest, OperatorConcat) { std::string raw_payload = "Test"; IP ip = IP("192.168.0.1") / TCP(22, 52) / RawPDU(raw_payload); EXPECT_EQ(ip.dst_addr(), "192.168.0.1"); ASSERT_TRUE(ip.inner_pdu()); TCP *tcp = ip.find_pdu(); ASSERT_TRUE(tcp); EXPECT_EQ(tcp->dport(), 22); EXPECT_EQ(tcp->sport(), 52); ASSERT_TRUE(tcp->inner_pdu()); RawPDU *raw = tcp->find_pdu(); ASSERT_TRUE(raw); ASSERT_EQ(raw->payload_size(), raw_payload.size()); EXPECT_TRUE(std::equal(raw_payload.begin(), raw_payload.end(), raw->payload().begin())); } TEST_F(PDUTest, OperatorConcatOnPointers) { std::string raw_payload = "Test"; IP ip = IP("192.168.0.1") / TCP(22, 52); TCP *tcp = ip.find_pdu(); ASSERT_TRUE(tcp); tcp /= RawPDU(raw_payload); RawPDU *raw = ip.find_pdu(); ASSERT_TRUE(raw); ASSERT_EQ(raw->payload_size(), raw_payload.size()); EXPECT_TRUE(std::equal(raw->payload().begin(), raw->payload().end(), raw_payload.begin())); } TEST_F(PDUTest, OperatorConcatOnPacket) { std::string raw_payload = "Test"; Packet packet = IP("192.168.0.1") / TCP(22, 52); TCP *tcp = packet.pdu()->find_pdu(); ASSERT_TRUE(tcp); tcp /= RawPDU(raw_payload); RawPDU *raw = packet.pdu()->find_pdu(); ASSERT_TRUE(raw); ASSERT_EQ(raw->payload_size(), raw_payload.size()); EXPECT_TRUE(std::equal(raw->payload().begin(), raw->payload().end(), raw_payload.begin())); } libtins-1.1/tests/src/network_interface.cpp0000664000175000017500000000334212154360113020503 0ustar matiasmatias#include #include #include "network_interface.h" #include "utils.h" #include "macros.h" using namespace Tins; class NetworkInterfaceTest : public ::testing::Test { public: static const std::string iface_name, iface_addr; }; #ifdef BSD const std::string NetworkInterfaceTest::iface_name("lo0"), NetworkInterfaceTest::iface_addr(""); #elif defined(WIN32) // modify me on every windows environment :D const std::string NetworkInterfaceTest::iface_name("{INSERT-SOME-INTERFACE-NAME}"), NetworkInterfaceTest::iface_addr(""); #else const std::string NetworkInterfaceTest::iface_name("lo"), NetworkInterfaceTest::iface_addr(""); #endif TEST_F(NetworkInterfaceTest, ConstructorFromString) { // just test this doesn't throw NetworkInterface iface(iface_name); try { NetworkInterface iface("ishallnotexist"); ASSERT_TRUE(false); } catch(...) { } } TEST_F(NetworkInterfaceTest, ConstructorFromIp) { NetworkInterface iface(IPv4Address("127.0.0.1")); EXPECT_EQ(iface.name(), iface_name); } TEST_F(NetworkInterfaceTest, Id) { NetworkInterface iface(iface_name); EXPECT_TRUE(iface.id() != 0); } TEST_F(NetworkInterfaceTest, Info) { NetworkInterface iface(iface_name); NetworkInterface::Info info(iface.addresses()); // assuming it's like this EXPECT_EQ(info.ip_addr, "127.0.0.1"); EXPECT_EQ(info.netmask, "255.0.0.0"); } TEST_F(NetworkInterfaceTest, EqualsOperator) { NetworkInterface iface1(iface_name), iface2(iface_name); EXPECT_EQ(iface1, iface2); } TEST_F(NetworkInterfaceTest, DistinctOperator) { NetworkInterface iface1(iface_name), iface2; EXPECT_NE(iface1, iface2); } libtins-1.1/tests/src/matches_response.cpp0000664000175000017500000002221512154360113020334 0ustar matiasmatias#include #include #include "ethernetII.h" #include "rawpdu.h" #include "udp.h" #include "dhcp.h" #include "dhcpv6.h" using namespace Tins; class MatchesResponseTest : public ::testing::Test { public: }; TEST_F(MatchesResponseTest, TCPSynAck) { uint8_t syn_data[] = { 0, 27, 17, 210, 27, 235, 0, 25, 209, 146, 248, 43, 8, 0, 69, 0, 0, 60, 21, 131, 64, 0, 64, 6, 163, 131, 192, 168, 0, 100, 192, 168, 0, 1, 219, 85, 31, 144, 11, 209, 99, 140, 0, 0, 0, 0, 160, 2, 57, 8, 129, 228, 0, 0, 2, 4, 5, 180, 4, 2, 8, 10, 0, 6, 118, 15, 0, 0, 0, 0, 1, 3, 3, 7 }; uint8_t resp_data[] = { 0, 25, 209, 146, 248, 43, 0, 27, 17, 210, 27, 235, 8, 0, 69, 0, 0, 40, 0, 0, 64, 0, 64, 6, 185, 26, 192, 168, 0, 1, 192, 168, 0, 100, 31, 144, 219, 85, 0, 0, 0, 0, 11, 209, 99, 141, 80, 20, 0, 0, 195, 214, 0, 0, 0, 0, 0, 0, 0, 0 }; EthernetII sent(syn_data, sizeof(syn_data)); EXPECT_TRUE(sent.matches_response(resp_data, sizeof(resp_data))); EXPECT_FALSE(sent.matches_response(syn_data, sizeof(syn_data))); } TEST_F(MatchesResponseTest, DHCP) { uint8_t dhcp_discover[] = { 255, 255, 255, 255, 255, 255, 0, 1, 1, 0, 0, 1, 8, 0, 69, 0, 1, 25, 77, 62, 0, 0, 64, 17, 44, 151, 0, 0, 0, 0, 255, 255, 255, 255, 0, 68, 0, 67, 1, 5, 0, 0, 1, 1, 6, 0, 217, 7, 133, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 130, 83, 99, 53, 1, 1, 61, 7, 1, 0, 1, 1, 0, 0, 1, 255 }; uint8_t dhcp_offer[] = { 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 2, 8, 0, 69, 0, 1, 28, 221, 161, 0, 0, 64, 17, 158, 45, 127, 0, 0, 1, 127, 0, 0, 1, 0, 67, 0, 68, 1, 8, 0, 0, 2, 1, 6, 0, 217, 7, 133, 224, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 130, 83, 99, 53, 1, 2, 54, 4, 127, 0, 0, 1, 51, 4, 0, 0, 1, 44, 255 }; EthernetII discover(dhcp_discover, sizeof(dhcp_discover)); UDP *udp = discover.find_pdu(); const RawPDU *raw = discover.find_pdu(); ASSERT_TRUE(udp); ASSERT_TRUE(raw); udp->inner_pdu(raw->to()); EXPECT_TRUE(discover.matches_response(dhcp_offer, sizeof(dhcp_offer))); EXPECT_FALSE(discover.matches_response(dhcp_discover, sizeof(dhcp_discover))); } TEST_F(MatchesResponseTest, ICMP) { uint8_t request[] = { 0, 16, 219, 124, 173, 34, 0, 22, 203, 139, 6, 92, 8, 0, 69, 0, 0, 84, 226, 159, 0, 0, 64, 1, 150, 133, 10, 10, 1, 89, 209, 131, 36, 158, 8, 0, 3, 45, 54, 12, 0, 0, 146, 91, 68, 72, 241, 31, 12, 0, 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, 52, 53, 54, 55 }; uint8_t reply[] = { 0, 22, 203, 139, 6, 92, 0, 16, 219, 124, 173, 34, 8, 0, 69, 0, 0, 84, 74, 84, 0, 0, 55, 1, 55, 209, 209, 131, 36, 158, 10, 10, 1, 89, 0, 0, 11, 45, 54, 12, 0, 0, 146, 91, 68, 72, 241, 31, 12, 0, 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, 52, 53, 54, 55 }; EthernetII pkt(request, sizeof(request)); EXPECT_TRUE(pkt.matches_response(reply, sizeof(reply))); EXPECT_FALSE(pkt.matches_response(request, sizeof(request))); } TEST_F(MatchesResponseTest, ARP) { uint8_t request[] = { 255, 255, 255, 255, 255, 255, 0, 1, 1, 0, 0, 1, 8, 6, 0, 1, 8, 0, 6, 4, 0, 1, 0, 1, 1, 0, 0, 1, 127, 0, 0, 1, 255, 255, 255, 255, 255, 255, 127, 0, 0, 1 }; uint8_t reply[] = { 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 2, 8, 6, 0, 1, 8, 0, 6, 4, 0, 2, 0, 1, 1, 0, 0, 2, 127, 0, 0, 1, 0, 1, 1, 0, 0, 1, 127, 0, 0, 1 }; EthernetII pkt(request, sizeof(request)); EXPECT_TRUE(pkt.matches_response(reply, sizeof(reply))); EXPECT_FALSE(pkt.matches_response(request, sizeof(request))); } TEST_F(MatchesResponseTest, ICMPv6) { uint8_t request[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, 221, 96, 0, 0, 0, 0, 64, 58, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 128, 0, 91, 104, 25, 156, 0, 1, 226, 206, 89, 81, 0, 0, 0, 0, 14, 139, 1, 0, 0, 0, 0, 0, 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, 52, 53, 54, 55 }; uint8_t reply[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, 221, 96, 0, 0, 0, 0, 64, 58, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 129, 0, 90, 104, 25, 156, 0, 1, 226, 206, 89, 81, 0, 0, 0, 0, 14, 139, 1, 0, 0, 0, 0, 0, 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, 52, 53, 54, 55 }; uint8_t not_a_reply[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, 221, 96, 0, 0, 0, 0, 26, 60, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17, 0, 11, 1, 9, 1, 1, 0, 166, 17, 0, 42, 0, 18, 104, 137, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106 }; EthernetII pkt(request, sizeof(request)); EXPECT_TRUE(pkt.matches_response(reply, sizeof(reply))); EXPECT_FALSE(pkt.matches_response(request, sizeof(request))); EXPECT_FALSE(pkt.matches_response(not_a_reply, sizeof(not_a_reply))); } TEST_F(MatchesResponseTest, DHCPv6) { uint8_t request[] = { 51, 51, 0, 1, 0, 2, 0, 2, 179, 193, 64, 207, 134, 221, 96, 0, 0, 0, 0, 52, 17, 128, 254, 128, 0, 0, 0, 0, 0, 0, 2, 2, 179, 255, 254, 193, 64, 207, 255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 34, 2, 35, 0, 52, 243, 80, 1, 0, 83, 101, 0, 1, 0, 14, 0, 1, 0, 6, 17, 195, 100, 52, 0, 22, 118, 189, 211, 18, 0, 3, 0, 12, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 255, 255, 0, 8, 0, 2, 0, 100 }; uint8_t reply[] = { 0, 2, 179, 193, 64, 207, 0, 21, 242, 4, 141, 219, 134, 221, 96, 0, 0, 0, 0, 209, 17, 128, 254, 128, 0, 0, 0, 0, 0, 0, 2, 21, 242, 255, 254, 4, 141, 219, 254, 128, 0, 0, 0, 0, 0, 0, 2, 2, 179, 255, 254, 193, 64, 207, 2, 35, 2, 34, 0, 209, 127, 59, 2, 0, 83, 101, 0, 1, 0, 14, 0, 1, 0, 6, 17, 195, 100, 52, 0, 22, 118, 189, 211, 18, 0, 3, 0, 132, 0, 0, 0, 1, 0, 0, 14, 16, 0, 0, 21, 24, 0, 5, 0, 24, 102, 0, 0, 0, 0, 0, 0, 0, 213, 240, 138, 111, 157, 131, 93, 191, 0, 1, 81, 128, 0, 2, 163, 0, 0, 13, 0, 88, 0, 0, 49, 32, 97, 100, 100, 114, 101, 115, 115, 32, 103, 114, 97, 110, 116, 101, 100, 46, 32, 89, 111, 117, 32, 109, 97, 121, 32, 105, 110, 99, 108, 117, 100, 101, 32, 73, 65, 65, 68, 68, 82, 32, 105, 110, 32, 73, 65, 32, 111, 112, 116, 105, 111, 110, 44, 32, 105, 102, 32, 121, 111, 117, 32, 119, 97, 110, 116, 32, 116, 111, 32, 112, 114, 111, 118, 105, 100, 101, 32, 97, 32, 104, 105, 110, 116, 46, 0, 2, 0, 14, 0, 1, 0, 1, 17, 195, 197, 84, 0, 224, 129, 73, 16, 201, 0, 7, 0, 1, 0, 0, 12, 0, 16, 0, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 }; EthernetII pkt(request, sizeof(request)); UDP *udp = pkt.find_pdu(); const RawPDU *raw = pkt.find_pdu(); ASSERT_TRUE(udp); ASSERT_TRUE(raw); udp->inner_pdu(raw->to()); EXPECT_TRUE(pkt.matches_response(reply, sizeof(reply))); EXPECT_FALSE(pkt.matches_response(request, sizeof(request))); } libtins-1.1/tests/src/main.cpp0000664000175000017500000000023312154360113015712 0ustar matiasmatias#include #include int main(int argc, char *argv[]) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } libtins-1.1/tests/src/llc.cpp0000664000175000017500000001235412154360113015547 0ustar matiasmatias#include #include #include #include #include "llc.h" using namespace Tins; using namespace std; class LLCTest : public testing::Test { public: static const uint8_t from_buffer_unnumbered[]; static const uint8_t from_buffer_info[]; static const uint8_t from_buffer_super[]; //void test_equals(const IP &ip1, const IP &ip2); }; const uint8_t LLCTest::from_buffer_info[] = { 254, 72, 60, 59 }; const uint8_t LLCTest::from_buffer_super[] = { 75, 25, 5, 58 }; const uint8_t LLCTest::from_buffer_unnumbered[] = { 170, 23, 207 }; TEST_F(LLCTest, DefaultConstructor) { LLC llc; EXPECT_EQ(llc.ssap(), 0); EXPECT_EQ(llc.dsap(), 0); EXPECT_EQ(llc.type(), LLC::INFORMATION); EXPECT_EQ(llc.header_size(), 4); EXPECT_EQ(llc.pdu_type(), PDU::LLC); } TEST_F(LLCTest, ParamsConstructor) { LLC llc(0xAD, 0x16); EXPECT_EQ(0xAD, llc.dsap()); EXPECT_EQ(0x16, llc.ssap()); EXPECT_EQ(LLC::INFORMATION, llc.type()); EXPECT_EQ(4, llc.header_size()); EXPECT_EQ(PDU::LLC, llc.pdu_type()); } TEST_F(LLCTest, Group) { LLC llc; llc.group(true); EXPECT_TRUE(llc.group()); llc.group(false); EXPECT_FALSE(llc.group()); } TEST_F(LLCTest, Dsap) { LLC llc; llc.dsap(0xaa); EXPECT_EQ(llc.dsap(), 0xaa); llc.dsap(0x01); EXPECT_EQ(llc.dsap(), 0x01); } TEST_F(LLCTest, Response) { LLC llc; llc.response(true); EXPECT_TRUE(llc.response()); llc.response(false); EXPECT_FALSE(llc.response()); } TEST_F(LLCTest, Ssap) { LLC llc; llc.ssap(0xaa); EXPECT_EQ(llc.ssap(), 0xaa); llc.ssap(0x01); EXPECT_EQ(llc.ssap(), 0x01); } TEST_F(LLCTest, Type) { LLC llc; llc.type(LLC::INFORMATION); EXPECT_EQ(llc.type(), LLC::INFORMATION); llc.type(LLC::SUPERVISORY); EXPECT_EQ(llc.type(), LLC::SUPERVISORY); llc.type(LLC::UNNUMBERED); EXPECT_EQ(llc.type(), LLC::UNNUMBERED); } TEST_F(LLCTest, HeadSize) { LLC llc; llc.type(LLC::INFORMATION); EXPECT_EQ(llc.header_size(), 4); llc.type(LLC::SUPERVISORY); EXPECT_EQ(llc.header_size(), 4); llc.type(LLC::UNNUMBERED); EXPECT_EQ(llc.header_size(), 3); } TEST_F(LLCTest, SendSeqNumber) { LLC llc; llc.type(LLC::INFORMATION); llc.send_seq_number(18); EXPECT_EQ(18, llc.send_seq_number()); llc.send_seq_number(127); EXPECT_EQ(127, llc.send_seq_number()); llc.type(LLC::SUPERVISORY); EXPECT_EQ(0, llc.send_seq_number()); llc.type(LLC::UNNUMBERED); EXPECT_EQ(0, llc.send_seq_number()); } TEST_F(LLCTest, ReceiveSeqNumber) { LLC llc; llc.type(LLC::INFORMATION); llc.receive_seq_number(18); EXPECT_EQ(18, llc.receive_seq_number()); llc.receive_seq_number(127); EXPECT_EQ(127, llc.receive_seq_number()); llc.type(LLC::SUPERVISORY); llc.receive_seq_number(19); EXPECT_EQ(19, llc.receive_seq_number()); llc.receive_seq_number(127); EXPECT_EQ(127, llc.receive_seq_number()); llc.type(LLC::UNNUMBERED); EXPECT_EQ(0, llc.receive_seq_number()); } TEST_F(LLCTest, PollFinal) { LLC llc; llc.type(LLC::INFORMATION); llc.poll_final(true); EXPECT_TRUE(llc.poll_final()); llc.poll_final(false); EXPECT_FALSE(llc.poll_final()); llc.type(LLC::SUPERVISORY); llc.poll_final(true); EXPECT_TRUE(llc.poll_final()); llc.poll_final(false); EXPECT_FALSE(llc.poll_final()); llc.type(LLC::UNNUMBERED); llc.poll_final(true); EXPECT_TRUE(llc.poll_final()); llc.poll_final(false); EXPECT_FALSE(llc.poll_final()); } TEST_F(LLCTest, SupervisoryFunction) { LLC llc; llc.type(LLC::INFORMATION); EXPECT_EQ(0, llc.supervisory_function()); llc.type(LLC::SUPERVISORY); llc.supervisory_function(LLC::RECEIVE_NOT_READY); EXPECT_EQ(LLC::RECEIVE_NOT_READY, llc.supervisory_function()); llc.supervisory_function(LLC::RECEIVE_READY); EXPECT_EQ(LLC::RECEIVE_READY, llc.supervisory_function()); llc.type(LLC::UNNUMBERED); EXPECT_EQ(0, llc.supervisory_function()); } TEST_F(LLCTest, ModifierFunction) { LLC llc; llc.type(LLC::INFORMATION); EXPECT_EQ(0, llc.modifier_function()); llc.type(LLC::SUPERVISORY); EXPECT_EQ(0, llc.modifier_function()); llc.type(LLC::UNNUMBERED); llc.modifier_function(LLC::TEST); EXPECT_EQ(LLC::TEST, llc.modifier_function()); llc.modifier_function(LLC::XID); EXPECT_EQ(LLC::XID, llc.modifier_function()); } TEST_F(LLCTest, ConstructorFromBuffer) { LLC llc(LLCTest::from_buffer_info, 4); EXPECT_EQ(LLC::INFORMATION, llc.type()); EXPECT_EQ(4, llc.header_size()); EXPECT_EQ(0xFE, llc.dsap()); EXPECT_EQ(0x48, llc.ssap()); EXPECT_FALSE(llc.group()); EXPECT_FALSE(llc.response()); EXPECT_TRUE(llc.poll_final()); EXPECT_EQ(30, llc.send_seq_number()); EXPECT_EQ(29, llc.receive_seq_number()); LLC llc_super(LLCTest::from_buffer_super, sizeof(LLCTest::from_buffer_super)); EXPECT_EQ(4, llc_super.header_size()); EXPECT_EQ(0x4B, llc_super.dsap()); EXPECT_EQ(0x19, llc_super.ssap()); EXPECT_TRUE(llc_super.group()); EXPECT_TRUE(llc_super.response()); EXPECT_FALSE(llc_super.poll_final()); EXPECT_EQ(29, llc_super.receive_seq_number()); EXPECT_EQ(LLC::RECEIVE_NOT_READY, llc_super.supervisory_function()); LLC llc_unnum(LLCTest::from_buffer_unnumbered, sizeof(LLCTest::from_buffer_unnumbered)); EXPECT_EQ(llc_unnum.header_size(), 3); EXPECT_EQ(llc_unnum.dsap(), 0xaa); EXPECT_EQ(llc_unnum.ssap(), 0x17); EXPECT_FALSE(llc_unnum.group()); EXPECT_TRUE(llc_unnum.response()); EXPECT_FALSE(llc_unnum.poll_final()); EXPECT_EQ(llc_unnum.modifier_function(), LLC::SABME); } libtins-1.1/tests/src/ipv6address.cpp0000664000175000017500000000523512154360113017227 0ustar matiasmatias#include #include #include #include #include #include #include "ipv6_address.h" #include "utils.h" using namespace Tins; const uint8_t empty_addr[IPv6Address::address_size] = { 0 }; void test_to_string(const std::string &str) { EXPECT_EQ(str, IPv6Address(str).to_string()); } TEST(IPv6AddressTest, DefaultConstructor) { IPv6Address addr; EXPECT_TRUE(std::equal(addr.begin(), addr.end(), empty_addr)); } TEST(IPv6AddressTest, ConstructorFromString1) { IPv6Address addr("2001:db8:85a3:8d3:1319:8a2e:370:7348"); const uint8_t some_addr[IPv6Address::address_size] = { 0x20, 0x01, 0x0d, 0xb8, 0x85, 0xa3, 0x08, 0xd3, 0x13, 0x19, 0x8a, 0x2e, 0x03, 0x70, 0x73, 0x48 }; EXPECT_TRUE(std::equal(addr.begin(), addr.end(), some_addr)); } TEST(IPv6AddressTest, ConstructorFromString2) { IPv6Address addr("2001:db8:85a3::1319:8a2e:370:7348"); const uint16_t some_addr[IPv6Address::address_size] = { 0x20, 0x01, 0x0d, 0xb8, 0x85, 0xa3, 0x00, 0x00, 0x13, 0x19, 0x8a, 0x2e, 0x03, 0x70, 0x73, 0x48 }; EXPECT_TRUE(std::equal(addr.begin(), addr.end(), some_addr)); } TEST(IPv6AddressTest, ConstructorFromString3) { IPv6Address addr("::1"); const uint16_t some_addr[IPv6Address::address_size] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; EXPECT_TRUE(std::equal(addr.begin(), addr.end(), some_addr)); } TEST(IPv6AddressTest, ToString) { test_to_string("2001:db8:85a3:8d3:1319:8a2e:370:7348"); test_to_string("2001:db8:85a3:8d3:1319:8a2e::"); test_to_string("1:db8:85a3:8d3:1319:8a2e:370:7348"); test_to_string("::85a3:8d3:1319:8a2e:370:7348"); test_to_string("::1:2:3"); } TEST(IPv6AddressTest, EqualOperator) { EXPECT_EQ(IPv6Address("17f8::1"), IPv6Address("17f8:0::0:1")); EXPECT_EQ(IPv6Address("::1"), IPv6Address("::1")); EXPECT_EQ(IPv6Address("1::"), IPv6Address("1::")); } TEST(IPv6AddressTest, DistinctOperator) { EXPECT_NE(IPv6Address("17f8::12"), IPv6Address("17f8:0::1:12")); EXPECT_NE(IPv6Address("::1"), IPv6Address("::2")); EXPECT_NE(IPv6Address("4::"), IPv6Address("5::")); } TEST(IPv6AddressTest, LessThanOperator) { EXPECT_LT(IPv6Address("17f8::1"), IPv6Address("17f8:0::0:5")); EXPECT_LT(IPv6Address("::1"), IPv6Address("::5")); EXPECT_LT(IPv6Address("1::"), IPv6Address("2::")); } TEST(IPv6AddressTest, OutputOperator) { std::ostringstream oss; oss << IPv6Address("17f8::1"); EXPECT_EQ("17f8::1", oss.str()); } TEST(IPv6AddressTest, Copy) { IPv6Address addr1("17f8::1"); IPv6Address addr2; addr1.copy(addr2.begin()); EXPECT_EQ(addr1, addr2); } libtins-1.1/tests/src/ipv6.cpp0000664000175000017500000001237212154360113015661 0ustar matiasmatias#include #include #include #include #include "ipv6.h" #include "tcp.h" #include "udp.h" #include "icmp.h" #include "icmpv6.h" #include "ipv6_address.h" #include "utils.h" using namespace std; using namespace Tins; class IPv6Test : public testing::Test { public: static const uint8_t expected_packet1[], expected_packet2[]; void test_equals(IPv6 &ip1, IPv6 &ip2); }; const uint8_t IPv6Test::expected_packet1[] = { 105, 168, 39, 52, 0, 40, 6, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 198, 140, 0, 80, 104, 72, 3, 12, 0, 0, 0, 0, 160, 2, 127, 240, 0, 48, 0, 0, 2, 4, 63, 248, 4, 2, 8, 10, 0, 132, 163, 156, 0, 0, 0, 0, 1, 3, 3, 7 }; const uint8_t IPv6Test::expected_packet2[] = { 96, 0, 0, 0, 0, 36, 0, 1, 254, 128, 0, 0, 0, 0, 0, 0, 2, 208, 9, 255, 254, 227, 232, 222, 255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 58, 0, 5, 2, 0, 0, 1, 0, 143, 0, 116, 254, 0, 0, 0, 1, 4, 0, 0, 0, 255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 255, 152, 6, 225 }; void IPv6Test::test_equals(IPv6 &ip1, IPv6 &ip2) { EXPECT_EQ(ip1.version(), ip2.version()); EXPECT_EQ(ip1.traffic_class(), ip2.traffic_class()); EXPECT_EQ(ip1.flow_label(), ip2.flow_label()); EXPECT_EQ(ip1.payload_length(), ip2.payload_length()); EXPECT_EQ(ip1.next_header(), ip2.next_header()); EXPECT_EQ(ip1.hop_limit(), ip2.hop_limit()); EXPECT_EQ(ip1.dst_addr(), ip2.dst_addr()); EXPECT_EQ(ip1.src_addr(), ip2.src_addr()); EXPECT_EQ(bool(ip1.search_header(IPv6::HOP_BY_HOP)), bool(ip2.search_header(IPv6::HOP_BY_HOP))); const IPv6::ext_header *header1 = ip1.search_header(IPv6::HOP_BY_HOP), *header2 = ip2.search_header(IPv6::HOP_BY_HOP); if(header1 && header2) { EXPECT_EQ(header1->data_size(), header2->data_size()); } EXPECT_EQ(bool(ip1.inner_pdu()), bool(ip2.inner_pdu())); const ICMPv6 *icmp1 = ip1.find_pdu(), *icmp2 = ip2.find_pdu(); ASSERT_EQ(bool(icmp1), bool(icmp2)); if(icmp1 && icmp2) { EXPECT_EQ(icmp1->checksum(), icmp2->checksum()); } } TEST_F(IPv6Test, Constructor) { IPv6 ipv6("::1:2:3", "f0aa:beef::1"); EXPECT_EQ(ipv6.version(), 6); EXPECT_EQ(ipv6.traffic_class(), 0); EXPECT_EQ(ipv6.flow_label(), 0); EXPECT_EQ(ipv6.payload_length(), 0); EXPECT_EQ(ipv6.next_header(), 0); EXPECT_EQ(ipv6.hop_limit(), 0); EXPECT_EQ(ipv6.dst_addr(), "::1:2:3"); EXPECT_EQ(ipv6.src_addr(), "f0aa:beef::1"); } TEST_F(IPv6Test, ConstructorFromBuffer) { IPv6 ipv6(expected_packet1, sizeof(expected_packet1)); EXPECT_EQ(ipv6.version(), 6); EXPECT_EQ(ipv6.traffic_class(), 0x9a); EXPECT_EQ(ipv6.flow_label(), 0x82734); EXPECT_EQ(ipv6.payload_length(), 40); EXPECT_EQ(ipv6.next_header(), 6); EXPECT_EQ(ipv6.hop_limit(), 64); EXPECT_EQ(ipv6.dst_addr(), "::1"); EXPECT_EQ(ipv6.src_addr(), "::1"); ASSERT_TRUE(ipv6.inner_pdu()); TCP *tcp = ipv6.find_pdu(); ASSERT_TRUE(tcp); EXPECT_EQ(tcp->sport(), 50828); EXPECT_EQ(tcp->dport(), 80); } // This one has a hop-by-hop ext header TEST_F(IPv6Test, ConstructorFromBuffer2) { IPv6 ipv6(expected_packet2, sizeof(expected_packet2)); EXPECT_EQ(ipv6.version(), 6); EXPECT_EQ(ipv6.traffic_class(), 0); EXPECT_EQ(ipv6.flow_label(), 0); EXPECT_EQ(ipv6.payload_length(), 36); EXPECT_EQ(ipv6.next_header(), IPv6::HOP_BY_HOP); EXPECT_EQ(ipv6.hop_limit(), 1); EXPECT_EQ(ipv6.dst_addr(), "ff02::16"); EXPECT_EQ(ipv6.src_addr(), "fe80::2d0:9ff:fee3:e8de"); ICMPv6 *pdu = ipv6.find_pdu(); ASSERT_TRUE(pdu); EXPECT_EQ(pdu->type(), 143); EXPECT_EQ(pdu->code(), 0); EXPECT_EQ(pdu->checksum(), 0x74fe); EXPECT_EQ(pdu->checksum(), 0x74fe); const IPv6::ext_header *header = ipv6.search_header(IPv6::HOP_BY_HOP); ASSERT_TRUE(header); EXPECT_EQ(header->data_size(), 6); } TEST_F(IPv6Test, Serialize) { IPv6 ip1(expected_packet2, sizeof(expected_packet2)); IPv6::serialization_type buffer = ip1.serialize(); ASSERT_EQ(buffer.size(), sizeof(expected_packet2)); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet2)); IPv6 ip2(&buffer[0], buffer.size()); test_equals(ip1, ip2); } TEST_F(IPv6Test, Version) { IPv6 ipv6; ipv6.version(3); EXPECT_EQ(ipv6.version(), 3); } TEST_F(IPv6Test, TrafficClass) { IPv6 ipv6; ipv6.traffic_class(0x7a); EXPECT_EQ(ipv6.traffic_class(), 0x7a); } TEST_F(IPv6Test, FlowLabel) { IPv6 ipv6; ipv6.flow_label(0x918d7); EXPECT_EQ(ipv6.flow_label(), 0x918d7); } TEST_F(IPv6Test, PayloadLength) { IPv6 ipv6; ipv6.payload_length(0xaf71); EXPECT_EQ(ipv6.payload_length(), 0xaf71); } TEST_F(IPv6Test, NextHeader) { IPv6 ipv6; ipv6.next_header(0x7a); EXPECT_EQ(ipv6.next_header(), 0x7a); } TEST_F(IPv6Test, HopLimit) { IPv6 ipv6; ipv6.hop_limit(0x7a); EXPECT_EQ(ipv6.hop_limit(), 0x7a); } TEST_F(IPv6Test, SourceAddress) { IPv6 ipv6; ipv6.src_addr("99af:1293::1"); EXPECT_EQ(ipv6.src_addr(), "99af:1293::1"); } TEST_F(IPv6Test, DestinationAddress) { IPv6 ipv6; ipv6.dst_addr("99af:1293::1"); EXPECT_EQ(ipv6.dst_addr(), "99af:1293::1"); } libtins-1.1/tests/src/ipaddress.cpp0000664000175000017500000000240512154360113016747 0ustar matiasmatias#include #include #include #include #include #include "ip_address.h" #include "utils.h" using namespace Tins; std::string ip_string("192.168.0.225"); TEST(IPAddressTest, Constructor) { IPv4Address addr1(ip_string); IPv4Address addr2(ip_string); EXPECT_EQ(addr2, addr1); EXPECT_EQ(addr1.to_string(), ip_string); EXPECT_EQ(addr2.to_string(), ip_string); EXPECT_NE(addr1, "192.168.0.254"); } TEST(IPAddressTest, CopyAssignmentOperator) { IPv4Address addr1(ip_string); uint32_t as_int = addr1; IPv4Address addr2; addr2 = IPv4Address(as_int); EXPECT_EQ(addr1, addr2); uint32_t as_int2 = addr2; EXPECT_EQ(as_int2, as_int); } TEST(IPAddressTest, OutputOperator) { IPv4Address addr(ip_string); std::ostringstream oss; oss << addr; EXPECT_EQ(oss.str(), ip_string); } TEST(IPAddressTest, EqualityOperator) { IPv4Address addr1(ip_string), addr2(ip_string); EXPECT_EQ(addr1, addr2); EXPECT_NE(addr1, "127.0.0.1"); } TEST(IPAddressTest, LessThanOperator) { IPv4Address addr1(ip_string), addr2(ip_string); EXPECT_FALSE(addr1 < addr2); EXPECT_LT(addr1, "192.168.1.2"); EXPECT_LT(addr1, "192.168.0.226"); EXPECT_LT(addr1, "193.0.0.0"); } libtins-1.1/tests/src/ip.cpp0000664000175000017500000001534512154360113015410 0ustar matiasmatias#include #include #include #include #include "ip.h" #include "tcp.h" #include "udp.h" #include "icmp.h" #include "ip_address.h" #include "utils.h" using namespace std; using namespace Tins; class IPTest : public testing::Test { public: static const uint8_t expected_packet[]; void test_equals(const IP &ip1, const IP &ip2); }; const uint8_t IPTest::expected_packet[] = { 40, 127, 0, 32, 0, 122, 0, 67, 21, 1, 0, 0, 84, 52, 254, 5, 192, 168, 9, 43, 130, 11, 116, 106, 103, 171, 119, 171, 104, 101, 108, 0 }; TEST_F(IPTest, DefaultConstructor) { IP ip; EXPECT_EQ(ip.dst_addr(), 0); EXPECT_EQ(ip.src_addr(), 0); EXPECT_EQ(ip.version(), 4); EXPECT_EQ(ip.id(), 1); EXPECT_EQ(ip.pdu_type(), PDU::IP); } TEST_F(IPTest, CopyConstructor) { IP ip1(expected_packet, sizeof(expected_packet)); IP ip2(ip1); test_equals(ip1, ip2); } TEST_F(IPTest, CopyAssignmentOperator) { IP ip1(expected_packet, sizeof(expected_packet)); IP ip2; ip2 = ip1; test_equals(ip1, ip2); } TEST_F(IPTest, NestedCopy) { IP *nested = new IP(expected_packet, sizeof(expected_packet)); IP ip1; ip1.inner_pdu(nested); IP ip2(ip1); test_equals(ip1, ip2); } TEST_F(IPTest, Constructor) { IP ip("192.168.0.1", "192.168.0.100"); EXPECT_EQ(ip.dst_addr(), "192.168.0.1"); EXPECT_EQ(ip.src_addr(), "192.168.0.100"); EXPECT_EQ(ip.version(), 4); EXPECT_EQ(ip.id(), 1); } TEST_F(IPTest, HeadLen) { IP ip; ip.head_len(14); EXPECT_EQ(ip.head_len(), 14); } TEST_F(IPTest, TOS) { IP ip; ip.tos(0x7a); EXPECT_EQ(ip.tos(), 0x7a); } TEST_F(IPTest, TotLen) { IP ip; ip.tot_len(0x7f1a); EXPECT_EQ(ip.tot_len(), 0x7f1a); } TEST_F(IPTest, ID) { IP ip; ip.id(0x7f1a); EXPECT_EQ(ip.id(), 0x7f1a); } TEST_F(IPTest, FragOffset) { IP ip; ip.frag_off(0x7f1a); EXPECT_EQ(ip.frag_off(), 0x7f1a); } TEST_F(IPTest, TTL) { IP ip; ip.ttl(0x7f); EXPECT_EQ(ip.ttl(), 0x7f); } TEST_F(IPTest, Protocol) { IP ip; ip.protocol(0x7f); EXPECT_EQ(ip.protocol(), 0x7f); } TEST_F(IPTest, SrcIPString) { IP ip; string string_ip("192.155.32.10"); ip.src_addr(string_ip); EXPECT_EQ(ip.src_addr(), IPv4Address(string_ip)); } TEST_F(IPTest, DstIPString) { IP ip; string string_ip("192.155.32.10"); ip.dst_addr(string_ip); EXPECT_EQ(ip.dst_addr(), IPv4Address(string_ip)); } TEST_F(IPTest, SrcIPInt) { IP ip; ip.src_addr("192.155.32.10"); EXPECT_EQ(ip.src_addr(), "192.155.32.10"); } TEST_F(IPTest, DstIPInt) { IP ip; ip.dst_addr("192.155.32.10"); EXPECT_EQ(ip.dst_addr(), "192.155.32.10"); } TEST_F(IPTest, Version) { IP ip; ip.version(0xb); EXPECT_EQ(ip.version(), 0xb); } TEST_F(IPTest, SecOption) { IP ip; ip.security(IP::security_type(0x746a, 26539, 0x77ab, 0x68656c)); IP::security_type found = ip.security(); EXPECT_EQ(found.security, 0x746a); EXPECT_EQ(found.compartments, 26539); EXPECT_EQ(found.handling_restrictions, 0x77ab); EXPECT_EQ(found.transmission_control, 0x68656c); } TEST_F(IPTest, LSRROption) { IP ip; IP::lsrr_type lsrr(0x2d); lsrr.routes.push_back("192.168.2.3"); lsrr.routes.push_back("192.168.5.1"); ip.lsrr(lsrr); IP::lsrr_type found = ip.lsrr(); EXPECT_EQ(found.pointer, lsrr.pointer); EXPECT_EQ(found.routes, lsrr.routes); } TEST_F(IPTest, SSRROption) { IP ip; IP::ssrr_type ssrr(0x2d); ssrr.routes.push_back("192.168.2.3"); ssrr.routes.push_back("192.168.5.1"); ip.ssrr(ssrr); IP::ssrr_type found = ip.ssrr(); EXPECT_EQ(found.pointer, ssrr.pointer); EXPECT_EQ(found.routes, ssrr.routes); } TEST_F(IPTest, RecordRouteOption) { IP ip; IP::record_route_type record_route(0x2d); record_route.routes.push_back("192.168.2.3"); record_route.routes.push_back("192.168.5.1"); ip.record_route(record_route); IP::record_route_type found = ip.record_route(); EXPECT_EQ(found.pointer, record_route.pointer); EXPECT_EQ(found.routes, record_route.routes); } TEST_F(IPTest, StreamIDOption) { IP ip; ip.stream_identifier(0x91fa); EXPECT_EQ(0x91fa, ip.stream_identifier()); } TEST_F(IPTest, AddOption) { IP ip; const uint8_t data[] = { 0x15, 0x17, 0x94, 0x66, 0xff }; IP::option_identifier id(IP::SEC, IP::CONTROL, 1); ip.add_option(IP::option(id, data, data + sizeof(data))); const IP::option *opt; ASSERT_TRUE((opt = ip.search_option(id))); ASSERT_EQ(opt->data_size(), sizeof(data)); EXPECT_TRUE(memcmp(opt->data_ptr(), data, sizeof(data)) == 0); } void IPTest::test_equals(const IP &ip1, const IP &ip2) { EXPECT_EQ(ip1.dst_addr(), ip2.dst_addr()); EXPECT_EQ(ip1.src_addr(), ip2.src_addr()); EXPECT_EQ(ip1.id(), ip2.id()); EXPECT_EQ(ip1.frag_off(), ip2.frag_off()); EXPECT_EQ(ip1.tos(), ip2.tos()); EXPECT_EQ(ip1.ttl(), ip2.ttl()); EXPECT_EQ(ip1.version(), ip2.version()); EXPECT_EQ((bool)ip1.inner_pdu(), (bool)ip2.inner_pdu()); } TEST_F(IPTest, ConstructorFromBuffer) { IP ip(expected_packet, sizeof(expected_packet)); EXPECT_EQ(ip.dst_addr(), "192.168.9.43"); EXPECT_EQ(ip.src_addr(), "84.52.254.5"); EXPECT_EQ(ip.id(), 0x7a); EXPECT_EQ(ip.tos(), 0x7f); EXPECT_EQ(ip.frag_off(), 0x43); EXPECT_EQ(ip.protocol(), 1); EXPECT_EQ(ip.ttl(), 0x15); EXPECT_EQ(ip.version(), 2); IP::security_type sec = ip.security(); EXPECT_EQ(sec.security, 0x746a); EXPECT_EQ(sec.compartments, 26539); EXPECT_EQ(sec.handling_restrictions, 0x77ab); EXPECT_EQ(sec.transmission_control, 0x68656c); } TEST_F(IPTest, Serialize) { IP ip1(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = ip1.serialize(); ASSERT_EQ(buffer.size(), sizeof(expected_packet)); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } TEST_F(IPTest, StackedProtocols) { IP ip = IP() / TCP(); IP::serialization_type buffer = ip.serialize(); EXPECT_TRUE(IP(&buffer[0], buffer.size()).find_pdu()); ip = IP() / UDP(); buffer = ip.serialize(); EXPECT_TRUE(IP(&buffer[0], buffer.size()).find_pdu()); ip = IP() / ICMP(); buffer = ip.serialize(); EXPECT_TRUE(IP(&buffer[0], buffer.size()).find_pdu()); } TEST_F(IPTest, SpoofedOptions) { IP pdu; uint8_t a[] = { 1,2,3,4,5,6 }; pdu.add_option( IP::option(IP::NOOP, 250, a, a + sizeof(a)) ); pdu.add_option( IP::option(IP::NOOP, 250, a, a + sizeof(a)) ); pdu.add_option( IP::option(IP::NOOP, 250, a, a + sizeof(a)) ); // probably we'd expect it to crash if it's not working, valgrind plx EXPECT_EQ(3, pdu.options().size()); EXPECT_EQ(pdu.serialize().size(), pdu.size()); } libtins-1.1/tests/src/icmpv6.cpp0000664000175000017500000003055112154360113016200 0ustar matiasmatias#include #include #include #include #include "icmpv6.h" #include "ip.h" #include "tcp.h" #include "utils.h" #include "hw_address.h" using namespace Tins; class ICMPv6Test : public testing::Test { public: static const uint8_t expected_packet[]; static const uint8_t expected_packet1[]; void test_equals(const ICMPv6 &icmp1, const ICMPv6 &icmp2); }; const uint8_t ICMPv6Test::expected_packet[] = { 136, 0, 220, 21, 192, 0, 0, 0, 63, 254, 5, 7, 0, 0, 0, 1, 2, 96, 151, 255, 254, 7, 105, 234 }; const uint8_t ICMPv6Test::expected_packet1[] = { 134, 0, 70, 37, 64, 0, 7, 8, 0, 0, 117, 48, 0, 0, 3, 232, 1, 1, 0, 96, 151, 7, 105, 234, 5, 1, 0, 0, 0, 0, 5, 220, 3, 4, 64, 192, 0, 54, 238, 128, 0, 54, 238, 128, 0, 0, 0, 0, 63, 254, 5, 7, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; TEST_F(ICMPv6Test, Constructor) { ICMPv6 icmp; EXPECT_EQ(icmp.type(), ICMPv6::ECHO_REQUEST); EXPECT_EQ(icmp.code(), 0); EXPECT_EQ(icmp.checksum(), 0); EXPECT_EQ(icmp.identifier(), 0); EXPECT_EQ(icmp.sequence(), 0); EXPECT_EQ(icmp.override(), 0); EXPECT_EQ(icmp.solicited(), 0); EXPECT_EQ(icmp.router(), 0); EXPECT_EQ(icmp.hop_limit(), 0); EXPECT_EQ(icmp.router_pref(), 0); EXPECT_EQ(icmp.home_agent(), 0); EXPECT_EQ(icmp.other(), 0); EXPECT_EQ(icmp.managed(), 0); EXPECT_EQ(icmp.router_lifetime(), 0); } TEST_F(ICMPv6Test, ConstructorFromBuffer) { ICMPv6 icmp(expected_packet, sizeof(expected_packet)); EXPECT_EQ(icmp.type(), ICMPv6::NEIGHBOUR_ADVERT); EXPECT_EQ(icmp.code(), 0); EXPECT_EQ(icmp.checksum(), 0xdc15); EXPECT_EQ(icmp.solicited(), 1); EXPECT_EQ(icmp.router(), 1); EXPECT_EQ(icmp.override(), 0); EXPECT_EQ(icmp.target_addr(), "3ffe:507:0:1:260:97ff:fe07:69ea"); } TEST_F(ICMPv6Test, ConstructorFromBuffer2) { ICMPv6 icmp(expected_packet1, sizeof(expected_packet1)); EXPECT_EQ(icmp.type(), ICMPv6::ROUTER_ADVERT); EXPECT_EQ(icmp.code(), 0); EXPECT_EQ(icmp.checksum(), 0x4625); EXPECT_EQ(icmp.managed(), 0); EXPECT_EQ(icmp.home_agent(), 0); EXPECT_EQ(icmp.other(), 0); EXPECT_EQ(icmp.router_pref(), 0); EXPECT_EQ(icmp.router_lifetime(), 1800); EXPECT_EQ(icmp.reachable_time(), 30000); EXPECT_EQ(icmp.retransmit_timer(), 1000); const ICMPv6::option *opt = icmp.search_option(ICMPv6::SOURCE_ADDRESS); ASSERT_TRUE(opt); EXPECT_EQ(opt->data_size(), 6); EXPECT_EQ(HWAddress<6>(opt->data_ptr()), "00:60:97:07:69:ea"); opt = icmp.search_option(ICMPv6::MTU); ASSERT_TRUE(opt); EXPECT_EQ(opt->data_size(), 6); opt = icmp.search_option(ICMPv6::PREFIX_INFO); ASSERT_TRUE(opt); EXPECT_EQ(opt->data_size(), 30); } TEST_F(ICMPv6Test, Type) { ICMPv6 icmp; icmp.type(ICMPv6::MLD2_REPORT); EXPECT_EQ(icmp.type(), ICMPv6::MLD2_REPORT); } TEST_F(ICMPv6Test, Code) { ICMPv6 icmp; icmp.code(0x7a); EXPECT_EQ(icmp.code(), 0x7a); } TEST_F(ICMPv6Test, Checksum) { ICMPv6 icmp; icmp.checksum(0x827f); EXPECT_EQ(icmp.checksum(), 0x827f); } TEST_F(ICMPv6Test, Identifier) { ICMPv6 icmp; icmp.identifier(0x827f); EXPECT_EQ(icmp.identifier(), 0x827f); } TEST_F(ICMPv6Test, Sequence) { ICMPv6 icmp; icmp.sequence(0x827f); EXPECT_EQ(icmp.sequence(), 0x827f); } TEST_F(ICMPv6Test, Override) { ICMPv6 icmp; icmp.override(1); EXPECT_EQ(icmp.override(), 1); icmp.override(0); EXPECT_EQ(icmp.override(), 0); } TEST_F(ICMPv6Test, Solicited) { ICMPv6 icmp; icmp.solicited(1); EXPECT_EQ(icmp.solicited(), 1); icmp.solicited(0); EXPECT_EQ(icmp.solicited(), 0); } TEST_F(ICMPv6Test, Router) { ICMPv6 icmp; icmp.router(1); EXPECT_EQ(icmp.router(), 1); icmp.router(0); EXPECT_EQ(icmp.router(), 0); } TEST_F(ICMPv6Test, RouterPref) { ICMPv6 icmp; icmp.router_pref(1); EXPECT_EQ(icmp.router_pref(), 1); icmp.router_pref(0); EXPECT_EQ(icmp.router_pref(), 0); } TEST_F(ICMPv6Test, HomeAgent) { ICMPv6 icmp; icmp.home_agent(1); EXPECT_EQ(icmp.home_agent(), 1); icmp.home_agent(0); EXPECT_EQ(icmp.home_agent(), 0); } TEST_F(ICMPv6Test, Other) { ICMPv6 icmp; icmp.other(1); EXPECT_EQ(icmp.other(), 1); icmp.other(0); EXPECT_EQ(icmp.other(), 0); } TEST_F(ICMPv6Test, Managed) { ICMPv6 icmp; icmp.managed(1); EXPECT_EQ(icmp.managed(), 1); icmp.managed(0); EXPECT_EQ(icmp.managed(), 0); } TEST_F(ICMPv6Test, RTLifetime) { ICMPv6 icmp; icmp.router_lifetime(0x827f); EXPECT_EQ(icmp.router_lifetime(), 0x827f); } TEST_F(ICMPv6Test, SourceLinkLayerAddress) { ICMPv6 icmp; icmp.source_link_layer_addr("09:fe:da:fe:22:33"); EXPECT_EQ(icmp.source_link_layer_addr(), "09:fe:da:fe:22:33"); } TEST_F(ICMPv6Test, TargetLinkLayerAddress) { ICMPv6 icmp; icmp.target_link_layer_addr("09:fe:da:fe:22:33"); EXPECT_EQ(icmp.target_link_layer_addr(), "09:fe:da:fe:22:33"); } TEST_F(ICMPv6Test, PrefixInformation) { ICMPv6 icmp; ICMPv6::prefix_info_type result, info(0x8, 1, 0, 0x92038fad, 0x918273fa, "827d:adae::1"); icmp.prefix_info(info); result = icmp.prefix_info(); EXPECT_EQ(result.prefix_len, info.prefix_len); EXPECT_EQ(result.A, info.A); EXPECT_EQ(result.L, info.L); EXPECT_EQ(result.valid_lifetime, info.valid_lifetime); EXPECT_EQ(result.preferred_lifetime, info.preferred_lifetime); EXPECT_EQ(IPv6Address(result.prefix), IPv6Address(result.prefix)); EXPECT_EQ(IPv6Address(result.prefix), "827d:adae::1"); } TEST_F(ICMPv6Test, RedirectHeader) { ICMPv6 icmp; IP ip = IP("127.0.0.1") / TCP(22); PDU::serialization_type buffer = ip.serialize(); icmp.redirect_header(buffer); EXPECT_EQ(buffer, icmp.redirect_header()); } TEST_F(ICMPv6Test, MTU) { ICMPv6 icmp; icmp.mtu(0x9a8df7); EXPECT_EQ(icmp.mtu(), 0x9a8df7); } TEST_F(ICMPv6Test, ShortcutLimit) { ICMPv6 icmp; icmp.shortcut_limit(123); EXPECT_EQ(icmp.shortcut_limit(), 123); } TEST_F(ICMPv6Test, NewAdvertisementInterval) { ICMPv6 icmp; icmp.new_advert_interval(0x9a8df7); EXPECT_EQ(icmp.new_advert_interval(), 0x9a8df7); } TEST_F(ICMPv6Test, NewHomeAgentInformation) { ICMPv6 icmp; ICMPv6::new_ha_info_type data(0x92fa, 0xaab3); icmp.new_home_agent_info(data); EXPECT_EQ(icmp.new_home_agent_info(), data); } TEST_F(ICMPv6Test, SourceAddressList) { ICMPv6 icmp; ICMPv6::addr_list_type data; data.push_back("827d:adae::1"); data.push_back("2929:1234:fefe::2"); icmp.source_addr_list(data); EXPECT_EQ(icmp.source_addr_list(), data); } TEST_F(ICMPv6Test, TargetAddressList) { ICMPv6 icmp; ICMPv6::addr_list_type data; data.push_back("827d:adae::1"); data.push_back("2929:1234:fefe::2"); icmp.target_addr_list(data); EXPECT_EQ(icmp.target_addr_list(), data); } TEST_F(ICMPv6Test, RSASignature) { ICMPv6 icmp; ICMPv6::rsa_sign_type data, result; // can i haz std::iota? const uint8_t arr[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; std::copy(arr, arr + sizeof(arr), data.key_hash); data.signature.push_back(12); data.signature.push_back(15); data.signature.push_back(221); icmp.rsa_signature(data); result = icmp.rsa_signature(); EXPECT_TRUE(std::equal(data.key_hash, data.key_hash + sizeof(data.key_hash), result.key_hash)); // There might be some padding(in this case, there is). ASSERT_LE(data.signature.size(), result.signature.size()); EXPECT_TRUE(std::equal(data.signature.begin(), data.signature.end(), result.signature.begin())); } TEST_F(ICMPv6Test, Timestamp) { ICMPv6 icmp; icmp.timestamp(0x2837d6aaa231L); EXPECT_EQ(icmp.timestamp(), 0x2837d6aaa231L); } TEST_F(ICMPv6Test, Nonce) { ICMPv6 icmp; ICMPv6::nonce_type data; data.push_back(22); data.push_back(211); data.push_back(67); icmp.nonce(data); EXPECT_EQ(icmp.nonce(), data); } TEST_F(ICMPv6Test, IPPrefix) { ICMPv6 icmp; ICMPv6::ip_prefix_type data(67, 198, "ff00:0928:ddfa::"), output; icmp.ip_prefix(data); output = icmp.ip_prefix(); EXPECT_EQ(output.option_code, data.option_code); EXPECT_EQ(output.prefix_len, data.prefix_len); EXPECT_EQ(output.address, data.address); } TEST_F(ICMPv6Test, LinkLayerAddress) { ICMPv6 icmp; ICMPv6::lladdr_type data(67), output; data.address.push_back(87); data.address.push_back(22); data.address.push_back(185); icmp.link_layer_addr(data); output = icmp.link_layer_addr(); EXPECT_EQ(output.option_code, data.option_code); ASSERT_LE(data.address.size(), output.address.size()); EXPECT_TRUE(std::equal(data.address.begin(), data.address.end(), output.address.begin())); } TEST_F(ICMPv6Test, NAACK) { ICMPv6 icmp; ICMPv6::naack_type data(0x92, 0xb3); icmp.naack(data); EXPECT_EQ(icmp.naack(), data); } TEST_F(ICMPv6Test, MAP) { ICMPv6 icmp; ICMPv6::map_type data(0x9, 0xb, 1, 0x9283719, "f029:adde::1"), output; icmp.map(data); output = icmp.map(); EXPECT_EQ(output.dist, data.dist); EXPECT_EQ(output.pref, data.pref); EXPECT_EQ(output.r, data.r); EXPECT_EQ(output.address, data.address); } TEST_F(ICMPv6Test, RouteInfo) { ICMPv6 icmp; ICMPv6::route_info_type data(0x92, 2, 0xf23a8823), output; data.prefix.push_back(98); data.prefix.push_back(52); data.prefix.push_back(44); icmp.route_info(data); output = icmp.route_info(); EXPECT_EQ(output.prefix_len, data.prefix_len); EXPECT_EQ(output.pref, data.pref); EXPECT_EQ(output.route_lifetime, data.route_lifetime); ASSERT_LE(data.prefix.size(), output.prefix.size()); EXPECT_TRUE(std::equal(data.prefix.begin(), data.prefix.end(), output.prefix.begin())); } TEST_F(ICMPv6Test, RecursiveDNSServer) { ICMPv6 icmp; ICMPv6::recursive_dns_type data(0x9283712), output; data.servers.push_back("827d:adae::1"); data.servers.push_back("2929:1234:fefe::2"); icmp.recursive_dns_servers(data); output = icmp.recursive_dns_servers(); EXPECT_EQ(output.lifetime, data.lifetime); EXPECT_EQ(output.servers, data.servers); } TEST_F(ICMPv6Test, HandoverKeyRequest) { ICMPv6 icmp; ICMPv6::handover_key_req_type data(2), output; data.key.push_back(98); data.key.push_back(52); data.key.push_back(44); icmp.handover_key_request(data); output = icmp.handover_key_request(); EXPECT_EQ(output.AT, data.AT); EXPECT_EQ(data.key, output.key); } TEST_F(ICMPv6Test, HandoverKeyReply) { ICMPv6 icmp; ICMPv6::handover_key_reply_type data(0x9283, 2), output; data.key.push_back(98); data.key.push_back(52); data.key.push_back(44); icmp.handover_key_reply(data); output = icmp.handover_key_reply(); EXPECT_EQ(output.AT, data.AT); EXPECT_EQ(output.lifetime, data.lifetime); EXPECT_EQ(data.key, output.key); } TEST_F(ICMPv6Test, HandoverAssistInfo) { ICMPv6 icmp; ICMPv6::handover_assist_info_type data(0x92), output; data.hai.push_back(98); data.hai.push_back(52); data.hai.push_back(44); icmp.handover_assist_info(data); output = icmp.handover_assist_info(); EXPECT_EQ(output.option_code, data.option_code); EXPECT_EQ(data.hai, output.hai); } TEST_F(ICMPv6Test, MobileNodeIdentifier) { ICMPv6 icmp; ICMPv6::mobile_node_id_type data(0x92), output; data.mn.push_back(98); data.mn.push_back(52); data.mn.push_back(44); icmp.mobile_node_identifier(data); output = icmp.mobile_node_identifier(); EXPECT_EQ(output.option_code, data.option_code); EXPECT_EQ(data.mn, output.mn); } TEST_F(ICMPv6Test, DNSSearchList) { ICMPv6 icmp; ICMPv6::dns_search_list_type data(0x9283fd1), output; data.domains.push_back("libtins.sourceforge.net"); data.domains.push_back("www.example.com"); icmp.dns_search_list(data); output = icmp.dns_search_list(); EXPECT_EQ(output.lifetime, data.lifetime); EXPECT_EQ(data.domains, output.domains); } TEST_F(ICMPv6Test, SpoofedOptions) { ICMPv6 pdu; uint8_t a[] = { 1,2,3,4,5,6 }; pdu.add_option( ICMPv6::option(ICMPv6::NAACK, 250, a, a + sizeof(a)) ); pdu.add_option( ICMPv6::option(ICMPv6::NAACK, 250, a, a + sizeof(a)) ); pdu.add_option( ICMPv6::option(ICMPv6::NAACK, 250, a, a + sizeof(a)) ); // probably we'd expect it to crash if it's not working, valgrind plx EXPECT_EQ(3, pdu.options().size()); EXPECT_EQ(pdu.serialize().size(), pdu.size()); } libtins-1.1/tests/src/icmp.cpp0000664000175000017500000001331612154360113015724 0ustar matiasmatias#include #include #include #include #include "icmp.h" #include "utils.h" using namespace std; using namespace Tins; class ICMPTest : public testing::Test { public: static const uint8_t expected_packets[][8]; static const uint32_t expected_packet_count; void test_equals(const ICMP &icmp1, const ICMP &icmp2); }; const uint8_t ICMPTest::expected_packets[][8] = { { 8, 1, 173, 123, 86, 209, 243, 177 }, { 12, 0, 116, 255, 127, 0, 0, 0 } }; const uint32_t ICMPTest::expected_packet_count = 1; TEST_F(ICMPTest, DefaultConstructor) { ICMP icmp; EXPECT_EQ(icmp.code(), 0); EXPECT_EQ(icmp.type(), ICMP::ECHO_REQUEST); EXPECT_EQ(icmp.id(), 0); EXPECT_EQ(icmp.check(), 0); } TEST_F(ICMPTest, CopyConstructor) { ICMP icmp1(expected_packets[0], sizeof(expected_packets[0])); ICMP icmp2(icmp1); test_equals(icmp1, icmp2); } TEST_F(ICMPTest, CopyAssignmentOperator) { ICMP icmp1(expected_packets[0], sizeof(expected_packets[0])); ICMP icmp2; icmp2 = icmp1; test_equals(icmp1, icmp2); } TEST_F(ICMPTest, NestedCopy) { ICMP *nested = new ICMP(expected_packets[0], sizeof(expected_packets[0])); ICMP icmp1(expected_packets[0], sizeof(expected_packets[0])); icmp1.inner_pdu(nested); ICMP icmp2(icmp1); test_equals(icmp1, icmp2); } TEST_F(ICMPTest, FlagConstructor) { ICMP icmp(ICMP::ECHO_REPLY); EXPECT_EQ(icmp.type(), ICMP::ECHO_REPLY); } TEST_F(ICMPTest, Code) { ICMP icmp; icmp.code(0x7a); EXPECT_EQ(icmp.code(), 0x7a); } TEST_F(ICMPTest, Id) { ICMP icmp; icmp.id(0x7af1); EXPECT_EQ(icmp.id(), 0x7af1); } TEST_F(ICMPTest, Sequence) { ICMP icmp; icmp.sequence(0x7af1); EXPECT_EQ(icmp.sequence(), 0x7af1); } TEST_F(ICMPTest, Type) { ICMP icmp; icmp.type(ICMP::ECHO_REPLY); EXPECT_EQ(icmp.type(), ICMP::ECHO_REPLY); } TEST_F(ICMPTest, Checksum) { ICMP icmp; icmp.check(0x31fd); EXPECT_EQ(icmp.check(), 0x31fd); } TEST_F(ICMPTest, Gateway) { ICMP icmp; icmp.gateway(0x31fdb5cd); EXPECT_EQ(icmp.gateway(), 0x31fdb5cd); } TEST_F(ICMPTest, MTU) { ICMP icmp; icmp.mtu(0x7af1); EXPECT_EQ(icmp.mtu(), 0x7af1); } TEST_F(ICMPTest, Pointer) { ICMP icmp; icmp.pointer(0xf1); EXPECT_EQ(icmp.pointer(), 0xf1); } TEST_F(ICMPTest, SetEchoRequest) { ICMP icmp; icmp.set_echo_request(0x7af1, 0x123f); EXPECT_EQ(icmp.type(), ICMP::ECHO_REQUEST); EXPECT_EQ(icmp.id(), 0x7af1); EXPECT_EQ(icmp.sequence(), 0x123f); } TEST_F(ICMPTest, SetEchoReply) { ICMP icmp; icmp.set_echo_reply(0x7af1, 0x123f); EXPECT_EQ(icmp.type(), ICMP::ECHO_REPLY); EXPECT_EQ(icmp.id(), 0x7af1); EXPECT_EQ(icmp.sequence(), 0x123f); } TEST_F(ICMPTest, SetInfoRequest) { ICMP icmp; icmp.set_info_request(0x7af1, 0x123f); EXPECT_EQ(icmp.type(), ICMP::INFO_REQUEST); EXPECT_EQ(icmp.id(), 0x7af1); EXPECT_EQ(icmp.sequence(), 0x123f); } TEST_F(ICMPTest, SetInfoReply) { ICMP icmp; icmp.set_info_reply(0x7af1, 0x123f); EXPECT_EQ(icmp.type(), ICMP::INFO_REPLY); EXPECT_EQ(icmp.id(), 0x7af1); EXPECT_EQ(icmp.sequence(), 0x123f); } TEST_F(ICMPTest, SetDestinationUnreachable) { ICMP icmp; icmp.set_dest_unreachable(); EXPECT_EQ(icmp.type(), ICMP::DEST_UNREACHABLE); } TEST_F(ICMPTest, SetTimeExceeded) { ICMP icmp; icmp.set_time_exceeded(true); EXPECT_EQ(icmp.type(), ICMP::TIME_EXCEEDED); EXPECT_EQ(icmp.code(), 0); icmp.set_time_exceeded(false); EXPECT_EQ(icmp.type(), ICMP::TIME_EXCEEDED); EXPECT_EQ(icmp.code(), 1); } TEST_F(ICMPTest, SetParamProblem) { ICMP icmp; icmp.set_param_problem(true, 0x4f); EXPECT_EQ(icmp.type(), ICMP::PARAM_PROBLEM); EXPECT_EQ(icmp.code(), 0); EXPECT_EQ(icmp.pointer(), 0x4f); icmp.set_param_problem(false); EXPECT_EQ(icmp.type(), ICMP::PARAM_PROBLEM); EXPECT_EQ(icmp.code(), 1); } TEST_F(ICMPTest, SetSourceQuench) { ICMP icmp; icmp.set_source_quench(); EXPECT_EQ(icmp.type(), ICMP::SOURCE_QUENCH); } TEST_F(ICMPTest, SetRedirect) { ICMP icmp; icmp.set_redirect(0x3d, 0xf1dc); EXPECT_EQ(icmp.type(), ICMP::REDIRECT); EXPECT_EQ(icmp.code(), 0x3d); EXPECT_EQ(icmp.gateway(), 0xf1dc); } void ICMPTest::test_equals(const ICMP &icmp1, const ICMP &icmp2) { EXPECT_EQ(icmp1.type(), icmp2.type()); EXPECT_EQ(icmp1.code(), icmp2.code()); EXPECT_EQ(icmp1.gateway(), icmp2.gateway()); EXPECT_EQ(icmp1.id(), icmp2.id()); EXPECT_EQ(icmp1.sequence(), icmp2.sequence()); EXPECT_EQ(icmp1.pointer(), icmp2.pointer()); EXPECT_EQ(icmp1.mtu(), icmp2.mtu()); EXPECT_EQ((bool)icmp1.inner_pdu(), (bool)icmp2.inner_pdu()); } TEST_F(ICMPTest, Serialize) { ICMP icmp1; icmp1.set_echo_request(0x34ab, 0x12f7); PDU::serialization_type buffer = icmp1.serialize(); ICMP icmp2(icmp1); PDU::serialization_type buffer2 = icmp2.serialize(); EXPECT_EQ(buffer, buffer2); } TEST_F(ICMPTest, ConstructorFromBuffer) { for(unsigned i(0); i < expected_packet_count; ++i) { ICMP icmp1(expected_packets[i], sizeof(expected_packets[i])); PDU::serialization_type buffer = icmp1.serialize(); switch(i) { case 0: EXPECT_EQ(icmp1.type(), ICMP::ECHO_REQUEST); EXPECT_EQ(icmp1.code(), 1); EXPECT_EQ(icmp1.id(), 0x56d1); EXPECT_EQ(icmp1.sequence(), 0xf3b1); break; case 1: EXPECT_EQ(icmp1.type(), ICMP::PARAM_PROBLEM); EXPECT_EQ(icmp1.code(), 0); EXPECT_EQ(icmp1.pointer(), 0x7f); break; } ICMP icmp2(&buffer[0], buffer.size()); test_equals(icmp1, icmp2); } } libtins-1.1/tests/src/hwaddress.cpp0000664000175000017500000000462112154360113016757 0ustar matiasmatias#include #include #include #include #include #include #include "hw_address.h" using namespace Tins; class HWAddressTest : public testing::Test { public: static const std::string address; static const uint8_t *byte_address, *empty_addr; }; const std::string HWAddressTest::address = "00:de:ad:be:ef:00"; const uint8_t *HWAddressTest::byte_address = (const uint8_t*)"\x00\xde\xad\xbe\xef\x00", *HWAddressTest::empty_addr = (const uint8_t*)"\x00\x00\x00\x00\x00\x00"; TEST_F(HWAddressTest, DefaultConstructor) { HWAddress<6> addr; EXPECT_TRUE(std::equal(addr.begin(), addr.end(), empty_addr)); } TEST_F(HWAddressTest, EqualsOperator) { HWAddress<6> addr1(byte_address), addr2(byte_address); EXPECT_EQ(addr1, addr2); } TEST_F(HWAddressTest, DistinctOperator) { HWAddress<6> addr1(byte_address), addr2(empty_addr); EXPECT_NE(addr1, addr2); } TEST_F(HWAddressTest, SubscriptOperator) { HWAddress<6> addr("00:01:02:03:04:05"); for(size_t i = 0; i < addr.size(); ++i) EXPECT_EQ(addr[i], i); } TEST_F(HWAddressTest, LessThanOperator) { HWAddress<6> addr1(byte_address), addr2(empty_addr); HWAddress<6> bcast = "ff:ff:ff:ff:ff:ff"; EXPECT_LT(addr2, addr1); EXPECT_LT(addr2, bcast); std::map, int> dict; dict[addr1] = 12; dict[addr2] = 15; EXPECT_EQ(dict[addr1], 12); EXPECT_EQ(dict[addr2], 15); } TEST_F(HWAddressTest, CopyConstructor) { HWAddress<6> addr1(byte_address), addr2(addr1); EXPECT_EQ(addr1, addr2); } TEST_F(HWAddressTest, IsBroadcast) { EXPECT_FALSE(HWAddress<6>("ff:ff:ff:ff:ff:fe").is_broadcast()); EXPECT_FALSE(HWAddress<6>("00:01:02:03:04:05").is_broadcast()); EXPECT_TRUE(HWAddress<6>("ff:ff:ff:ff:ff:ff").is_broadcast()); } TEST_F(HWAddressTest, CopyAssignmentOperator) { HWAddress<6> addr1(byte_address), addr2; addr2 = addr1; EXPECT_EQ(addr1, addr2); } TEST_F(HWAddressTest, ConstructorFromBytes) { HWAddress<6> addr(byte_address); EXPECT_TRUE(std::equal(addr.begin(), addr.end(), byte_address)); } TEST_F(HWAddressTest, ConstructorFromAddress) { HWAddress<6> addr(address); EXPECT_TRUE(std::equal(addr.begin(), addr.end(), byte_address)); } TEST_F(HWAddressTest, OutputOperator) { HWAddress<6> addr(address); std::ostringstream oss; oss << addr; EXPECT_EQ(oss.str(), address); } libtins-1.1/tests/src/ethernetII.cpp0000664000175000017500000000776012154360113017042 0ustar matiasmatias#include #include #include "ethernetII.h" #include "utils.h" #include "macros.h" #include "ipv6.h" #include "ip.h" using namespace Tins; typedef EthernetII::address_type address_type; class EthernetIITest : public ::testing::Test { public: static const uint8_t expected_packet[], ip_packet[], ipv6_packet[]; static address_type src_addr; static address_type dst_addr; static address_type empty_addr; static const uint16_t p_type; void test_equals(const EthernetII ð1, const EthernetII ð2); }; const uint8_t EthernetIITest::expected_packet[] = { 170, 187, 204, 221, 238, 255, 138, 139, 140, 141, 142, 143, 208, 171 }, EthernetIITest::ip_packet[] = { 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 8, 0, 69, 0, 0, 20, 0, 1, 0, 0, 64, 0, 124, 231, 127, 0, 0, 1, 127, 0, 0, 1 }, EthernetIITest::ipv6_packet[] = { 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 134, 221, 96, 0, 0, 0, 0, 0, 59, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; address_type EthernetIITest::src_addr("8a:8b:8c:8d:8e:8f"); address_type EthernetIITest::dst_addr("aa:bb:cc:dd:ee:ff"); address_type EthernetIITest::empty_addr; const uint16_t EthernetIITest::p_type = 0xd0ab; void EthernetIITest::test_equals(const EthernetII ð1, const EthernetII ð2) { EXPECT_EQ(eth1.dst_addr(), eth2.dst_addr()); EXPECT_EQ(eth1.src_addr(), eth2.src_addr()); EXPECT_EQ(eth1.payload_type(), eth2.payload_type()); EXPECT_EQ((bool)eth1.inner_pdu(), (bool)eth2.inner_pdu()); } TEST_F(EthernetIITest, DefaultConstructor) { EthernetII eth; EXPECT_EQ(eth.dst_addr(), empty_addr); EXPECT_EQ(eth.src_addr(), empty_addr); EXPECT_EQ(eth.payload_type(), 0); EXPECT_FALSE(eth.inner_pdu()); EXPECT_EQ(eth.pdu_type(), PDU::ETHERNET_II); } TEST_F(EthernetIITest, CopyConstructor) { EthernetII eth1(expected_packet, sizeof(expected_packet)); EthernetII eth2(eth1); test_equals(eth1, eth2); } TEST_F(EthernetIITest, CopyAssignmentOperator) { EthernetII eth1(expected_packet, sizeof(expected_packet)); EthernetII eth2; eth2 = eth1; test_equals(eth1, eth2); } TEST_F(EthernetIITest, NestedCopy) { EthernetII *nested = new EthernetII(expected_packet, sizeof(expected_packet)); EthernetII eth1(expected_packet, sizeof(expected_packet)); eth1.inner_pdu(nested); EthernetII eth2(eth1); test_equals(eth1, eth2); } TEST_F(EthernetIITest, SourceAddress) { EthernetII eth; eth.src_addr(src_addr); ASSERT_EQ(eth.src_addr(), src_addr); } TEST_F(EthernetIITest, DestinationAddress) { EthernetII eth; eth.dst_addr(dst_addr); ASSERT_EQ(eth.dst_addr(), dst_addr); } TEST_F(EthernetIITest, PayloadType) { EthernetII eth; eth.payload_type(p_type); ASSERT_EQ(eth.payload_type(), p_type); } TEST_F(EthernetIITest, CompleteConstructor) { EthernetII eth2; EthernetII eth = EthernetII(dst_addr, src_addr) / eth2; EXPECT_EQ(eth.dst_addr(), dst_addr); EXPECT_EQ(eth.src_addr(), src_addr); EXPECT_EQ(eth.payload_type(), 0); } TEST_F(EthernetIITest, Serialize) { EthernetII eth(dst_addr, src_addr); eth.payload_type(p_type); PDU::serialization_type serialized = eth.serialize(); ASSERT_EQ(serialized.size(), sizeof(expected_packet)); EXPECT_TRUE(std::equal(serialized.begin(), serialized.end(), expected_packet)); } TEST_F(EthernetIITest, ConstructorFromBuffer) { EthernetII eth(expected_packet, sizeof(expected_packet)); EXPECT_EQ(eth.src_addr(), src_addr); EXPECT_EQ(eth.dst_addr(), dst_addr); EXPECT_EQ(eth.payload_type(), p_type); } TEST_F(EthernetIITest, ConstructorFromIPBuffer) { EthernetII eth(ip_packet, sizeof(ip_packet)); ASSERT_TRUE(eth.inner_pdu()); EXPECT_EQ(eth.find_pdu(), eth.inner_pdu()); } TEST_F(EthernetIITest, ConstructorFromIPv6Buffer) { EthernetII eth(ipv6_packet, sizeof(ipv6_packet)); ASSERT_TRUE(eth.inner_pdu()); EXPECT_EQ(eth.find_pdu(), eth.inner_pdu()); } libtins-1.1/tests/src/dot1q.cpp0000664000175000017500000000402512154360113016021 0ustar matiasmatias#include #include #include #include #include "dot1q.h" #include "arp.h" #include "ethernetII.h" using namespace std; using namespace Tins; class Dot1QTest : public testing::Test { public: static const uint8_t expected_packet[]; void test_equals(const Dot1Q &pdu1, const Dot1Q &pdu2); }; const uint8_t Dot1QTest::expected_packet[] = { 255, 255, 255, 255, 255, 255, 0, 25, 6, 234, 184, 193, 129, 0, 176, 123, 8, 6, 0, 1, 8, 0, 6, 4, 0, 2, 0, 25, 6, 234, 184, 193, 192, 168, 123, 1, 255, 255, 255, 255, 255, 255, 192, 168, 123, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; TEST_F(Dot1QTest, DefaultConstructor) { Dot1Q dot1; EXPECT_EQ(0, dot1.payload_type()); EXPECT_EQ(0, dot1.priority()); EXPECT_EQ(0, dot1.cfi()); EXPECT_EQ(0, dot1.id()); } TEST_F(Dot1QTest, ConstructorFromBuffer) { EthernetII eth(expected_packet, sizeof(expected_packet)); const Dot1Q *dot1 = eth.find_pdu(); ASSERT_TRUE(dot1); EXPECT_EQ(0x806, dot1->payload_type()); EXPECT_EQ(5, dot1->priority()); EXPECT_EQ(1, dot1->cfi()); EXPECT_EQ(123, dot1->id()); const ARP *arp = dot1->find_pdu(); ASSERT_TRUE(arp); // just to check it the offset's OK EXPECT_EQ(ARP::hwaddress_type("00:19:06:ea:b8:c1"), arp->sender_hw_addr()); } TEST_F(Dot1QTest, Serialize) { EthernetII eth(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = eth.serialize(); EXPECT_EQ( PDU::serialization_type(expected_packet, expected_packet + sizeof(expected_packet)), buffer ); } TEST_F(Dot1QTest, PayloadType) { Dot1Q dot1; dot1.payload_type(0x9283); EXPECT_EQ(0x9283, dot1.payload_type()); } TEST_F(Dot1QTest, Priority) { Dot1Q dot1; dot1.priority(5); EXPECT_EQ(5, dot1.priority()); } TEST_F(Dot1QTest, CFI) { Dot1Q dot1; dot1.cfi(1); EXPECT_EQ(1, dot1.cfi()); } TEST_F(Dot1QTest, Id) { Dot1Q dot1; dot1.id(3543); EXPECT_EQ(3543, dot1.id()); } libtins-1.1/tests/src/dot11/0000775000175000017500000000000012154360113015214 5ustar matiasmatiaslibtins-1.1/tests/src/dot11/rts.cpp0000664000175000017500000000416512154360113016536 0ustar matiasmatias#include #include "tests/dot11_control.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11RTSTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11RTSTest::expected_packet[] = { 181, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6 }; void test_equals(const Dot11RTS &dot1, const Dot11RTS &dot2) { test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11RTS &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::RTS); } TEST_F(Dot11RTSTest, Constructor) { Dot11RTS dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::RTS); } TEST_F(Dot11RTSTest, ConstructorFromBuffer) { Dot11RTS dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11RTSTest, CopyConstructor) { Dot11RTS dot1(expected_packet, sizeof(expected_packet)); Dot11RTS dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11RTSTest, CopyAssignmentOperator) { Dot11RTS dot1(expected_packet, sizeof(expected_packet)); Dot11RTS dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11RTSTest, ClonePDU) { Dot11RTS dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11RTSTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11RTS *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11RTSTest, Serialize) { Dot11RTS pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/reassoc_response.cpp0000664000175000017500000000546612154360113021310 0ustar matiasmatias#include #include "dot11/dot11_assoc.h" #include "tests/dot11_mgmt.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11ReAssocResponseTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11ReAssocResponseTest::expected_packet[] = { 49, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 0, 0, 21, 32, 243, 146, 58, 242 }; void test_equals(const Dot11ReAssocResponse &dot1, const Dot11ReAssocResponse &dot2) { test_equals(dot1.capabilities(), dot2.capabilities()); EXPECT_EQ(dot1.status_code(), dot2.status_code()); EXPECT_EQ(dot1.aid(), dot2.aid()); test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11ReAssocResponse &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.status_code(), 0x92f3); EXPECT_EQ(dot11.aid(), 0xf23a); EXPECT_EQ(dot11.subtype(), Dot11::REASSOC_RESP); } TEST_F(Dot11ReAssocResponseTest, Constructor) { Dot11ReAssocResponse dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.status_code(), 0); EXPECT_EQ(dot11.aid(), 0); EXPECT_EQ(dot11.subtype(), Dot11::REASSOC_RESP); } TEST_F(Dot11ReAssocResponseTest, ConstructorFromBuffer) { Dot11ReAssocResponse dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11ReAssocResponseTest, CopyConstructor) { Dot11ReAssocResponse dot1(expected_packet, sizeof(expected_packet)); Dot11ReAssocResponse dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11ReAssocResponseTest, CopyAssignmentOperator) { Dot11ReAssocResponse dot1(expected_packet, sizeof(expected_packet)); Dot11ReAssocResponse dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11ReAssocResponseTest, ClonePDU) { Dot11ReAssocResponse dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11ReAssocResponseTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11ReAssocResponse *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11ReAssocResponseTest, Serialize) { Dot11ReAssocResponse pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/reassoc_request.cpp0000664000175000017500000000621412154360113021132 0ustar matiasmatias#include #include "dot11/dot11_assoc.h" #include "tests/dot11_mgmt.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11ReAssocRequestTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11ReAssocRequestTest::expected_packet[] = { 33, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 0, 0, 21, 32, 243, 146, 3, 4, 5, 6, 7, 8 }; void test_equals(const Dot11ReAssocRequest &dot1, const Dot11ReAssocRequest &dot2) { test_equals(dot1.capabilities(), dot2.capabilities()); EXPECT_EQ(dot1.listen_interval(), dot2.listen_interval()); EXPECT_EQ(dot1.current_ap(), dot2.current_ap()); test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11ReAssocRequest &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.listen_interval(), 0x92f3); EXPECT_EQ(dot11.subtype(), Dot11::REASSOC_REQ); } TEST_F(Dot11ReAssocRequestTest, Constructor) { Dot11ReAssocRequest dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.listen_interval(), 0); EXPECT_EQ(dot11.current_ap(), address_type()); EXPECT_EQ(dot11.subtype(), Dot11::REASSOC_REQ); } TEST_F(Dot11ReAssocRequestTest, ConstructorFromBuffer) { Dot11ReAssocRequest dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11ReAssocRequestTest, CopyConstructor) { Dot11ReAssocRequest dot1(expected_packet, sizeof(expected_packet)); Dot11ReAssocRequest dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11ReAssocRequestTest, CopyAssignmentOperator) { Dot11ReAssocRequest dot1(expected_packet, sizeof(expected_packet)); Dot11ReAssocRequest dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11ReAssocRequestTest, ListenInterval) { Dot11ReAssocRequest dot11; dot11.listen_interval(0x92fd); EXPECT_EQ(dot11.listen_interval(), 0x92fd); } TEST_F(Dot11ReAssocRequestTest, CurrentAP) { Dot11ReAssocRequest dot11; dot11.current_ap("00:01:02:03:04:05"); EXPECT_EQ(dot11.current_ap(), "00:01:02:03:04:05"); } TEST_F(Dot11ReAssocRequestTest, ClonePDU) { Dot11ReAssocRequest dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11ReAssocRequestTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11ReAssocRequest *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11ReAssocRequestTest, Serialize) { Dot11ReAssocRequest pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/pspoll.cpp0000664000175000017500000000427012154360113017234 0ustar matiasmatias#include #include "tests/dot11_control.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11PSPollTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11PSPollTest::expected_packet[] = { 165, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6 }; void test_equals(const Dot11PSPoll &dot1, const Dot11PSPoll &dot2) { test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11PSPoll &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::PS); } TEST_F(Dot11PSPollTest, Constructor) { Dot11PSPoll dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::PS); } TEST_F(Dot11PSPollTest, ConstructorFromBuffer) { Dot11PSPoll dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11PSPollTest, CopyConstructor) { Dot11PSPoll dot1(expected_packet, sizeof(expected_packet)); Dot11PSPoll dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11PSPollTest, CopyAssignmentOperator) { Dot11PSPoll dot1(expected_packet, sizeof(expected_packet)); Dot11PSPoll dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11PSPollTest, ClonePDU) { Dot11PSPoll dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11PSPollTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11PSPoll *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11PSPollTest, Serialize) { Dot11PSPoll pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/probe_response.cpp0000664000175000017500000000607612154360113020756 0ustar matiasmatias#include #include "dot11/dot11_probe.h" #include "tests/dot11_mgmt.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11ProbeResponseTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11ProbeResponseTest::expected_packet[] = { 81, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 0, 0, 145, 138, 131, 39, 223, 152, 166, 23, 141, 146, 0, 0 }; void test_equals(const Dot11ProbeResponse &dot1, const Dot11ProbeResponse &dot2) { EXPECT_EQ(dot1.interval(), dot2.interval()); EXPECT_EQ(dot1.timestamp(), dot2.timestamp()); test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11ProbeResponse &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.timestamp(), 0x17a698df27838a91LL); EXPECT_EQ(dot11.interval(), 0x928d); EXPECT_EQ(dot11.subtype(), Dot11::PROBE_RESP); } TEST_F(Dot11ProbeResponseTest, Constructor) { Dot11ProbeResponse dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.timestamp(), 0); EXPECT_EQ(dot11.interval(), 0); EXPECT_EQ(dot11.subtype(), Dot11::PROBE_RESP); } TEST_F(Dot11ProbeResponseTest, ConstructorFromBuffer) { Dot11ProbeResponse dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11ProbeResponseTest, CopyConstructor) { Dot11ProbeResponse dot1(expected_packet, sizeof(expected_packet)); Dot11ProbeResponse dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11ProbeResponseTest, CopyAssignmentOperator) { Dot11ProbeResponse dot1(expected_packet, sizeof(expected_packet)); Dot11ProbeResponse dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11ProbeResponseTest, Interval) { Dot11ProbeResponse dot11; dot11.interval(0x92af); EXPECT_EQ(dot11.interval(), 0x92af); } TEST_F(Dot11ProbeResponseTest, Timestamp) { Dot11ProbeResponse dot11; dot11.timestamp(0x92af8a72df928a7cLL); EXPECT_EQ(dot11.timestamp(), 0x92af8a72df928a7cLL); } TEST_F(Dot11ProbeResponseTest, ClonePDU) { Dot11ProbeResponse dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11ProbeResponseTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11ProbeResponse *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11ProbeResponseTest, Serialize) { Dot11ProbeResponse pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/probe_request.cpp0000664000175000017500000000416512154360113020605 0ustar matiasmatias#include #include "dot11/dot11_probe.h" #include "tests/dot11_mgmt.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11ProbeRequestTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11ProbeRequestTest::expected_packet[] = { 65, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 0, 0 }; void test_equals(const Dot11ProbeRequest &dot1, const Dot11ProbeRequest &dot2) { test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11ProbeRequest &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::PROBE_REQ); } TEST_F(Dot11ProbeRequestTest, Constructor) { Dot11ProbeRequest dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::PROBE_REQ); } TEST_F(Dot11ProbeRequestTest, ConstructorFromBuffer) { Dot11ProbeRequest dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11ProbeRequestTest, CopyConstructor) { Dot11ProbeRequest dot1(expected_packet, sizeof(expected_packet)); Dot11ProbeRequest dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11ProbeRequestTest, CopyAssignmentOperator) { Dot11ProbeRequest dot1(expected_packet, sizeof(expected_packet)); Dot11ProbeRequest dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11ProbeRequestTest, ClonePDU) { Dot11ProbeRequest dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11ProbeRequestTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11ProbeRequest *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } libtins-1.1/tests/src/dot11/dot11.cpp0000664000175000017500000000776312154360113016665 0ustar matiasmatias#include #include "tests/dot11.h" #include "utils.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11Test : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const address_type Dot11Test::empty_addr, Dot11Test::hwaddr("72:91:34:fa:de:ad"); const uint8_t Dot11Test::expected_packet[] = { 53, 1, 79, 35, 0, 1, 2, 3, 4, 5 }; TEST_F(Dot11Test, DefaultConstructor) { Dot11 dot11; EXPECT_EQ(dot11.protocol(), 0); EXPECT_EQ(dot11.type(), 0); EXPECT_EQ(dot11.subtype(), 0); EXPECT_EQ(dot11.to_ds(), 0); EXPECT_EQ(dot11.from_ds(), 0); EXPECT_EQ(dot11.more_frag(), 0); EXPECT_EQ(dot11.retry(), 0); EXPECT_EQ(dot11.power_mgmt(), 0); EXPECT_EQ(dot11.wep(), 0); EXPECT_EQ(dot11.order(), 0); EXPECT_EQ(dot11.duration_id(), 0); EXPECT_EQ(dot11.addr1(), empty_addr); } TEST_F(Dot11Test, CopyConstructor) { Dot11 dot1(expected_packet, sizeof(expected_packet)); Dot11 dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11Test, CopyAssignmentOperator) { Dot11 dot1(expected_packet, sizeof(expected_packet)); Dot11 dot2; dot2 = dot1; test_equals(dot1, dot2); } // type="Control", subtype=3, proto=1, FCfield="to-DS", ID=0x234f, addr1="00:01:02:03:04:05" TEST_F(Dot11Test, ConstructorFromBuffer) { Dot11 dot11(expected_packet, sizeof(expected_packet)); EXPECT_EQ(dot11.protocol(), 1); EXPECT_EQ(dot11.type(), Dot11::CONTROL); EXPECT_EQ(dot11.subtype(), 3); EXPECT_EQ(dot11.to_ds(), 1); EXPECT_EQ(dot11.from_ds(), 0); EXPECT_EQ(dot11.more_frag(), 0); EXPECT_EQ(dot11.retry(), 0); EXPECT_EQ(dot11.power_mgmt(), 0); EXPECT_EQ(dot11.wep(), 0); EXPECT_EQ(dot11.order(), 0); EXPECT_EQ(dot11.duration_id(), 0x234f); EXPECT_EQ(dot11.addr1(), "00:01:02:03:04:05"); } TEST_F(Dot11Test, SrcAddrConstructor) { Dot11 dot11(hwaddr); EXPECT_EQ(dot11.addr1(), hwaddr); } TEST_F(Dot11Test, Protocol) { Dot11 dot11; dot11.protocol(1); EXPECT_EQ(dot11.protocol(), 1); } TEST_F(Dot11Test, Type) { Dot11 dot11; dot11.type(Dot11::CONTROL); EXPECT_EQ(dot11.type(), Dot11::CONTROL); } TEST_F(Dot11Test, Subtype) { Dot11 dot11; dot11.subtype(Dot11::QOS_DATA_DATA); EXPECT_EQ(dot11.subtype(), Dot11::QOS_DATA_DATA); } TEST_F(Dot11Test, ToDS) { Dot11 dot11; dot11.to_ds(true); EXPECT_EQ(dot11.to_ds(), true); } TEST_F(Dot11Test, FromDS) { Dot11 dot11; dot11.from_ds(true); EXPECT_EQ(dot11.from_ds(), true); } TEST_F(Dot11Test, MoreFrag) { Dot11 dot11; dot11.more_frag(1); EXPECT_EQ(dot11.more_frag(), 1); } TEST_F(Dot11Test, Retry) { Dot11 dot11; dot11.retry(1); EXPECT_EQ(dot11.retry(), 1); } TEST_F(Dot11Test, PowerMGMT) { Dot11 dot11; dot11.power_mgmt(1); EXPECT_EQ(dot11.power_mgmt(), 1); } TEST_F(Dot11Test, WEP) { Dot11 dot11; dot11.wep(1); EXPECT_EQ(dot11.wep(), 1); } TEST_F(Dot11Test, Order) { Dot11 dot11; dot11.order(1); EXPECT_EQ(dot11.order(), 1); } TEST_F(Dot11Test, DurationID) { Dot11 dot11; dot11.duration_id(0x7163); EXPECT_EQ(dot11.duration_id(), 0x7163); } TEST_F(Dot11Test, Addr1) { Dot11 dot11; dot11.addr1(hwaddr); EXPECT_EQ(dot11.addr1(), hwaddr); } TEST_F(Dot11Test, AddTaggedOption) { Dot11 dot11; dot11.add_option(Dot11::option(Dot11::SSID, hwaddr.begin(), hwaddr.end())); const Dot11::option *option; ASSERT_TRUE((option = dot11.search_option(Dot11::SSID))); EXPECT_EQ(option->data_size(), hwaddr.size()); EXPECT_EQ(option->option(), Dot11::SSID); EXPECT_TRUE(std::equal(hwaddr.begin(), hwaddr.end(), option->data_ptr())); } TEST_F(Dot11Test, Serialize) { Dot11 pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/disassoc.cpp0000664000175000017500000000524512154360113017536 0ustar matiasmatias#include #include "dot11/dot11_assoc.h" #include "tests/dot11_mgmt.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11DisassocTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; //static void test_equals_expected(const Dot11Beacon&dot11); }; const uint8_t Dot11DisassocTest::expected_packet[] = { 161, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 0, 0, 18, 35 }; void test_equals(const Dot11Disassoc &dot1, const Dot11Disassoc &dot2) { EXPECT_EQ(dot1.reason_code(), dot2.reason_code()); test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11Disassoc &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.reason_code(), 0x2312); EXPECT_EQ(dot11.subtype(), Dot11::DISASSOC); } TEST_F(Dot11DisassocTest, Constructor) { Dot11Disassoc dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.reason_code(), 0); EXPECT_EQ(dot11.subtype(), Dot11::DISASSOC); } TEST_F(Dot11DisassocTest, ConstructorFromBuffer) { Dot11Disassoc dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11DisassocTest, CopyConstructor) { Dot11Disassoc dot1(expected_packet, sizeof(expected_packet)); Dot11Disassoc dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11DisassocTest, CopyAssignmentOperator) { Dot11Disassoc dot1(expected_packet, sizeof(expected_packet)); Dot11Disassoc dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11DisassocTest, ReasonCode) { Dot11Disassoc dot11; dot11.reason_code(0x92f3); EXPECT_EQ(dot11.reason_code(), 0x92f3); } TEST_F(Dot11DisassocTest, ClonePDU) { Dot11Disassoc dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11DisassocTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11Disassoc *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11DisassocTest, Serialize) { Dot11Disassoc pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/deauthentication.cpp0000664000175000017500000000545212154360113021256 0ustar matiasmatias#include #include "dot11/dot11_auth.h" #include "tests/dot11_mgmt.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11DeauthenticationTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11DeauthenticationTest::expected_packet[] = { 193, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 0, 0, 243, 146 }; void test_equals(const Dot11Deauthentication &dot1, const Dot11Deauthentication &dot2) { EXPECT_EQ(dot1.reason_code(), dot2.reason_code()); test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11Deauthentication &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.reason_code(), 0x92f3); EXPECT_EQ(dot11.subtype(), Dot11::DEAUTH); } TEST_F(Dot11DeauthenticationTest, Constructor) { Dot11Deauthentication dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.reason_code(), 0); EXPECT_EQ(dot11.subtype(), Dot11::DEAUTH); } TEST_F(Dot11DeauthenticationTest, ConstructorFromBuffer) { Dot11Deauthentication dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11DeauthenticationTest, CopyConstructor) { Dot11Deauthentication dot1(expected_packet, sizeof(expected_packet)); Dot11Deauthentication dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11DeauthenticationTest, CopyAssignmentOperator) { Dot11Deauthentication dot1(expected_packet, sizeof(expected_packet)); Dot11Deauthentication dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11DeauthenticationTest, ReasonCode) { Dot11Deauthentication dot11; dot11.reason_code(0x92f3); EXPECT_EQ(dot11.reason_code(), 0x92f3); } TEST_F(Dot11DeauthenticationTest, ClonePDU) { Dot11Deauthentication dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11DeauthenticationTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11Deauthentication *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11DeauthenticationTest, Serialize) { Dot11Deauthentication pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/data.cpp0000664000175000017500000000632012154360113016632 0ustar matiasmatias#include #include "tests/dot11_data.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11DataTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11DataTest::expected_packet[] = { 9, 0, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 218, 241 }; TEST_F(Dot11DataTest, Constructor) { Dot11Data dot11; test_equals_empty(dot11); } TEST_F(Dot11DataTest, ConstructorFromBuffer) { Dot11Data dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11DataTest, CopyConstructor) { Dot11Data dot1(expected_packet, sizeof(expected_packet)); Dot11Data dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11DataTest, CopyAssignmentOperator) { Dot11Data dot1(expected_packet, sizeof(expected_packet)); Dot11Data dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11DataTest, FragNum) { Dot11Data dot11; dot11.frag_num(0x3); EXPECT_EQ(0x3, dot11.frag_num()); EXPECT_EQ(0, dot11.seq_num()); } TEST_F(Dot11DataTest, SeqNum) { Dot11Data dot11; dot11.seq_num(0x1f2); EXPECT_EQ(0x1f2, dot11.seq_num()); EXPECT_EQ(0, dot11.frag_num()); } TEST_F(Dot11DataTest, ClonePDU) { Dot11Data dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11DataTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11Data *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11DataTest, PCAPLoad1) { const uint8_t buffer[] = { 8, 66, 212, 0, 0, 36, 33, 146, 167, 83, 0, 27, 17, 210, 27, 235, 0, 27, 17, 210, 27, 235, 144, 121, 163, 95, 0, 32, 0, 0, 0, 0, 240, 239, 181, 249, 52, 203, 0, 44, 68, 228, 186, 34, 167, 47, 47, 71, 4, 213, 111, 78, 235, 54, 91, 195, 68, 116, 121, 236, 132, 242, 96, 32, 88, 30, 112, 162, 122, 2, 26, 55, 210, 242, 10, 28, 199, 122, 68, 196, 196, 188, 71, 95, 159, 207, 188, 162, 183, 175, 237, 224, 204, 185, 158, 148, 32, 238, 70, 137, 49, 171, 231, 184, 73, 175, 195, 244, 197, 149, 28, 141, 26, 248, 58, 189, 149, 191, 121, 206, 218, 120, 115, 64, 224, 62, 161, 66, 148, 217, 177, 166, 23, 238, 180, 149, 69 }; Dot11Data dot1(buffer, sizeof(buffer)); EXPECT_EQ(dot1.addr1(), "00:24:21:92:a7:53"); EXPECT_EQ(dot1.addr2(), "00:1b:11:d2:1b:eb"); EXPECT_EQ(dot1.addr3(), "00:1b:11:d2:1b:eb"); EXPECT_EQ(dot1.wep(), 1); EXPECT_EQ(dot1.from_ds(), 1); EXPECT_EQ(dot1.frag_num(), 0); EXPECT_EQ(dot1.seq_num(), 1945); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11DataTest, Serialize) { Dot11Data pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/cfendack.cpp0000664000175000017500000000436712154360113017470 0ustar matiasmatias#include #include "tests/dot11_control.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11EndCFAckTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11EndCFAckTest::expected_packet[] = { 245, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6 }; void test_equals(const Dot11EndCFAck &dot1, const Dot11EndCFAck &dot2) { test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11EndCFAck &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::CF_END_ACK); } TEST_F(Dot11EndCFAckTest, Constructor) { Dot11EndCFAck dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::CF_END_ACK); } TEST_F(Dot11EndCFAckTest, ConstructorFromBuffer) { Dot11EndCFAck dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11EndCFAckTest, CopyConstructor) { Dot11EndCFAck dot1(expected_packet, sizeof(expected_packet)); Dot11EndCFAck dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11EndCFAckTest, CopyAssignmentOperator) { Dot11EndCFAck dot1(expected_packet, sizeof(expected_packet)); Dot11EndCFAck dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11EndCFAckTest, ClonePDU) { Dot11EndCFAck dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11EndCFAckTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11EndCFAck *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11EndCFAckTest, Serialize) { Dot11EndCFAck pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/cfend.cpp0000664000175000017500000000425112154360113017001 0ustar matiasmatias#include #include "tests/dot11_control.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11CFEndTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11CFEndTest::expected_packet[] = { 229, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6 }; void test_equals(const Dot11CFEnd &dot1, const Dot11CFEnd &dot2) { test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11CFEnd &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::CF_END); } TEST_F(Dot11CFEndTest, Constructor) { Dot11CFEnd dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::CF_END); } TEST_F(Dot11CFEndTest, ConstructorFromBuffer) { Dot11CFEnd dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11CFEndTest, CopyConstructor) { Dot11CFEnd dot1(expected_packet, sizeof(expected_packet)); Dot11CFEnd dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11CFEndTest, CopyAssignmentOperator) { Dot11CFEnd dot1(expected_packet, sizeof(expected_packet)); Dot11CFEnd dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11CFEndTest, ClonePDU) { Dot11CFEnd dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11CFEndTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11CFEnd *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11CFEndTest, Serialize) { Dot11CFEnd pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/block_ack_request.cpp0000664000175000017500000000557512154360113021414 0ustar matiasmatias#include #include "dot11/dot11_control.h" #include "tests/dot11.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11BlockAckRequestTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11BlockAckRequestTest::expected_packet[] = { 132, 0, 176, 1, 0, 33, 107, 2, 154, 230, 0, 28, 223, 215, 13, 85, 4, 0, 176, 33 }; void test_equals(const Dot11BlockAckRequest &dot1, const Dot11BlockAckRequest &dot2) { EXPECT_EQ(dot1.fragment_number(), dot2.fragment_number()); EXPECT_EQ(dot1.start_sequence(), dot2.start_sequence()); EXPECT_EQ(dot1.bar_control(), dot2.bar_control()); } void test_equals_expected(const Dot11BlockAckRequest &dot11) { EXPECT_EQ(dot11.type(), Dot11::CONTROL); EXPECT_EQ(dot11.subtype(), Dot11::BLOCK_ACK_REQ); EXPECT_EQ(dot11.bar_control(), 4); EXPECT_EQ(dot11.start_sequence(), 539); EXPECT_EQ(dot11.fragment_number(), 0); } TEST_F(Dot11BlockAckRequestTest, Constructor) { Dot11BlockAckRequest dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.subtype(), Dot11::BLOCK_ACK_REQ); EXPECT_EQ(dot11.fragment_number(), 0); EXPECT_EQ(dot11.start_sequence(), 0); EXPECT_EQ(dot11.bar_control(), 0); } TEST_F(Dot11BlockAckRequestTest, ConstructorFromBuffer) { Dot11BlockAckRequest dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11BlockAckRequestTest, CopyConstructor) { Dot11BlockAckRequest dot1; dot1.fragment_number(6); dot1.start_sequence(0x294); dot1.bar_control(0x9); Dot11BlockAckRequest dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11BlockAckRequestTest, CopyAssignmentOperator) { Dot11BlockAckRequest dot1; dot1.fragment_number(6); dot1.start_sequence(0x294); dot1.bar_control(0x9); Dot11BlockAckRequest dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11BlockAckRequestTest, ClonePDU) { Dot11BlockAckRequest dot1; dot1.fragment_number(6); dot1.start_sequence(0x294); dot1.bar_control(0x9); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11BlockAckRequestTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11BlockAckRequest *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11BlockAckRequestTest, Serialize) { Dot11BlockAckRequest pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/beacon.cpp0000664000175000017500000003501412154360113017152 0ustar matiasmatias#include #include "dot11/dot11_beacon.h" #include "rsn_information.h" #include "tests/dot11_mgmt.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; typedef Dot11Beacon::channels_type channels_type; class Dot11BeaconTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const address_type Dot11BeaconTest::empty_addr, Dot11BeaconTest::hwaddr("72:91:34:fa:de:ad"); const uint8_t Dot11BeaconTest::expected_packet[] = { 129, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 0, 0, 250, 1, 147, 40, 65, 35, 173, 31, 250, 20, 149, 32 }; void test_equals_expected(const Dot11Beacon &dot11) { EXPECT_EQ(dot11.subtype(), 8); EXPECT_EQ(dot11.timestamp(), 0x1fad2341289301faLL); EXPECT_EQ(dot11.interval(), 0x14fa); const Dot11Beacon::capability_information &info = dot11.capabilities(); EXPECT_EQ(info.ess(), 1); EXPECT_EQ(info.ibss(), 0); EXPECT_EQ(info.cf_poll(), 1); EXPECT_EQ(info.cf_poll_req(), 0); EXPECT_EQ(info.privacy(), 1); EXPECT_EQ(info.short_preamble(), 0); EXPECT_EQ(info.pbcc(), 0); EXPECT_EQ(info.channel_agility(), 1); EXPECT_EQ(info.spectrum_mgmt(), 0); EXPECT_EQ(info.qos(), 0); EXPECT_EQ(info.sst(), 0); EXPECT_EQ(info.apsd(), 0); EXPECT_EQ(info.reserved(), 0); EXPECT_EQ(info.dsss_ofdm(), 1); EXPECT_EQ(info.delayed_block_ack(), 0); EXPECT_EQ(info.immediate_block_ack(), 0); ::test_equals_expected(static_cast(dot11)); } void test_equals(const Dot11Beacon& b1, const Dot11Beacon& b2) { EXPECT_EQ(b1.interval(), b2.interval()); EXPECT_EQ(b1.timestamp(), b2.timestamp()); test_equals(b1.capabilities(), b2.capabilities()); test_equals( static_cast(b1), static_cast(b2) ); } TEST_F(Dot11BeaconTest, DefaultConstructor) { Dot11Beacon dot11; test_equals_empty(static_cast(dot11)); test_equals_empty(dot11.capabilities()); EXPECT_EQ(dot11.interval(), 0); EXPECT_EQ(dot11.timestamp(), 0); EXPECT_EQ(dot11.subtype(), Dot11::BEACON); } // beacon_interval=0x14fa, timestamp=0x1fad2341289301fa, cap="ESS+CFP+privacy+DSSS-OFDM" TEST_F(Dot11BeaconTest, ConstructorFromBuffer) { Dot11Beacon dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11BeaconTest, CopyConstructor) { Dot11Beacon dot1(expected_packet, sizeof(expected_packet)); Dot11Beacon dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11BeaconTest, CopyAssignmentOperator) { Dot11Beacon dot1(expected_packet, sizeof(expected_packet)); Dot11Beacon dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11BeaconTest, FragNum) { Dot11Beacon dot11; dot11.frag_num(0x3); EXPECT_EQ(0x3, dot11.frag_num()); EXPECT_EQ(0, dot11.seq_num()); } TEST_F(Dot11BeaconTest, SeqNum) { Dot11Beacon dot11; dot11.seq_num(0x1f2); EXPECT_EQ(0x1f2, dot11.seq_num()); EXPECT_EQ(0, dot11.frag_num()); } TEST_F(Dot11BeaconTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11Beacon *beacon = dot11->find_pdu(); ASSERT_TRUE(beacon); test_equals_expected(*beacon); } TEST_F(Dot11BeaconTest, Timestamp) { Dot11Beacon dot11; dot11.timestamp(0x1fad2341289301faLL); EXPECT_EQ(dot11.timestamp(), 0x1fad2341289301faLL); } TEST_F(Dot11BeaconTest, Interval) { Dot11Beacon dot11; dot11.interval(0x14fa); EXPECT_EQ(dot11.interval(), 0x14fa); } TEST_F(Dot11BeaconTest, SSID) { Dot11Beacon dot11; dot11.ssid("libtins"); EXPECT_EQ(dot11.ssid(), "libtins"); } TEST_F(Dot11BeaconTest, SupportedRates) { Dot11Beacon dot11; Dot11Beacon::rates_type rates, found_rates; rates.push_back(0.5f); rates.push_back(1.0f); rates.push_back(5.5f); rates.push_back(7.5f); dot11.supported_rates(rates); found_rates = dot11.supported_rates(); EXPECT_EQ(rates, found_rates); } TEST_F(Dot11BeaconTest, ExtendedSupportedRates) { Dot11Beacon dot11; Dot11Beacon::rates_type rates, found_rates; rates.push_back(0.5f); rates.push_back(1.0f); rates.push_back(5.5f); rates.push_back(7.5f); dot11.extended_supported_rates(rates); found_rates = dot11.extended_supported_rates(); EXPECT_EQ(rates, found_rates); } TEST_F(Dot11BeaconTest, QOSCapability) { Dot11Beacon dot11; dot11.qos_capability(0xfa); EXPECT_EQ(dot11.qos_capability(), 0xfa); } TEST_F(Dot11BeaconTest, PowerCapability) { typedef std::pair power_pair; Dot11Beacon dot11; dot11.power_capability(0xfa, 0xa2); power_pair power = dot11.power_capability(); EXPECT_EQ(power.first, 0xfa); EXPECT_EQ(power.second, 0xa2); } TEST_F(Dot11BeaconTest, SupportedChannels) { Dot11Beacon dot11; channels_type channels, output; channels.push_back(std::make_pair(13, 19)); channels.push_back(std::make_pair(67, 159)); dot11.supported_channels(channels); output = dot11.supported_channels(); EXPECT_EQ(output, channels); } TEST_F(Dot11BeaconTest, RequestInformation) { Dot11Beacon dot11; Dot11Beacon::request_info_type info, found_info; info.push_back(10); info.push_back(15); info.push_back(51); info.push_back(42); dot11.request_information(info); found_info = dot11.request_information(); EXPECT_EQ(info, found_info); } TEST_F(Dot11BeaconTest, FHParameterSet) { Dot11Beacon dot11; Dot11Beacon::fh_params_set params(0x482f, 67, 42, 0xa1), output; dot11.fh_parameter_set(params); output = dot11.fh_parameter_set(); EXPECT_EQ(output.hop_index, params.hop_index); EXPECT_EQ(output.hop_pattern, params.hop_pattern); EXPECT_EQ(output.hop_set, params.hop_set); EXPECT_EQ(output.dwell_time, params.dwell_time); } TEST_F(Dot11BeaconTest, DSParameterSet) { Dot11Beacon dot11; dot11.ds_parameter_set(0x1e); EXPECT_EQ(dot11.ds_parameter_set(), 0x1e); } TEST_F(Dot11BeaconTest, IBSSParameterSet) { Dot11Beacon dot11; dot11.ibss_parameter_set(0x1ef3); EXPECT_EQ(dot11.ibss_parameter_set(), 0x1ef3); } TEST_F(Dot11BeaconTest, IBSS_DFS) { Dot11Beacon dot11; Dot11Beacon::ibss_dfs_params params, output; params.dfs_owner = "00:01:02:03:04:05"; params.recovery_interval = 0x7f; params.channel_map.push_back(std::make_pair(0x8e, 0x92)); params.channel_map.push_back(std::make_pair(0x02, 0xf2)); params.channel_map.push_back(std::make_pair(0x3a, 0x53)); dot11.ibss_dfs(params); output = dot11.ibss_dfs(); EXPECT_EQ(params.dfs_owner, output.dfs_owner); EXPECT_EQ(params.recovery_interval, output.recovery_interval); EXPECT_EQ(params.channel_map, output.channel_map); } TEST_F(Dot11BeaconTest, Country) { Dot11Beacon dot11; Dot11Beacon::country_params params, output; params.country = "ARO"; params.first_channel.push_back(65); params.first_channel.push_back(11); params.first_channel.push_back(97); params.number_channels.push_back(123); params.number_channels.push_back(56); params.number_channels.push_back(42); params.max_transmit_power.push_back(4); params.max_transmit_power.push_back(213); params.max_transmit_power.push_back(165); dot11.country(params); output = dot11.country(); EXPECT_EQ(params.country, output.country); EXPECT_EQ(params.first_channel, output.first_channel); EXPECT_EQ(params.number_channels, output.number_channels); EXPECT_EQ(params.max_transmit_power, output.max_transmit_power); } TEST_F(Dot11BeaconTest, FHParameters) { Dot11Beacon dot11; std::pair tim(0x42, 0x1f); dot11.fh_parameters(tim.first, tim.second); EXPECT_EQ(tim, dot11.fh_parameters()); } TEST_F(Dot11BeaconTest, FHPattern) { Dot11Beacon dot11; Dot11Beacon::fh_pattern_type tim, output; tim.flag = 0x67; tim.number_of_sets = 0x42; tim.modulus = 0x1f; tim.offset = 0x3a; tim.random_table.push_back(23); tim.random_table.push_back(15); tim.random_table.push_back(129); dot11.fh_pattern_table(tim); output = dot11.fh_pattern_table(); EXPECT_EQ(tim.flag, tim.flag); EXPECT_EQ(tim.number_of_sets, tim.number_of_sets); EXPECT_EQ(tim.modulus, tim.modulus); EXPECT_EQ(tim.offset, tim.offset); EXPECT_EQ(tim.random_table, tim.random_table); } TEST_F(Dot11BeaconTest, PowerConstraint) { Dot11Beacon dot11; dot11.power_constraint(0x1e); EXPECT_EQ(dot11.power_constraint(), 0x1e); } TEST_F(Dot11BeaconTest, ChannelSwitch) { Dot11Beacon dot11; Dot11Beacon::channel_switch_type tim(13, 42, 98), output; dot11.channel_switch(tim); output = dot11.channel_switch(); EXPECT_EQ(output.switch_mode, tim.switch_mode); EXPECT_EQ(output.new_channel, tim.new_channel); EXPECT_EQ(output.switch_count, tim.switch_count); } TEST_F(Dot11BeaconTest, Quiet) { Dot11Beacon dot11; Dot11Beacon::quiet_type tim(13, 42, 0x928f, 0xf1ad), output; dot11.quiet(tim); output = dot11.quiet(); EXPECT_EQ(output.quiet_count, tim.quiet_count); EXPECT_EQ(output.quiet_period, tim.quiet_period); EXPECT_EQ(output.quiet_duration, tim.quiet_duration); EXPECT_EQ(output.quiet_offset, tim.quiet_offset); } TEST_F(Dot11BeaconTest, TPCReport) { Dot11Beacon dot11; std::pair tim(42, 193); dot11.tpc_report(tim.first, tim.second); EXPECT_EQ(dot11.tpc_report(), tim); } TEST_F(Dot11BeaconTest, ERPInformation) { Dot11Beacon dot11; dot11.erp_information(0x1e); EXPECT_EQ(dot11.erp_information(), 0x1e); } TEST_F(Dot11BeaconTest, BSSLoad) { Dot11Beacon dot11; Dot11Beacon::bss_load_type tim(0x129f, 42, 0xf5a2), output; dot11.bss_load(tim); output = dot11.bss_load(); EXPECT_EQ(tim.station_count, output.station_count); EXPECT_EQ(tim.channel_utilization, output.channel_utilization); EXPECT_EQ(tim.available_capacity, output.available_capacity); } TEST_F(Dot11BeaconTest, TIM) { Dot11Beacon dot11; Dot11Beacon::tim_type tim, output; tim.dtim_count = 42; tim.dtim_period = 59; tim.bitmap_control = 191; tim.partial_virtual_bitmap.push_back(92); tim.partial_virtual_bitmap.push_back(182); tim.partial_virtual_bitmap.push_back(212); dot11.tim(tim); output = dot11.tim(); EXPECT_EQ(tim.dtim_count, output.dtim_count); EXPECT_EQ(tim.dtim_period, output.dtim_period); EXPECT_EQ(tim.bitmap_control, output.bitmap_control); EXPECT_EQ(tim.partial_virtual_bitmap, output.partial_virtual_bitmap); } TEST_F(Dot11BeaconTest, ChallengeText) { Dot11Beacon dot11; dot11.challenge_text("libtins ftw"); EXPECT_EQ(dot11.challenge_text(), "libtins ftw"); } TEST_F(Dot11BeaconTest, RSNInformationTest) { Dot11Beacon dot11; RSNInformation rsn_info, found; rsn_info.add_pairwise_cypher(RSNInformation::WEP_40); rsn_info.add_akm_cypher(RSNInformation::PSK); rsn_info.group_suite(RSNInformation::CCMP); rsn_info.version(0x7283); rsn_info.capabilities(0x18ad); dot11.rsn_information(rsn_info); found = dot11.rsn_information(); EXPECT_EQ(rsn_info.version(), found.version()); EXPECT_EQ(rsn_info.capabilities(), found.capabilities()); EXPECT_EQ(rsn_info.group_suite(), found.group_suite()); EXPECT_EQ(rsn_info.pairwise_cyphers(), found.pairwise_cyphers()); EXPECT_EQ(rsn_info.akm_cyphers(), found.akm_cyphers()); } TEST_F(Dot11BeaconTest, PCAPLoad1) { const uint8_t buffer[] = { 128, 0, 0, 0, 255, 255, 255, 255, 255, 255, 244, 236, 56, 254, 77, 146, 244, 236, 56, 254, 77, 146, 224, 234, 128, 209, 212, 206, 44, 0, 0, 0, 100, 0, 49, 4, 0, 7, 83, 101, 103, 117, 110, 100, 111, 1, 8, 130, 132, 139, 150, 12, 18, 24, 36, 3, 1, 1, 5, 4, 0, 1, 0, 0, 7, 6, 85, 83, 32, 1, 13, 20, 42, 1, 0, 48, 20, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 2, 0, 0, 50, 4, 48, 72, 96, 108, 221, 24, 0, 80, 242, 2, 1, 1, 3, 0, 3, 164, 0, 0, 39, 164, 0, 0, 66, 67, 94, 0, 98, 50, 47, 0, 221, 9, 0, 3, 127, 1, 1, 0, 0, 255, 127 }; typedef Dot11Beacon::country_params::container_type country_container; Dot11Beacon dot11(buffer, sizeof(buffer)); float rates[] = { 1.0f, 2.0f, 5.5f, 11.0f, 6.0f, 9.0f, 12.0f, 18.0f}, ext_rates[] = { 24.0f, 36.0f, 48.0f, 54.0f }; Dot11Beacon::rates_type rates_parsed = dot11.supported_rates(); Dot11Beacon::rates_type ext_rates_parsed = dot11.extended_supported_rates(); Dot11Beacon::tim_type tim(0, 1, 0, Dot11Beacon::tim_type::container_type(1)), tim_parsed = dot11.tim(); Dot11Beacon::country_params country("US ", country_container(1, 1), country_container(1, 13), country_container(1, 20)), country_parsed = dot11.country(); EXPECT_EQ(dot11.ssid(), "Segundo"); ASSERT_EQ(rates_parsed.size(), sizeof(rates) / sizeof(float)); EXPECT_TRUE(std::equal(rates_parsed.begin(), rates_parsed.end(), rates)); ASSERT_EQ(ext_rates_parsed.size(), sizeof(ext_rates) / sizeof(float)); EXPECT_TRUE(std::equal(ext_rates_parsed.begin(), ext_rates_parsed.end(), ext_rates)); EXPECT_EQ(1, dot11.ds_parameter_set()); EXPECT_EQ(tim.dtim_count, tim_parsed.dtim_count); EXPECT_EQ(tim.dtim_period, tim_parsed.dtim_period); EXPECT_EQ(tim.bitmap_control, tim_parsed.bitmap_control); EXPECT_EQ(tim.partial_virtual_bitmap, tim_parsed.partial_virtual_bitmap); EXPECT_EQ(country.country, country_parsed.country); EXPECT_EQ(country.first_channel, country_parsed.first_channel); EXPECT_EQ(country.number_channels, country_parsed.number_channels); EXPECT_EQ(country.max_transmit_power, country_parsed.max_transmit_power); EXPECT_EQ(dot11.erp_information(), 0); PDU::serialization_type serialized = dot11.serialize(); ASSERT_EQ(sizeof(buffer), serialized.size()); EXPECT_TRUE(std::equal(serialized.begin(), serialized.end(), buffer)); } TEST_F(Dot11BeaconTest, Serialize) { Dot11Beacon pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/authentication.cpp0000664000175000017500000000661112154360113020743 0ustar matiasmatias#include #include "dot11/dot11_auth.h" #include "tests/dot11_mgmt.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11AuthenticationTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11AuthenticationTest::expected_packet[] = { 177, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 0, 0, 162, 40, 58, 242, 243, 146 }; void test_equals(const Dot11Authentication &dot1, const Dot11Authentication &dot2) { EXPECT_EQ(dot1.status_code(), dot2.status_code()); EXPECT_EQ(dot1.auth_seq_number(), dot2.auth_seq_number()); EXPECT_EQ(dot1.auth_algorithm(), dot2.auth_algorithm()); test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11Authentication &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.status_code(), 0x92f3); EXPECT_EQ(dot11.auth_seq_number(), 0xf23a); EXPECT_EQ(dot11.auth_algorithm(), 0x28a2); EXPECT_EQ(dot11.subtype(), Dot11::AUTH); } TEST_F(Dot11AuthenticationTest, Constructor) { Dot11Authentication dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.status_code(), 0); EXPECT_EQ(dot11.auth_seq_number(), 0); EXPECT_EQ(dot11.auth_algorithm(), 0); EXPECT_EQ(dot11.subtype(), Dot11::AUTH); } TEST_F(Dot11AuthenticationTest, ConstructorFromBuffer) { Dot11Authentication dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11AuthenticationTest, CopyConstructor) { Dot11Authentication dot1(expected_packet, sizeof(expected_packet)); Dot11Authentication dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11AuthenticationTest, CopyAssignmentOperator) { Dot11Authentication dot1(expected_packet, sizeof(expected_packet)); Dot11Authentication dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11AuthenticationTest, StatusCode) { Dot11Authentication dot11; dot11.status_code(0x92f3); EXPECT_EQ(dot11.status_code(), 0x92f3); } TEST_F(Dot11AuthenticationTest, AuthSequenceNumber) { Dot11Authentication dot11; dot11.auth_seq_number(0x92f3); EXPECT_EQ(dot11.auth_seq_number(), 0x92f3); } TEST_F(Dot11AuthenticationTest, AuthAlgorithm) { Dot11Authentication dot11; dot11.auth_algorithm(0x92f3); EXPECT_EQ(dot11.auth_algorithm(), 0x92f3); } TEST_F(Dot11AuthenticationTest, ClonePDU) { Dot11Authentication dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11AuthenticationTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11Authentication *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11AuthenticationTest, Serialize) { Dot11Authentication pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/assoc_response.cpp0000664000175000017500000000603712154360113020754 0ustar matiasmatias#include #include "dot11/dot11_assoc.h" #include "tests/dot11_mgmt.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11AssocResponseTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const uint8_t Dot11AssocResponseTest::expected_packet[] = { 17, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 0, 0, 21, 32, 243, 146, 58, 242 }; void test_equals(const Dot11AssocResponse &dot1, const Dot11AssocResponse &dot2) { test_equals(dot1.capabilities(), dot2.capabilities()); EXPECT_EQ(dot1.status_code(), dot2.status_code()); EXPECT_EQ(dot1.aid(), dot2.aid()); test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11AssocResponse &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.status_code(), 0x92f3); EXPECT_EQ(dot11.aid(), 0xf23a); EXPECT_EQ(dot11.subtype(), Dot11::ASSOC_RESP); } TEST_F(Dot11AssocResponseTest, Constructor) { Dot11AssocResponse dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.status_code(), 0); EXPECT_EQ(dot11.aid(), 0); EXPECT_EQ(dot11.subtype(), Dot11::ASSOC_RESP); } TEST_F(Dot11AssocResponseTest, ConstructorFromBuffer) { Dot11AssocResponse dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11AssocResponseTest, CopyConstructor) { Dot11AssocResponse dot1(expected_packet, sizeof(expected_packet)); Dot11AssocResponse dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11AssocResponseTest, CopyAssignmentOperator) { Dot11AssocResponse dot1(expected_packet, sizeof(expected_packet)); Dot11AssocResponse dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11AssocResponseTest, StatusCode) { Dot11AssocResponse dot11; dot11.status_code(0x92f3); EXPECT_EQ(dot11.status_code(), 0x92f3); } TEST_F(Dot11AssocResponseTest, AID) { Dot11AssocResponse dot11; dot11.aid(0x92f3); EXPECT_EQ(dot11.aid(), 0x92f3); } TEST_F(Dot11AssocResponseTest, ClonePDU) { Dot11AssocResponse dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11AssocResponseTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11AssocResponse *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11AssocResponseTest, Serialize) { Dot11AssocResponse pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/assoc_request.cpp0000664000175000017500000000555312154360113020610 0ustar matiasmatias#include #include "dot11/dot11_assoc.h" #include "tests/dot11_mgmt.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11AssocRequestTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; //static void test_equals_expected(const Dot11Beacon&dot11); }; const uint8_t Dot11AssocRequestTest::expected_packet[] = { 1, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 0, 0, 21, 32, 243, 146 }; void test_equals(const Dot11AssocRequest &dot1, const Dot11AssocRequest &dot2) { test_equals(dot1.capabilities(), dot2.capabilities()); EXPECT_EQ(dot1.listen_interval(), dot2.listen_interval()); test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11AssocRequest &dot11) { test_equals_expected(static_cast(dot11)); EXPECT_EQ(dot11.listen_interval(), 0x92f3); EXPECT_EQ(dot11.subtype(), Dot11::ASSOC_REQ); } TEST_F(Dot11AssocRequestTest, Constructor) { Dot11AssocRequest dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.listen_interval(), 0); EXPECT_EQ(dot11.subtype(), Dot11::ASSOC_REQ); } TEST_F(Dot11AssocRequestTest, ConstructorFromBuffer) { Dot11AssocRequest dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11AssocRequestTest, CopyConstructor) { Dot11AssocRequest dot1(expected_packet, sizeof(expected_packet)); Dot11AssocRequest dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11AssocRequestTest, CopyAssignmentOperator) { Dot11AssocRequest dot1(expected_packet, sizeof(expected_packet)); Dot11AssocRequest dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11AssocRequestTest, ListenInterval) { Dot11AssocRequest dot11; dot11.listen_interval(0x92fd); EXPECT_EQ(dot11.listen_interval(), 0x92fd); } TEST_F(Dot11AssocRequestTest, ClonePDU) { Dot11AssocRequest dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11AssocRequestTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11AssocRequest *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11AssocRequestTest, Serialize) { Dot11AssocRequest pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dot11/ack.cpp0000664000175000017500000000565012154360113016464 0ustar matiasmatias#include #include "dot11/dot11_control.h" #include "tests/dot11.h" using namespace std; using namespace Tins; typedef Dot11::address_type address_type; class Dot11AckTest : public testing::Test { public: static const address_type empty_addr, hwaddr; static const uint8_t expected_packet[]; }; const address_type Dot11AckTest::empty_addr; const uint8_t Dot11AckTest::expected_packet[] = { 213, 1, 79, 35, 0, 1, 2, 3, 4, 5 }; void test_equals(const Dot11Ack &dot1, const Dot11Ack &dot2) { test_equals( static_cast(dot1), static_cast(dot2) ); } void test_equals_expected(const Dot11Ack &dot11) { EXPECT_EQ(dot11.protocol(), 1); EXPECT_EQ(dot11.type(), Dot11::CONTROL); EXPECT_EQ(dot11.subtype(), Dot11::ACK); EXPECT_EQ(dot11.to_ds(), 1); EXPECT_EQ(dot11.from_ds(), 0); EXPECT_EQ(dot11.more_frag(), 0); EXPECT_EQ(dot11.retry(), 0); EXPECT_EQ(dot11.power_mgmt(), 0); EXPECT_EQ(dot11.wep(), 0); EXPECT_EQ(dot11.order(), 0); EXPECT_EQ(dot11.duration_id(), 0x234f); EXPECT_EQ(dot11.subtype(), Dot11::ACK); EXPECT_EQ(dot11.addr1(), "00:01:02:03:04:05"); } TEST_F(Dot11AckTest, Constructor) { Dot11Ack dot11; test_equals_empty(static_cast(dot11)); EXPECT_EQ(dot11.protocol(), 0); EXPECT_EQ(dot11.type(), Dot11::CONTROL); EXPECT_EQ(dot11.subtype(), Dot11::ACK); EXPECT_EQ(dot11.to_ds(), 0); EXPECT_EQ(dot11.from_ds(), 0); EXPECT_EQ(dot11.more_frag(), 0); EXPECT_EQ(dot11.retry(), 0); EXPECT_EQ(dot11.power_mgmt(), 0); EXPECT_EQ(dot11.wep(), 0); EXPECT_EQ(dot11.order(), 0); EXPECT_EQ(dot11.duration_id(), 0); EXPECT_EQ(dot11.addr1(), empty_addr); } TEST_F(Dot11AckTest, ConstructorFromBuffer) { Dot11Ack dot11(expected_packet, sizeof(expected_packet)); test_equals_expected(dot11); } TEST_F(Dot11AckTest, CopyConstructor) { Dot11Ack dot1(expected_packet, sizeof(expected_packet)); Dot11Ack dot2(dot1); test_equals(dot1, dot2); } TEST_F(Dot11AckTest, CopyAssignmentOperator) { Dot11Ack dot1(expected_packet, sizeof(expected_packet)); Dot11Ack dot2; dot2 = dot1; test_equals(dot1, dot2); } TEST_F(Dot11AckTest, ClonePDU) { Dot11Ack dot1(expected_packet, sizeof(expected_packet)); Internals::smart_ptr::type dot2(dot1.clone()); test_equals(dot1, *dot2); } TEST_F(Dot11AckTest, FromBytes) { Internals::smart_ptr::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet))); ASSERT_TRUE(dot11.get()); const Dot11Ack *inner = dot11->find_pdu(); ASSERT_TRUE(inner); test_equals_expected(*inner); } TEST_F(Dot11AckTest, Serialize) { Dot11Ack pdu(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = pdu.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } libtins-1.1/tests/src/dns.cpp0000664000175000017500000002060412154360113015556 0ustar matiasmatias#include #include #include "dns.h" #include "ipv6_address.h" #include "utils.h" using namespace Tins; class DNSTest : public testing::Test { public: static const uint8_t expected_packet[]; void test_equals(const DNS &dns1, const DNS &dns2); void test_equals(const DNS::Query &q1, const DNS::Query &q2); void test_equals(const DNS::Resource &q1, const DNS::Resource &q2); }; const uint8_t DNSTest::expected_packet[] = { 0, 19, 215, 154, 0, 1, 0, 1, 0, 0, 0, 0, 3, 119, 119, 119, 7, 101, 120, 97, 109, 112, 108, 101, 3, 99, 111, 109, 0, 0, 1, 0, 1, 3, 119, 119, 119, 7, 101, 120, 97, 109, 112, 108, 101, 3, 99, 111, 109, 0, 0, 1, 0, 1, 0, 0, 18, 52, 0, 4, 192, 168, 0, 1 }; void DNSTest::test_equals(const DNS &dns1, const DNS &dns2) { EXPECT_EQ(dns1.id(), dns2.id()); EXPECT_EQ(dns1.type(), dns2.type()); EXPECT_EQ(dns1.opcode(), dns2.opcode()); EXPECT_EQ(dns1.authoritative_answer(), dns2.authoritative_answer()); EXPECT_EQ(dns1.truncated(), dns2.truncated()); EXPECT_EQ(dns1.recursion_desired(), dns2.recursion_desired()); EXPECT_EQ(dns1.recursion_available(), dns2.recursion_available()); EXPECT_EQ(dns1.z(), dns2.z()); EXPECT_EQ(dns1.authenticated_data(), dns2.authenticated_data()); EXPECT_EQ(dns1.checking_disabled(), dns2.checking_disabled()); EXPECT_EQ(dns1.rcode(), dns2.rcode()); EXPECT_EQ(dns1.questions_count(), dns2.questions_count()); EXPECT_EQ(dns1.answers_count(), dns2.answers_count()); EXPECT_EQ(dns1.authority_count(), dns2.authority_count()); EXPECT_EQ(dns1.additional_count(), dns2.additional_count()); EXPECT_EQ(dns1.pdu_type(), dns2.pdu_type()); EXPECT_EQ(dns1.header_size(), dns2.header_size()); EXPECT_EQ(bool(dns1.inner_pdu()), bool(dns2.inner_pdu())); } void DNSTest::test_equals(const DNS::Query &q1, const DNS::Query &q2) { EXPECT_EQ(q1.dname(), q2.dname()); EXPECT_EQ(q1.type(), q2.type()); EXPECT_EQ(q1.query_class(), q2.query_class()); } void DNSTest::test_equals(const DNS::Resource &q1, const DNS::Resource &q2) { EXPECT_EQ(q1.dname(), q2.dname()); EXPECT_EQ(q1.data(), q2.data()); EXPECT_EQ(q1.type(), q2.type()); EXPECT_EQ(q1.query_class(), q2.query_class()); EXPECT_EQ(q1.ttl(), q2.ttl()); } TEST_F(DNSTest, ConstructorFromBuffer) { DNS dns(expected_packet, sizeof(expected_packet)); // id=0x13, qr=1, opcode=0xa, aa=1, tc=1, rd=1, ra=1, z=0, rcode=0xa EXPECT_EQ(dns.id(), 0x13); EXPECT_EQ(dns.type(), DNS::RESPONSE); EXPECT_EQ(dns.opcode(), 0xa); EXPECT_EQ(dns.authoritative_answer(), 1); EXPECT_EQ(dns.truncated(), 1); EXPECT_EQ(dns.recursion_desired(), 1); EXPECT_EQ(dns.recursion_available(), 1); EXPECT_EQ(dns.z(), 0); EXPECT_EQ(dns.rcode(), 0xa); EXPECT_EQ(dns.questions_count(), 1); EXPECT_EQ(dns.answers_count(), 1); std::list queries = dns.queries(); ASSERT_EQ(queries.size(), 1); test_equals(queries.front(), DNS::Query("www.example.com", DNS::A, DNS::IN)); std::list answers = dns.answers(); ASSERT_EQ(answers.size(), 1); test_equals(answers.front(), DNS::Resource("www.example.com", "192.168.0.1", DNS::A, DNS::IN, 0x1234)); } TEST_F(DNSTest, Serialization) { DNS dns(expected_packet, sizeof(expected_packet)); DNS::serialization_type buffer = dns.serialize(); ASSERT_EQ(buffer.size(), sizeof(expected_packet)); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); } TEST_F(DNSTest, CopyConstructor) { DNS dns1(expected_packet, sizeof(expected_packet)); DNS dns2(dns1); test_equals(dns1, dns2); } TEST_F(DNSTest, CopyAssignmentOperator) { DNS dns1(expected_packet, sizeof(expected_packet)); DNS dns2; dns2 = dns1; test_equals(dns1, dns2); } TEST_F(DNSTest, NestedCopy) { DNS *nested = new DNS(expected_packet, sizeof(expected_packet)); DNS dns1(expected_packet, sizeof(expected_packet)); dns1.inner_pdu(nested); DNS dns2(dns1); test_equals(dns1, dns2); dns2.inner_pdu(0); dns2 = dns1; test_equals(dns1, dns2); } TEST_F(DNSTest, ID) { DNS dns; dns.id(0x7263); EXPECT_EQ(dns.id(), 0x7263); } TEST_F(DNSTest, Type) { DNS dns; dns.type(DNS::RESPONSE); EXPECT_EQ(dns.type(), DNS::RESPONSE); } TEST_F(DNSTest, Opcode) { DNS dns; dns.opcode(0xa); EXPECT_EQ(dns.opcode(), 0xa); } TEST_F(DNSTest, AuthoritativeAnswer) { DNS dns; dns.authoritative_answer(1); EXPECT_EQ(dns.authoritative_answer(), 1); } TEST_F(DNSTest, Truncated) { DNS dns; dns.truncated(1); EXPECT_EQ(dns.truncated(), 1); } TEST_F(DNSTest, RecursionDesired) { DNS dns; dns.recursion_desired(1); EXPECT_EQ(dns.recursion_desired(), 1); } TEST_F(DNSTest, RecursionAvailable) { DNS dns; dns.recursion_available(1); EXPECT_EQ(dns.recursion_available(), 1); } TEST_F(DNSTest, Z) { DNS dns; dns.z(1); EXPECT_EQ(dns.z(), 1); } TEST_F(DNSTest, AuthenticatedData) { DNS dns; dns.authenticated_data(1); EXPECT_EQ(dns.authenticated_data(), 1); } TEST_F(DNSTest, CheckingDisabled) { DNS dns; dns.checking_disabled(1); EXPECT_EQ(dns.checking_disabled(), 1); } TEST_F(DNSTest, RCode) { DNS dns; dns.rcode(0xa); EXPECT_EQ(dns.rcode(), 0xa); } TEST_F(DNSTest, Question) { DNS dns; dns.add_query(DNS::Query("www.example.com", DNS::A, DNS::IN)); dns.add_query(DNS::Query("www.example2.com", DNS::MX, DNS::IN)); ASSERT_EQ(dns.questions_count(), 2); DNS::queries_type queries(dns.queries()); for(DNS::queries_type::const_iterator it = queries.begin(); it != queries.end(); ++it) { EXPECT_TRUE(it->dname() == "www.example.com" || it->dname() == "www.example2.com"); if(it->dname() == "www.example.com") { EXPECT_EQ(it->type(), DNS::A); EXPECT_EQ(it->query_class(), DNS::IN); } else if(it->dname() == "www.example2.com") { EXPECT_EQ(it->type(), DNS::MX); EXPECT_EQ(it->query_class(), DNS::IN); } } } TEST_F(DNSTest, Answers) { DNS dns; dns.add_answer("www.example.com", DNS::make_info(DNS::A, DNS::IN, 0x762), IPv4Address("127.0.0.1")); dns.add_answer("www.example2.com", DNS::make_info(DNS::MX, DNS::IN, 0x762), IPv4Address("127.0.0.1")); ASSERT_EQ(dns.answers_count(), 2); DNS::resources_type resources = dns.answers(); for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_TRUE(it->dname() == "www.example.com" || it->dname() == "www.example2.com"); if(it->dname() == "www.example.com") { EXPECT_EQ(it->type(), DNS::A); EXPECT_EQ(it->ttl(), 0x762); EXPECT_EQ(it->data(), "127.0.0.1"); EXPECT_EQ(it->query_class(), DNS::IN); } else if(it->dname() == "www.example2.com") { EXPECT_EQ(it->type(), DNS::MX); EXPECT_EQ(it->ttl(), 0x762); EXPECT_EQ(it->data(), "127.0.0.1"); EXPECT_EQ(it->query_class(), DNS::IN); } } } TEST_F(DNSTest, AnswersWithSameName) { DNS dns; dns.add_answer("www.example.com", DNS::make_info(DNS::A, DNS::IN, 0x762), IPv4Address("127.0.0.1")); dns.add_answer("www.example.com", DNS::make_info(DNS::A, DNS::IN, 0x762), IPv4Address("127.0.0.2")); ASSERT_EQ(dns.answers_count(), 2); DNS::resources_type resources = dns.answers(); for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_TRUE(it->data() == "127.0.0.1" || it->data() == "127.0.0.2"); EXPECT_EQ(it->dname(), "www.example.com"); EXPECT_EQ(it->type(), DNS::A); EXPECT_EQ(it->ttl(), 0x762); EXPECT_EQ(it->query_class(), DNS::IN); } } TEST_F(DNSTest, AnswersV6) { DNS dns; dns.add_answer("www.example.com", DNS::make_info(DNS::AAAA, DNS::IN, 0x762), IPv6Address("f9a8:239::1:1")); dns.add_answer("www.example.com", DNS::make_info(DNS::AAAA, DNS::IN, 0x762), IPv6Address("f9a8:239::1:1")); ASSERT_EQ(dns.answers_count(), 2); DNS::resources_type resources = dns.answers(); for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_EQ(it->dname(), "www.example.com"); EXPECT_EQ(it->type(), DNS::AAAA); EXPECT_EQ(it->ttl(), 0x762); EXPECT_EQ(it->data(), "f9a8:239::1:1"); EXPECT_EQ(it->query_class(), DNS::IN); } } libtins-1.1/tests/src/dhcpv6.cpp0000664000175000017500000002174612154360113016174 0ustar matiasmatias#include #include #include #include #include "dhcpv6.h" using namespace Tins; class DHCPv6Test : public testing::Test { public: static const uint8_t expected_packet[]; void test_equals(const DHCPv6 &dhcp1, const DHCPv6 &dhcp2); }; const uint8_t DHCPv6Test::expected_packet[] = { 1, 232, 40, 185, 0, 1, 0, 10, 0, 3, 0, 1, 0, 1, 2, 3, 4, 5, 0, 3, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 2, 0, 0, 0, 6, 0, 2, 0, 3 }; TEST_F(DHCPv6Test, DefaultConstructor) { DHCPv6 dhcp; EXPECT_EQ(0, (int)dhcp.msg_type()); EXPECT_EQ(0, dhcp.hop_count()); EXPECT_EQ(0, dhcp.transaction_id()); } TEST_F(DHCPv6Test, ConstructorFromBuffer) { DHCPv6 dhcp(expected_packet, sizeof(expected_packet)); EXPECT_EQ(DHCPv6::SOLICIT, dhcp.msg_type()); EXPECT_EQ(0xe828b9, dhcp.transaction_id()); EXPECT_TRUE(dhcp.search_option(DHCPv6::CLIENTID)); EXPECT_TRUE(dhcp.search_option(DHCPv6::IA_NA)); EXPECT_TRUE(dhcp.search_option(DHCPv6::ELAPSED_TIME)); EXPECT_TRUE(dhcp.search_option(DHCPv6::OPTION_REQUEST)); EXPECT_FALSE(dhcp.search_option(DHCPv6::SERVERID)); } TEST_F(DHCPv6Test, Serialize) { DHCPv6 dhcp(expected_packet, sizeof(expected_packet)); DHCPv6::serialization_type buffer = dhcp.serialize(); ASSERT_EQ(sizeof(expected_packet), buffer.size()); EXPECT_EQ( DHCPv6::serialization_type(expected_packet, expected_packet + sizeof(expected_packet)), buffer ); } TEST_F(DHCPv6Test, MessageType) { DHCPv6 dhcp; dhcp.msg_type(DHCPv6::SOLICIT); EXPECT_EQ(DHCPv6::SOLICIT, dhcp.msg_type()); } TEST_F(DHCPv6Test, HopCount) { DHCPv6 dhcp; dhcp.hop_count(0x8a); EXPECT_EQ(0x8a, dhcp.hop_count()); } TEST_F(DHCPv6Test, TransactionId) { DHCPv6 dhcp; dhcp.transaction_id(0x8af2ad); EXPECT_EQ(0x8af2ad, dhcp.transaction_id()); } // Options TEST_F(DHCPv6Test, IA_NA) { DHCPv6 dhcp; DHCPv6::ia_na_type data, output; data.id = 0x9283f78a; data.t1 = 0xaf235212; data.t2 = 0x9a8293fa; data.options.push_back(0); data.options.push_back(1); data.options.push_back(2); dhcp.ia_na(data); output = dhcp.ia_na(); EXPECT_EQ(data.id, output.id); EXPECT_EQ(data.t1, output.t1); EXPECT_EQ(data.t2, output.t2); EXPECT_EQ(data.options, output.options); } TEST_F(DHCPv6Test, IA_TA) { DHCPv6 dhcp; DHCPv6::ia_ta_type data, output; data.id = 0x9283f78a; data.options.push_back(0); data.options.push_back(1); data.options.push_back(2); dhcp.ia_ta(data); output = dhcp.ia_ta(); EXPECT_EQ(data.id, output.id); EXPECT_EQ(data.options, output.options); } TEST_F(DHCPv6Test, IA_Address) { DHCPv6 dhcp; DHCPv6::ia_address_type data, output; data.address = "fe00:feaa::1"; data.preferred_lifetime = 0x9283f78a; data.valid_lifetime = 0x938fda32; data.options.push_back(0); data.options.push_back(1); data.options.push_back(2); dhcp.ia_address(data); output = dhcp.ia_address(); EXPECT_EQ(data.address, output.address); EXPECT_EQ(data.preferred_lifetime, output.preferred_lifetime); EXPECT_EQ(data.valid_lifetime, output.valid_lifetime); EXPECT_EQ(data.options, output.options); } TEST_F(DHCPv6Test, OptionRequest) { DHCPv6 dhcp; DHCPv6::option_request_type data, output; data.push_back(DHCPv6::IA_ADDR); data.push_back(DHCPv6::IA_NA); dhcp.option_request(data); output = dhcp.option_request(); EXPECT_EQ(data, output); } TEST_F(DHCPv6Test, Preference) { DHCPv6 dhcp; dhcp.preference(0x8a); EXPECT_EQ(0x8a, dhcp.preference()); } TEST_F(DHCPv6Test, ElapsedTime) { DHCPv6 dhcp; dhcp.elapsed_time(0x8a2f); EXPECT_EQ(0x8a2f, dhcp.elapsed_time()); } TEST_F(DHCPv6Test, RelayMessage) { DHCPv6 dhcp; DHCPv6::relay_msg_type data, output; data.push_back(1); data.push_back(156); data.push_back(12); dhcp.relay_message(data); output = dhcp.relay_message(); EXPECT_EQ(data, output); } TEST_F(DHCPv6Test, Authentication) { DHCPv6 dhcp; DHCPv6::authentication_type data, output; data.protocol = 0x92; data.algorithm = 0x8f; data.rdm = 0xa1; data.replay_detection = 0x78ad6d5290398df7; data.auth_info.push_back(0); data.auth_info.push_back(1); data.auth_info.push_back(2); dhcp.authentication(data); output = dhcp.authentication(); EXPECT_EQ(data.protocol, output.protocol); EXPECT_EQ(data.algorithm, output.algorithm); EXPECT_EQ(data.rdm, output.rdm); EXPECT_EQ(data.replay_detection, output.replay_detection); EXPECT_EQ(data.auth_info, output.auth_info); } TEST_F(DHCPv6Test, ServerUnicast) { const IPv6Address addr("fe00:0a9d:dd23::1"); DHCPv6 dhcp; dhcp.server_unicast(addr); EXPECT_EQ(addr, dhcp.server_unicast()); } TEST_F(DHCPv6Test, StatusCode) { DHCPv6 dhcp; DHCPv6::status_code_type data(0x72, "libtins, mah frend"), output; dhcp.status_code(data); output = dhcp.status_code(); EXPECT_EQ(data.code, output.code); EXPECT_EQ(data.message, output.message); } TEST_F(DHCPv6Test, RapidCommit) { DHCPv6 dhcp; dhcp.rapid_commit(); EXPECT_EQ(true, dhcp.has_rapid_commit()); } TEST_F(DHCPv6Test, UserClass) { DHCPv6 dhcp; DHCPv6::user_class_type data, output; DHCPv6::class_option_data_type user_data; user_data.push_back(22); user_data.push_back(176); data.push_back(user_data); user_data.push_back(99); user_data.push_back(231); data.push_back(user_data); dhcp.user_class(data); output = dhcp.user_class(); EXPECT_EQ(data, output); } TEST_F(DHCPv6Test, VendorClass) { DHCPv6 dhcp; DHCPv6::vendor_class_type data(15), output; DHCPv6::class_option_data_type user_data; user_data.push_back(22); user_data.push_back(176); data.vendor_class_data.push_back(user_data); user_data.push_back(99); user_data.push_back(231); data.vendor_class_data.push_back(user_data); dhcp.vendor_class(data); output = dhcp.vendor_class(); EXPECT_EQ(data.enterprise_number, output.enterprise_number); EXPECT_EQ(data.vendor_class_data, output.vendor_class_data); } TEST_F(DHCPv6Test, VendorInfo) { DHCPv6 dhcp; DHCPv6::vendor_info_type data(0x72988fad), output; data.data.push_back(22); data.data.push_back(176); data.data.push_back(99); data.data.push_back(231); dhcp.vendor_info(data); output = dhcp.vendor_info(); EXPECT_EQ(data.enterprise_number, output.enterprise_number); EXPECT_EQ(data.data, output.data); } TEST_F(DHCPv6Test, InterfaceID) { DHCPv6 dhcp; DHCPv6::interface_id_type data, output; data.push_back(1); data.push_back(156); data.push_back(12); dhcp.interface_id(data); output = dhcp.interface_id(); EXPECT_EQ(data, output); } TEST_F(DHCPv6Test, ReconfigureMsg) { DHCPv6 dhcp; dhcp.reconfigure_msg(0x8a); EXPECT_EQ(0x8a, dhcp.reconfigure_msg()); } TEST_F(DHCPv6Test, ReconfigureAccept) { DHCPv6 dhcp; dhcp.reconfigure_accept(); EXPECT_EQ(true, dhcp.has_reconfigure_accept()); } TEST_F(DHCPv6Test, Client_Server_ID_DUIDLL) { DHCPv6 dhcp; DHCPv6::duid_ll data, output; DHCPv6::duid_type tmp, tmp2; data.hw_type = 0x5f; data.lladdress.push_back(78); data.lladdress.push_back(66); data.lladdress.push_back(209); dhcp.client_id(data); tmp = dhcp.client_id(); output = DHCPv6::duid_ll::from_bytes(&tmp.data[0], tmp.data.size()); EXPECT_EQ(data.hw_type, output.hw_type); EXPECT_EQ(data.lladdress, output.lladdress); dhcp.server_id(data); tmp2 = dhcp.server_id(); EXPECT_EQ(tmp.id, tmp2.id); EXPECT_EQ(tmp.data, tmp2.data); } TEST_F(DHCPv6Test, Client_Server_ID_DUIDLLT) { DHCPv6 dhcp; DHCPv6::duid_llt data, output; DHCPv6::duid_type tmp, tmp2; data.hw_type = 0x5f; data.time = 0x92837af; data.lladdress.push_back(78); data.lladdress.push_back(66); data.lladdress.push_back(209); dhcp.client_id(data); tmp = dhcp.client_id(); output = DHCPv6::duid_llt::from_bytes(&tmp.data[0], tmp.data.size()); EXPECT_EQ(data.hw_type, output.hw_type); EXPECT_EQ(data.time, output.time); EXPECT_EQ(data.lladdress, output.lladdress); dhcp.server_id(data); tmp2 = dhcp.server_id(); EXPECT_EQ(tmp.id, tmp2.id); EXPECT_EQ(tmp.data, tmp2.data); } TEST_F(DHCPv6Test, Client_Server_ID_DUIDEN) { DHCPv6 dhcp; DHCPv6::duid_en data, output; DHCPv6::duid_type tmp, tmp2; data.enterprise_number = 0x5faa23da; data.identifier.push_back(78); data.identifier.push_back(66); data.identifier.push_back(209); dhcp.client_id(data); tmp = dhcp.client_id(); output = DHCPv6::duid_en::from_bytes(&tmp.data[0], tmp.data.size()); EXPECT_EQ(data.enterprise_number, output.enterprise_number); EXPECT_EQ(data.identifier, output.identifier); dhcp.server_id(data); tmp2 = dhcp.server_id(); EXPECT_EQ(tmp.id, tmp2.id); EXPECT_EQ(tmp.data, tmp2.data); } libtins-1.1/tests/src/dhcp.cpp0000664000175000017500000002333212154360113015711 0ustar matiasmatias#include #include #include #include #include #include #include "dhcp.h" #include "utils.h" #include "ethernetII.h" #include "hw_address.h" #include "ip_address.h" using namespace std; using namespace Tins; class DHCPTest : public testing::Test { public: static const uint8_t expected_packet[]; static const BootP::chaddr_type chaddr; static const uint8_t sname[], file[]; static const IPv4Address addr; void test_equals(const DHCP &dhcp1, const DHCP &dhcp2); void test_option(const DHCP &dhcp, DHCP::OptionTypes opt, uint32_t len = 0, uint8_t *value = 0); }; const BootP::chaddr_type DHCPTest::chaddr("16:ab:54:12:fa:ca:56:7f:1b:65:11:fa:da:ab:19:18"); const uint8_t DHCPTest::sname[] = "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xbb\x19\x18" "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xcb\x19\x18" "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xeb\x19\x18" "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xfb\x19\x18"; const uint8_t DHCPTest::file[] = "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xbb\x19\x18" "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xcb\x19\x18" "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xeb\x19\x18" "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xfb\x19\x18" "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xbb\x19\x18" "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xcb\x19\x18" "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xeb\x19\x18" "\x16\xab\x54\x12\xfa\xca\x56\x7f\x1b\x65\x11\xfa\xda\xfb\x19\x18"; const IPv4Address DHCPTest::addr("192.168.8.1"); const uint8_t DHCPTest::expected_packet[] = { 1, 1, 6, 31, 63, 171, 35, 222, 159, 26, 0, 0, 192, 168, 0, 102, 243, 22, 34, 98, 167, 32, 11, 154, 123, 43, 55, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 130, 83, 99, 54, 4, 192, 168, 4, 2, 1, 4, 255, 255, 32, 11, 53, 1, 4, 3, 8, 192, 168, 0, 1, 127, 0, 0, 1, 6, 8, 192, 168, 0, 2, 127, 0, 0, 1 }; TEST_F(DHCPTest, DefaultConstructor) { DHCP dhcp; EXPECT_EQ(dhcp.htype(), 1); EXPECT_EQ(dhcp.hlen(), (const size_t)EthernetII::address_type::address_size); } TEST_F(DHCPTest, CopyConstructor) { DHCP dhcp1(expected_packet, sizeof(expected_packet)); DHCP dhcp2(dhcp1); test_equals(dhcp1, dhcp2); } TEST_F(DHCPTest, CopyAssignmentOperator) { DHCP dhcp1(expected_packet, sizeof(expected_packet)); DHCP dhcp2 = dhcp1; test_equals(dhcp1, dhcp2); } TEST_F(DHCPTest, NestedCopy) { } TEST_F(DHCPTest, OpCode) { DHCP dhcp; dhcp.opcode(0x71); EXPECT_EQ(dhcp.opcode(), 0x71); } TEST_F(DHCPTest, HType) { DHCP dhcp; dhcp.htype(0x71); EXPECT_EQ(dhcp.htype(), 0x71); } TEST_F(DHCPTest, HLen) { DHCP dhcp; dhcp.hlen(0x71); EXPECT_EQ(dhcp.hlen(), 0x71); } TEST_F(DHCPTest, HOps) { DHCP dhcp; dhcp.hops(0x71); EXPECT_EQ(dhcp.hops(), 0x71); } TEST_F(DHCPTest, Xid) { DHCP dhcp; dhcp.xid(0x71bd167c); EXPECT_EQ(dhcp.xid(), 0x71bd167c); } TEST_F(DHCPTest, Secs) { DHCP dhcp; dhcp.secs(0x71bd); EXPECT_EQ(dhcp.secs(), 0x71bd); } TEST_F(DHCPTest, Padding) { DHCP dhcp; dhcp.padding(0x71bd); EXPECT_EQ(dhcp.padding(), 0x71bd); } TEST_F(DHCPTest, Ciaddr) { DHCP dhcp; dhcp.ciaddr(addr); EXPECT_EQ(dhcp.ciaddr(), addr); } TEST_F(DHCPTest, Yiaddr) { DHCP dhcp; dhcp.yiaddr(addr); EXPECT_EQ(dhcp.yiaddr(), addr); } TEST_F(DHCPTest, Siaddr) { DHCP dhcp; dhcp.siaddr(addr); EXPECT_EQ(dhcp.siaddr(), addr); } TEST_F(DHCPTest, Giaddr) { DHCP dhcp; dhcp.giaddr(addr); EXPECT_EQ(dhcp.giaddr(), addr); } TEST_F(DHCPTest, Chaddr) { DHCP dhcp; dhcp.chaddr(chaddr); EXPECT_EQ(dhcp.chaddr(), chaddr); HWAddress<4> hwaddr("31:33:70:00"); dhcp.chaddr(hwaddr); HWAddress<4> copied(dhcp.chaddr()); EXPECT_EQ(copied, hwaddr); } TEST_F(DHCPTest, Sname) { DHCP dhcp; dhcp.sname(sname); EXPECT_TRUE(memcmp(dhcp.sname(), sname, 64) == 0); } TEST_F(DHCPTest, File) { DHCP dhcp; dhcp.file(file); EXPECT_TRUE(memcmp(dhcp.file(), file, 128) == 0); } void DHCPTest::test_option(const DHCP &dhcp, DHCP::OptionTypes opt, uint32_t len, uint8_t *value) { const DHCP::option *option = dhcp.search_option(opt); ASSERT_TRUE(option != 0); EXPECT_EQ(option->option(), opt); ASSERT_EQ(option->data_size(), len); EXPECT_TRUE(std::equal(option->data_ptr(), option->data_ptr() + option->data_size(), value)); } TEST_F(DHCPTest, TypeOption) { DHCP dhcp; dhcp.type(DHCP::REQUEST); EXPECT_EQ(dhcp.type(), DHCP::REQUEST); } TEST_F(DHCPTest, ServerIdentifierOption) { DHCP dhcp; dhcp.server_identifier("192.168.0.1"); EXPECT_EQ(DHCP::ipaddress_type("192.168.0.1"), dhcp.server_identifier()); } TEST_F(DHCPTest, LeaseTimeOption) { DHCP dhcp; uint32_t ltime = 0x34f1; dhcp.lease_time(ltime); EXPECT_EQ(ltime, dhcp.lease_time()); } TEST_F(DHCPTest, SubnetMaskOption) { DHCP dhcp; IPv4Address ip = "192.168.0.1", ip_found; dhcp.subnet_mask(ip); EXPECT_EQ(ip, dhcp.subnet_mask()); } TEST_F(DHCPTest, RoutersOption) { DHCP dhcp; list routers; routers.push_back("192.168.0.253"); routers.push_back("10.123.45.67"); dhcp.routers(routers); list routers2 = dhcp.routers(); ASSERT_EQ(routers.size(), routers2.size()); while(routers.size()) { EXPECT_EQ(routers.front(), routers2.front()); routers.pop_front(); routers2.pop_front(); } } TEST_F(DHCPTest, DNSOption) { DHCP dhcp; list dns; dns.push_back("192.168.0.253"); dns.push_back("10.123.45.67"); dhcp.domain_name_servers(dns); list dns2 = dhcp.domain_name_servers(); ASSERT_EQ(dns.size(), dns2.size()); while(dns.size()) { EXPECT_EQ(dns.front(), dns2.front()); dns.pop_front(); dns2.pop_front(); } } TEST_F(DHCPTest, DomainNameOption) { DHCP dhcp; string domain = "libtins.test.domain", domain_found; dhcp.domain_name(domain); EXPECT_EQ(domain, dhcp.domain_name()); } TEST_F(DHCPTest, BroadcastOption) { DHCP dhcp; IPv4Address ip = "192.168.0.1", ip_found; dhcp.broadcast(ip); EXPECT_EQ(ip, dhcp.broadcast()); } void DHCPTest::test_equals(const DHCP &dhcp1, const DHCP &dhcp2) { EXPECT_EQ(dhcp1.opcode(), dhcp2.opcode()); EXPECT_EQ(dhcp1.htype(), dhcp2.htype()); ASSERT_EQ(dhcp1.hlen(), dhcp2.hlen()); EXPECT_EQ(dhcp1.hops(), dhcp2.hops()); EXPECT_EQ(dhcp1.xid(), dhcp2.xid()); EXPECT_EQ(dhcp1.padding(), dhcp2.padding()); EXPECT_EQ(dhcp1.ciaddr(), dhcp2.ciaddr()); EXPECT_EQ(dhcp1.yiaddr(), dhcp2.yiaddr()); EXPECT_EQ(dhcp1.siaddr(), dhcp2.siaddr()); EXPECT_EQ(dhcp1.giaddr(), dhcp2.giaddr()); EXPECT_EQ(dhcp1.chaddr(), dhcp2.chaddr()); EXPECT_TRUE(memcmp(dhcp1.sname(), dhcp2.sname(), 64) == 0); EXPECT_TRUE(memcmp(dhcp1.file(), dhcp2.file(), 128) == 0); const DHCP::options_type options1(dhcp1.options()); const DHCP::options_type options2(dhcp2.options()); ASSERT_EQ(options1.size(), options2.size()); DHCP::options_type::const_iterator it1, it2; it1 = options1.begin(); it2 = options2.begin(); while(it1 != options1.end()) { EXPECT_EQ(it1->option(), it2->option()); ASSERT_EQ(it1->data_size(), it2->data_size()); EXPECT_TRUE(std::equal(it1->data_ptr(), it1->data_ptr() + it1->data_size(), it2->data_ptr())); it1++; it2++; } } TEST_F(DHCPTest, ConstructorFromBuffer) { DHCP dhcp1(expected_packet, sizeof(expected_packet)); std::list routers; IPv4Address expected_routers[] = { "192.168.0.1", "127.0.0.1" }; EXPECT_EQ(dhcp1.opcode(), DHCP::DISCOVER); EXPECT_EQ(dhcp1.htype(), 1); ASSERT_EQ(dhcp1.hlen(), (const size_t)EthernetII::address_type::address_size); EXPECT_EQ(dhcp1.hops(), 0x1f); EXPECT_EQ(dhcp1.xid(), 0x3fab23de); EXPECT_EQ(dhcp1.secs(), 0x9f1a); EXPECT_EQ(dhcp1.padding(), 0); EXPECT_EQ(dhcp1.ciaddr(), IPv4Address("192.168.0.102")); EXPECT_EQ(dhcp1.yiaddr(), IPv4Address("243.22.34.98")); EXPECT_EQ(dhcp1.giaddr(), IPv4Address("123.43.55.254")); EXPECT_EQ(dhcp1.siaddr(), IPv4Address("167.32.11.154")); EXPECT_EQ(dhcp1.server_identifier(), IPv4Address("192.168.4.2")); routers = dhcp1.routers(); ASSERT_EQ(routers.size(), sizeof(expected_routers) / sizeof(IPv4Address)); ASSERT_TRUE(std::equal(routers.begin(), routers.end(), expected_routers)); } TEST_F(DHCPTest, Serialize) { DHCP dhcp1(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = dhcp1.serialize(); ASSERT_EQ(buffer.size(), sizeof(expected_packet)); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); DHCP dhcp2(&buffer[0], buffer.size()); test_equals(dhcp1, dhcp2); } libtins-1.1/tests/src/arp.cpp0000664000175000017500000001141512154360113015554 0ustar matiasmatias#include #include #include #include #include #include "arp.h" #include "utils.h" #include "ip_address.h" using namespace std; using namespace Tins; typedef ARP::hwaddress_type address_type; class ARPTest : public testing::Test { public: static const address_type empty_addr; static const address_type hw_addr1; static const address_type hw_addr2; static const string ip_addr1; static const uint8_t expected_packet[]; static const IPv4Address addr1, addr2; void test_equals(const ARP &arp1, const ARP &arp2); }; const address_type ARPTest::empty_addr; const address_type ARPTest::hw_addr1("13:da:de:f1:01:85"); const address_type ARPTest::hw_addr2("7a:1f:f4:39:ab:0d"); const uint8_t ARPTest::expected_packet[] = { 0, 1, 8, 0, 6, 4, 0, 2, 3, 222, 245, 18, 9, 250, 192, 168, 45, 231, 245, 18, 218, 103, 189, 13, 32, 155, 81, 254 }; const IPv4Address ARPTest::addr1(0x1234), ARPTest::addr2(0xa3f1); void ARPTest::test_equals(const ARP &arp1, const ARP &arp2) { EXPECT_EQ(arp1.opcode(), arp2.opcode()); ASSERT_EQ(arp1.hw_addr_length(), arp2.hw_addr_length()); EXPECT_EQ(arp1.hw_addr_format(), arp2.hw_addr_format()); ASSERT_EQ(arp1.prot_addr_length(), arp2.prot_addr_length()); EXPECT_EQ(arp1.prot_addr_format(), arp2.prot_addr_format()); EXPECT_EQ(arp1.sender_ip_addr(), arp2.sender_ip_addr()); EXPECT_EQ(arp1.target_ip_addr(), arp2.target_ip_addr()); EXPECT_EQ(arp1.sender_hw_addr(), arp2.sender_hw_addr()); EXPECT_EQ(arp1.target_hw_addr(), arp2.target_hw_addr()); EXPECT_EQ((bool)arp1.inner_pdu(), (bool)arp2.inner_pdu()); } TEST_F(ARPTest, DefaultContructor) { ARP arp; EXPECT_EQ(arp.target_ip_addr(), IPv4Address()); EXPECT_EQ(arp.sender_ip_addr(), IPv4Address()); EXPECT_EQ(arp.target_hw_addr(), empty_addr); EXPECT_EQ(arp.target_hw_addr(), empty_addr); EXPECT_EQ(arp.pdu_type(), PDU::ARP); } TEST_F(ARPTest, CopyContructor) { ARP arp1(addr1, addr2, hw_addr1, hw_addr2); ARP arp2(arp1); test_equals(arp1, arp2); } TEST_F(ARPTest, CopyAssignmentOperator) { ARP arp1(addr1, addr2, hw_addr1, hw_addr2); ARP arp2 = arp1; test_equals(arp1, arp2); } TEST_F(ARPTest, NestedCopy) { ARP *nested_arp = new ARP(addr1, addr2, hw_addr1, hw_addr2); ARP arp1(addr1, addr2, hw_addr1, hw_addr2); arp1.inner_pdu(nested_arp); ARP arp2(arp1); test_equals(arp1, arp2); } TEST_F(ARPTest, CompleteContructor) { ARP arp(addr1, addr2, hw_addr1, hw_addr2); EXPECT_EQ(arp.target_hw_addr(), hw_addr1); EXPECT_EQ(arp.sender_hw_addr(), hw_addr2); EXPECT_EQ(arp.target_ip_addr(), addr1); EXPECT_EQ(arp.sender_ip_addr(), addr2); } TEST_F(ARPTest, SenderIPAddrInt) { ARP arp; arp.sender_ip_addr(addr1); EXPECT_EQ(arp.sender_ip_addr(), addr1); } TEST_F(ARPTest, TargetIPAddrInt) { ARP arp; arp.target_ip_addr(addr1); EXPECT_EQ(arp.target_ip_addr(), addr1); } TEST_F(ARPTest, TargetHWAddr) { ARP arp; arp.target_hw_addr(hw_addr1); EXPECT_EQ(arp.target_hw_addr(), hw_addr1); } TEST_F(ARPTest, SenderHWAddr) { ARP arp; arp.sender_hw_addr(hw_addr1); EXPECT_EQ(arp.sender_hw_addr(), hw_addr1); } TEST_F(ARPTest, ProtAddrFormat) { ARP arp; arp.prot_addr_format(0x45fa); EXPECT_EQ(arp.prot_addr_format(), 0x45fa); } TEST_F(ARPTest, ProtAddrLength) { ARP arp; arp.prot_addr_length(0x4f); EXPECT_EQ(arp.prot_addr_length(), 0x4f); } TEST_F(ARPTest, HWAddrFormat) { ARP arp; arp.hw_addr_format(0x45fa); EXPECT_EQ(arp.hw_addr_format(), 0x45fa); } TEST_F(ARPTest, HWAddrLength) { ARP arp; arp.hw_addr_length(0xd1); EXPECT_EQ(arp.hw_addr_length(), 0xd1); } TEST_F(ARPTest, Opcode) { ARP arp; arp.opcode(ARP::REQUEST); EXPECT_EQ(arp.opcode(), ARP::REQUEST); } TEST_F(ARPTest, Serialize) { ARP arp1("192.168.0.1", "192.168.0.100", hw_addr1, hw_addr2); PDU::serialization_type buffer = arp1.serialize(); ARP arp2(arp1); PDU::serialization_type buffer2 = arp2.serialize(); EXPECT_EQ(buffer, buffer2); } TEST_F(ARPTest, ConstructorFromBuffer) { ARP arp1(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = arp1.serialize(); ARP arp2(&buffer[0], buffer.size()); EXPECT_EQ(arp1.opcode(), arp2.opcode()); ASSERT_EQ(arp1.hw_addr_length(), arp2.hw_addr_length()); EXPECT_EQ(arp1.hw_addr_format(), arp2.hw_addr_format()); ASSERT_EQ(arp1.prot_addr_length(), arp2.prot_addr_length()); EXPECT_EQ(arp1.prot_addr_format(), arp2.prot_addr_format()); EXPECT_EQ(arp1.sender_ip_addr(), arp2.sender_ip_addr()); EXPECT_EQ(arp1.target_ip_addr(), arp2.target_ip_addr()); EXPECT_EQ(arp1.sender_hw_addr(), arp2.sender_hw_addr()); EXPECT_EQ(arp1.target_hw_addr(), arp2.target_hw_addr()); } libtins-1.1/tests/include/0000775000175000017500000000000012154360113015120 5ustar matiasmatiaslibtins-1.1/tests/include/tests/0000775000175000017500000000000012154360113016262 5ustar matiasmatiaslibtins-1.1/tests/include/tests/dot11_mgmt.h0000664000175000017500000000630212154360113020410 0ustar matiasmatias#ifndef TINS_DOT11_MGMT_TEST_H #define TINS_DOT11_MGMT_TEST_H #include "tests/dot11.h" #include "dot11/dot11_mgmt.h" using Tins::Dot11ManagementFrame; typedef Dot11ManagementFrame::capability_information capability_information; inline void test_equals(const Dot11ManagementFrame& b1, const Dot11ManagementFrame& b2) { EXPECT_EQ(b1.addr2(), b2.addr2()); EXPECT_EQ(b1.addr3(), b2.addr3()); EXPECT_EQ(b1.addr4(), b2.addr4()); EXPECT_EQ(b1.frag_num(), b2.frag_num()); EXPECT_EQ(b1.seq_num(), b2.seq_num()); test_equals(static_cast(b1), static_cast(b2)); } inline void test_equals_expected(const Dot11ManagementFrame &dot11) { EXPECT_EQ(dot11.protocol(), 1); EXPECT_EQ(dot11.type(), Dot11::MANAGEMENT); EXPECT_EQ(dot11.to_ds(), 1); EXPECT_EQ(dot11.from_ds(), 0); EXPECT_EQ(dot11.more_frag(), 0); EXPECT_EQ(dot11.retry(), 0); EXPECT_EQ(dot11.power_mgmt(), 0); EXPECT_EQ(dot11.wep(), 0); EXPECT_EQ(dot11.order(), 0); EXPECT_EQ(dot11.duration_id(), 0x234f); EXPECT_EQ(dot11.addr1(), "00:01:02:03:04:05"); EXPECT_EQ(dot11.addr2(), "01:02:03:04:05:06"); EXPECT_EQ(dot11.addr3(), "02:03:04:05:06:07"); } inline void test_equals_empty(const Dot11ManagementFrame &dot11) { Dot11::address_type empty_addr; EXPECT_EQ(dot11.type(), Dot11::MANAGEMENT); EXPECT_EQ(dot11.addr2(), empty_addr); EXPECT_EQ(dot11.addr3(), empty_addr); EXPECT_EQ(dot11.addr4(), empty_addr); EXPECT_EQ(dot11.frag_num(), 0); EXPECT_EQ(dot11.seq_num(), 0); test_equals_empty(static_cast(dot11)); } inline void test_equals(const capability_information &info1, const capability_information &info2) { EXPECT_EQ(info1.ess(), info2.ess()); EXPECT_EQ(info1.ibss(), info2.ibss()); EXPECT_EQ(info1.cf_poll(), info2.cf_poll()); EXPECT_EQ(info1.cf_poll_req(), info2.cf_poll_req()); EXPECT_EQ(info1.privacy(), info2.privacy()); EXPECT_EQ(info1.short_preamble(), info2.short_preamble()); EXPECT_EQ(info1.pbcc(), info2.pbcc()); EXPECT_EQ(info1.channel_agility(), info2.channel_agility()); EXPECT_EQ(info1.spectrum_mgmt(), info2.spectrum_mgmt()); EXPECT_EQ(info1.qos(), info2.qos()); EXPECT_EQ(info1.sst(), info2.sst()); EXPECT_EQ(info1.apsd(), info2.apsd()); EXPECT_EQ(info1.reserved(), info2.reserved()); EXPECT_EQ(info1.dsss_ofdm(), info2.dsss_ofdm()); EXPECT_EQ(info1.delayed_block_ack(), info2.delayed_block_ack()); EXPECT_EQ(info1.immediate_block_ack(), info2.immediate_block_ack()); } inline void test_equals_empty(const capability_information &info) { EXPECT_EQ(info.ess(), 0); EXPECT_EQ(info.ibss(), 0); EXPECT_EQ(info.cf_poll(), 0); EXPECT_EQ(info.cf_poll_req(), 0); EXPECT_EQ(info.privacy(), 0); EXPECT_EQ(info.short_preamble(), 0); EXPECT_EQ(info.pbcc(), 0); EXPECT_EQ(info.channel_agility(), 0); EXPECT_EQ(info.spectrum_mgmt(), 0); EXPECT_EQ(info.qos(), 0); EXPECT_EQ(info.sst(), 0); EXPECT_EQ(info.apsd(), 0); EXPECT_EQ(info.reserved(), 0); EXPECT_EQ(info.dsss_ofdm(), 0); EXPECT_EQ(info.delayed_block_ack(), 0); EXPECT_EQ(info.immediate_block_ack(), 0); } #endif // TINS_DOT11_MGMT_TEST_H libtins-1.1/tests/include/tests/dot11_data.h0000664000175000017500000000221712154360113020356 0ustar matiasmatias#ifndef TINS_TEST_DOT11_DATA_H #define TINS_TEST_DOT11_DATA_H #include "tests/dot11.h" #include "dot11/dot11_data.h" using Tins::Dot11Data; inline void test_equals(const Dot11Data& b1, const Dot11Data& b2) { EXPECT_EQ(b1.addr2(), b2.addr2()); EXPECT_EQ(b1.addr3(), b2.addr3()); EXPECT_EQ(b1.addr4(), b2.addr4()); EXPECT_EQ(b1.frag_num(), b2.frag_num()); EXPECT_EQ(b1.seq_num(), b2.seq_num()); test_equals(static_cast(b1), static_cast(b2)); } inline void test_equals_expected(const Dot11Data &dot11) { EXPECT_EQ(dot11.type(), Dot11::DATA); EXPECT_EQ(dot11.addr1(), "00:01:02:03:04:05"); EXPECT_EQ(dot11.addr2(), "01:02:03:04:05:06"); EXPECT_EQ(dot11.addr3(), "02:03:04:05:06:07"); EXPECT_EQ(dot11.frag_num(), 0xa); EXPECT_EQ(dot11.seq_num(), 0xf1d); } inline void test_equals_empty(const Dot11Data &dot11) { Dot11::address_type empty_addr; EXPECT_EQ(dot11.addr1(), empty_addr); EXPECT_EQ(dot11.addr2(), empty_addr); EXPECT_EQ(dot11.addr3(), empty_addr); EXPECT_EQ(dot11.frag_num(), 0); EXPECT_EQ(dot11.seq_num(), 0); } #endif // TINS_TEST_DOT11_DATA_H libtins-1.1/tests/include/tests/dot11_control.h0000664000175000017500000000140712154360113021125 0ustar matiasmatias#ifndef TINS_TEST_DOT11_CONTROL_H #define TINS_TEST_DOT11_CONTROL_H #include "tests/dot11.h" #include "dot11/dot11_control.h" using Tins::Dot11ControlTA; inline void test_equals(const Dot11ControlTA& b1, const Dot11ControlTA& b2) { EXPECT_EQ(b1.target_addr(), b2.target_addr()); test_equals(static_cast(b1), static_cast(b2)); } inline void test_equals_expected(const Dot11ControlTA &dot11) { EXPECT_EQ(dot11.target_addr(), "01:02:03:04:05:06"); EXPECT_EQ(dot11.addr1(), "00:01:02:03:04:05"); } inline void test_equals_empty(const Dot11ControlTA &dot11) { Dot11::address_type empty_addr; EXPECT_EQ(dot11.target_addr(), empty_addr); EXPECT_EQ(dot11.addr1(), empty_addr); } #endif // TINS_TEST_DOT11_CONTROL_H libtins-1.1/tests/include/tests/dot11.h0000664000175000017500000000233412154360113017365 0ustar matiasmatias#ifndef TINS_DOT11_TEST #define TINS_DOT11_TEST #include "dot11/dot11_base.h" using Tins::Dot11; typedef Dot11::address_type address_type; inline void test_equals(const Dot11 &dot1, const Dot11 &dot2) { EXPECT_EQ(dot1.protocol(), dot2.protocol()); EXPECT_EQ(dot1.type(), dot2.type()); EXPECT_EQ(dot1.subtype(), dot2.subtype()); EXPECT_EQ(dot1.to_ds(), dot2.to_ds()); EXPECT_EQ(dot1.from_ds(), dot2.from_ds()); EXPECT_EQ(dot1.more_frag(), dot2.more_frag()); EXPECT_EQ(dot1.retry(), dot2.retry()); EXPECT_EQ(dot1.power_mgmt(), dot2.power_mgmt()); EXPECT_EQ(dot1.wep(), dot2.wep()); EXPECT_EQ(dot1.order(), dot2.order()); EXPECT_EQ(dot1.duration_id(), dot2.duration_id()); EXPECT_EQ(dot1.addr1(), dot2.addr1()); } inline void test_equals_empty(const Dot11 &dot11) { Dot11::address_type empty_addr; EXPECT_EQ(dot11.protocol(), 0); EXPECT_EQ(dot11.to_ds(), 0); EXPECT_EQ(dot11.from_ds(), 0); EXPECT_EQ(dot11.more_frag(), 0); EXPECT_EQ(dot11.retry(), 0); EXPECT_EQ(dot11.power_mgmt(), 0); EXPECT_EQ(dot11.wep(), 0); EXPECT_EQ(dot11.order(), 0); EXPECT_EQ(dot11.duration_id(), 0); EXPECT_EQ(dot11.addr1(), empty_addr); } #endif // TINS_DOT11_TEST libtins-1.1/tests/depends.d0000664000175000017500000025253412154360113015277 0ustar matiasmatias../src/arp.o: ../src/arp.cpp ../include/arp.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/hw_address.h ../include/ip_address.h \ ../include/ip.h ../include/small_uint.h ../include/pdu_option.h \ ../include/ethernetII.h ../include/rawpdu.h ../include/constants.h \ ../include/network_interface.h ../include/exceptions.h ../include/arp.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/hw_address.h: ../include/ip_address.h: ../include/ip.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/ethernetII.h: ../include/rawpdu.h: ../include/constants.h: ../include/network_interface.h: ../include/exceptions.h: ../src/bootp.o: ../src/bootp.cpp ../include/bootp.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/ip_address.h ../include/hw_address.h \ ../include/exceptions.h ../include/bootp.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/ip_address.h: ../include/hw_address.h: ../include/exceptions.h: ../src/crypto.o: ../src/crypto.cpp ../include/crypto.h ../include/utils.h \ ../include/macros.h ../include/ip_address.h ../include/cxxstd.h \ ../include/ipv6_address.h ../include/hw_address.h ../include/internals.h \ ../include/constants.h ../include/pdu.h ../include/exceptions.h \ ../include/snap.h ../include/endianness.h ../include/small_uint.h \ ../include/rawpdu.h ../include/handshake_capturer.h ../include/eapol.h \ ../include/config.h ../include/dot11/dot11_data.h \ ../include/dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../macros.h ../include/dot11/dot11_beacon.h \ ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h ../include/crypto.h: ../include/utils.h: ../include/macros.h: ../include/ip_address.h: ../include/cxxstd.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/exceptions.h: ../include/snap.h: ../include/endianness.h: ../include/small_uint.h: ../include/rawpdu.h: ../include/handshake_capturer.h: ../include/eapol.h: ../include/config.h: ../include/dot11/dot11_data.h: ../include/dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../macros.h: ../include/dot11/dot11_beacon.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../src/dhcp.o: ../src/dhcp.cpp ../include/endianness.h \ ../include/macros.h ../include/dhcp.h ../include/bootp.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/ip_address.h ../include/hw_address.h \ ../include/pdu_option.h ../include/ethernetII.h ../include/exceptions.h ../include/endianness.h: ../include/macros.h: ../include/dhcp.h: ../include/bootp.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/ip_address.h: ../include/hw_address.h: ../include/pdu_option.h: ../include/ethernetII.h: ../include/exceptions.h: ../src/dhcpv6.o: ../src/dhcpv6.cpp ../include/dhcpv6.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h \ ../include/ipv6_address.h ../include/pdu_option.h \ ../include/exceptions.h ../include/dhcpv6.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/ipv6_address.h: ../include/pdu_option.h: ../include/exceptions.h: ../src/dns.o: ../src/dns.cpp ../include/dns.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/dns_record.h ../include/ip_address.h \ ../include/ipv6_address.h ../include/exceptions.h ../include/rawpdu.h ../include/dns.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/dns_record.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/exceptions.h: ../include/rawpdu.h: ../src/dns_record.o: ../src/dns_record.cpp ../include/dns_record.h \ ../include/cxxstd.h ../include/macros.h ../include/endianness.h \ ../include/exceptions.h ../include/dns_record.h: ../include/cxxstd.h: ../include/macros.h: ../include/endianness.h: ../include/exceptions.h: ../src/dot11/dot11_assoc.o: ../src/dot11/dot11_assoc.cpp \ ../include/dot11/dot11_assoc.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h ../include/dot11/dot11_assoc.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: ../src/dot11/dot11_auth.o: ../src/dot11/dot11_auth.cpp \ ../include/dot11/dot11_auth.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h ../include/dot11/dot11_auth.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: ../src/dot11/dot11_base.o: ../src/dot11/dot11_base.cpp \ ../include/macros.h ../include/exceptions.h \ ../include/dot11/dot11_base.h ../include/dot11/../pdu.h \ ../include/dot11/../macros.h ../include/dot11/../cxxstd.h \ ../include/dot11/../exceptions.h ../include/dot11/../pdu_option.h \ ../include/dot11/../small_uint.h ../include/dot11/../hw_address.h \ ../include/dot11/../endianness.h ../include/dot11/../cxxstd.h \ ../include/dot11/../macros.h ../include/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_data.h \ ../include/dot11/../dot11/dot11_base.h ../include/dot11/dot11_mgmt.h \ ../include/dot11/dot11_beacon.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/dot11_assoc.h ../include/dot11/dot11_auth.h \ ../include/dot11/dot11_probe.h ../include/dot11/dot11_control.h \ ../include/rawpdu.h ../include/pdu.h ../include/rsn_information.h \ ../include/endianness.h ../include/packet_sender.h \ ../include/network_interface.h ../include/hw_address.h \ ../include/ip_address.h ../include/cxxstd.h ../include/macros.h \ ../include/snap.h ../include/small_uint.h ../include/macros.h: ../include/exceptions.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../macros.h: ../include/dot11/../cxxstd.h: ../include/dot11/../exceptions.h: ../include/dot11/../pdu_option.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_data.h: ../include/dot11/../dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: ../include/dot11/dot11_beacon.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/dot11_assoc.h: ../include/dot11/dot11_auth.h: ../include/dot11/dot11_probe.h: ../include/dot11/dot11_control.h: ../include/rawpdu.h: ../include/pdu.h: ../include/rsn_information.h: ../include/endianness.h: ../include/packet_sender.h: ../include/network_interface.h: ../include/hw_address.h: ../include/ip_address.h: ../include/cxxstd.h: ../include/macros.h: ../include/snap.h: ../include/small_uint.h: ../src/dot11/dot11_beacon.o: ../src/dot11/dot11_beacon.cpp \ ../include/dot11/dot11_beacon.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h ../include/dot11/dot11_beacon.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: ../src/dot11/dot11_control.o: ../src/dot11/dot11_control.cpp \ ../include/dot11/dot11_control.h ../include/dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../pdu.h ../include/dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../macros.h ../include/dot11/dot11_control.h: ../include/dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../macros.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../macros.h: ../src/dot11/dot11_data.o: ../src/dot11/dot11_data.cpp \ ../include/dot11/dot11_data.h ../include/dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../pdu.h ../include/dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../macros.h ../include/rawpdu.h \ ../include/pdu.h ../include/snap.h ../include/macros.h \ ../include/endianness.h ../include/small_uint.h ../include/dot11/dot11_data.h: ../include/dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../macros.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../macros.h: ../include/rawpdu.h: ../include/pdu.h: ../include/snap.h: ../include/macros.h: ../include/endianness.h: ../include/small_uint.h: ../src/dot11/dot11_mgmt.o: ../src/dot11/dot11_mgmt.cpp \ ../include/dot11/dot11_mgmt.h ../include/dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../pdu.h ../include/dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../macros.h ../include/rsn_information.h \ ../include/endianness.h ../include/dot11/dot11_mgmt.h: ../include/dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../macros.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../macros.h: ../include/rsn_information.h: ../include/endianness.h: ../src/dot11/dot11_probe.o: ../src/dot11/dot11_probe.cpp \ ../include/dot11/dot11_probe.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h ../include/dot11/dot11_probe.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: ../src/dot1q.o: ../src/dot1q.cpp ../include/dot1q.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h ../include/internals.h \ ../include/constants.h ../include/exceptions.h ../include/dot1q.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/internals.h: ../include/constants.h: ../include/exceptions.h: ../src/dot3.o: ../src/dot3.cpp ../include/macros.h ../include/dot3.h \ ../include/macros.h ../include/pdu.h ../include/cxxstd.h \ ../include/exceptions.h ../include/endianness.h ../include/hw_address.h \ ../include/packet_sender.h ../include/network_interface.h \ ../include/ip_address.h ../include/llc.h ../include/exceptions.h ../include/macros.h: ../include/dot3.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/hw_address.h: ../include/packet_sender.h: ../include/network_interface.h: ../include/ip_address.h: ../include/llc.h: ../include/exceptions.h: ../src/eapol.o: ../src/eapol.cpp ../include/eapol.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/small_uint.h ../include/endianness.h \ ../include/rsn_information.h ../include/exceptions.h ../include/eapol.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/small_uint.h: ../include/endianness.h: ../include/rsn_information.h: ../include/exceptions.h: ../src/ethernetII.o: ../src/ethernetII.cpp ../include/macros.h \ ../include/ethernetII.h ../include/macros.h ../include/pdu.h \ ../include/cxxstd.h ../include/exceptions.h ../include/endianness.h \ ../include/hw_address.h ../include/packet_sender.h \ ../include/network_interface.h ../include/ip_address.h \ ../include/rawpdu.h ../include/ip.h ../include/small_uint.h \ ../include/pdu_option.h ../include/ipv6.h ../include/ipv6_address.h \ ../include/arp.h ../include/constants.h ../include/internals.h \ ../include/constants.h ../include/exceptions.h ../include/macros.h: ../include/ethernetII.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/hw_address.h: ../include/packet_sender.h: ../include/network_interface.h: ../include/ip_address.h: ../include/rawpdu.h: ../include/ip.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/ipv6.h: ../include/ipv6_address.h: ../include/arp.h: ../include/constants.h: ../include/internals.h: ../include/constants.h: ../include/exceptions.h: ../src/handshake_capturer.o: ../src/handshake_capturer.cpp \ ../include/handshake_capturer.h ../include/hw_address.h \ ../include/cxxstd.h ../include/eapol.h ../include/pdu.h \ ../include/macros.h ../include/exceptions.h ../include/small_uint.h \ ../include/endianness.h ../include/dot11/dot11_data.h \ ../include/dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../macros.h ../include/handshake_capturer.h: ../include/hw_address.h: ../include/cxxstd.h: ../include/eapol.h: ../include/pdu.h: ../include/macros.h: ../include/exceptions.h: ../include/small_uint.h: ../include/endianness.h: ../include/dot11/dot11_data.h: ../include/dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../macros.h: ../src/icmp.o: ../src/icmp.cpp ../include/icmp.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/rawpdu.h ../include/utils.h \ ../include/ip_address.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h \ ../include/exceptions.h ../include/icmp.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/rawpdu.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/exceptions.h: ../src/icmpv6.o: ../src/icmpv6.cpp ../include/icmpv6.h \ ../include/macros.h ../include/pdu.h ../include/cxxstd.h \ ../include/exceptions.h ../include/ipv6_address.h \ ../include/pdu_option.h ../include/endianness.h ../include/small_uint.h \ ../include/hw_address.h ../include/ipv6.h ../include/rawpdu.h \ ../include/utils.h ../include/ip_address.h ../include/internals.h \ ../include/constants.h ../include/constants.h ../include/exceptions.h ../include/icmpv6.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/ipv6_address.h: ../include/pdu_option.h: ../include/endianness.h: ../include/small_uint.h: ../include/hw_address.h: ../include/ipv6.h: ../include/rawpdu.h: ../include/utils.h: ../include/ip_address.h: ../include/internals.h: ../include/constants.h: ../include/constants.h: ../include/exceptions.h: ../src/internals.o: ../src/internals.cpp ../include/internals.h \ ../include/constants.h ../include/pdu.h ../include/macros.h \ ../include/cxxstd.h ../include/exceptions.h ../include/ip.h \ ../include/small_uint.h ../include/endianness.h ../include/ip_address.h \ ../include/pdu_option.h ../include/ethernetII.h ../include/hw_address.h \ ../include/ieee802_3.h ../include/dot3.h ../include/radiotap.h \ ../include/dot11/dot11_base.h ../include/dot11/../pdu.h \ ../include/dot11/../pdu_option.h ../include/dot11/../small_uint.h \ ../include/dot11/../hw_address.h ../include/dot11/../endianness.h \ ../include/dot11/../cxxstd.h ../include/dot11/../macros.h \ ../include/ipv6.h ../include/ipv6_address.h ../include/arp.h \ ../include/eapol.h ../include/rawpdu.h ../include/dot1q.h \ ../include/pppoe.h ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/ip.h: ../include/small_uint.h: ../include/endianness.h: ../include/ip_address.h: ../include/pdu_option.h: ../include/ethernetII.h: ../include/hw_address.h: ../include/ieee802_3.h: ../include/dot3.h: ../include/radiotap.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../pdu_option.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/ipv6.h: ../include/ipv6_address.h: ../include/arp.h: ../include/eapol.h: ../include/rawpdu.h: ../include/dot1q.h: ../include/pppoe.h: ../src/ip.o: ../src/ip.cpp ../include/ip.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/small_uint.h ../include/endianness.h ../include/ip_address.h \ ../include/pdu_option.h ../include/ipv6.h ../include/ipv6_address.h \ ../include/tcp.h ../include/udp.h ../include/icmp.h ../include/rawpdu.h \ ../include/utils.h ../include/hw_address.h ../include/internals.h \ ../include/constants.h ../include/packet_sender.h \ ../include/network_interface.h ../include/constants.h \ ../include/network_interface.h ../include/exceptions.h ../include/ip.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/small_uint.h: ../include/endianness.h: ../include/ip_address.h: ../include/pdu_option.h: ../include/ipv6.h: ../include/ipv6_address.h: ../include/tcp.h: ../include/udp.h: ../include/icmp.h: ../include/rawpdu.h: ../include/utils.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/packet_sender.h: ../include/network_interface.h: ../include/constants.h: ../include/network_interface.h: ../include/exceptions.h: ../src/ip_address.o: ../src/ip_address.cpp ../include/ip_address.h \ ../include/cxxstd.h ../include/endianness.h ../include/macros.h ../include/ip_address.h: ../include/cxxstd.h: ../include/endianness.h: ../include/macros.h: ../src/ipv6.o: ../src/ipv6.cpp ../include/ipv6.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h ../include/pdu_option.h \ ../include/ipv6_address.h ../include/constants.h \ ../include/packet_sender.h ../include/network_interface.h \ ../include/hw_address.h ../include/ip_address.h ../include/ip.h \ ../include/tcp.h ../include/udp.h ../include/icmp.h ../include/icmpv6.h \ ../include/rawpdu.h ../include/exceptions.h ../include/ipv6.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/ipv6_address.h: ../include/constants.h: ../include/packet_sender.h: ../include/network_interface.h: ../include/hw_address.h: ../include/ip_address.h: ../include/ip.h: ../include/tcp.h: ../include/udp.h: ../include/icmp.h: ../include/icmpv6.h: ../include/rawpdu.h: ../include/exceptions.h: ../src/ipv6_address.o: ../src/ipv6_address.cpp ../include/macros.h \ ../include/ipv6_address.h ../include/cxxstd.h ../include/macros.h: ../include/ipv6_address.h: ../include/cxxstd.h: ../src/llc.o: ../src/llc.cpp ../include/llc.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/stp.h ../include/hw_address.h \ ../include/small_uint.h ../include/rawpdu.h ../include/exceptions.h ../include/llc.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/stp.h: ../include/hw_address.h: ../include/small_uint.h: ../include/rawpdu.h: ../include/exceptions.h: ../src/loopback.o: ../src/loopback.cpp ../include/loopback.h \ ../include/pdu.h ../include/macros.h ../include/cxxstd.h \ ../include/exceptions.h ../include/packet_sender.h \ ../include/network_interface.h ../include/hw_address.h \ ../include/ip_address.h ../include/ip.h ../include/small_uint.h \ ../include/endianness.h ../include/pdu_option.h ../include/llc.h \ ../include/rawpdu.h ../include/exceptions.h ../include/loopback.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/packet_sender.h: ../include/network_interface.h: ../include/hw_address.h: ../include/ip_address.h: ../include/ip.h: ../include/small_uint.h: ../include/endianness.h: ../include/pdu_option.h: ../include/llc.h: ../include/rawpdu.h: ../include/exceptions.h: ../src/network_interface.o: ../src/network_interface.cpp \ ../include/macros.h ../include/network_interface.h \ ../include/hw_address.h ../include/cxxstd.h ../include/ip_address.h \ ../include/utils.h ../include/macros.h ../include/ipv6_address.h \ ../include/internals.h ../include/constants.h ../include/pdu.h \ ../include/exceptions.h ../include/endianness.h ../include/macros.h: ../include/network_interface.h: ../include/hw_address.h: ../include/cxxstd.h: ../include/ip_address.h: ../include/utils.h: ../include/macros.h: ../include/ipv6_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/exceptions.h: ../include/endianness.h: ../src/packet_sender.o: ../src/packet_sender.cpp \ ../include/packet_sender.h ../include/network_interface.h \ ../include/hw_address.h ../include/cxxstd.h ../include/ip_address.h \ ../include/macros.h ../include/pdu.h ../include/exceptions.h \ ../include/macros.h ../include/network_interface.h \ ../include/ethernetII.h ../include/pdu.h ../include/endianness.h \ ../include/radiotap.h ../include/dot11/dot11_base.h \ ../include/dot11/../pdu.h ../include/dot11/../pdu_option.h \ ../include/dot11/../exceptions.h ../include/dot11/../small_uint.h \ ../include/dot11/../hw_address.h ../include/dot11/../endianness.h \ ../include/dot11/../cxxstd.h ../include/dot11/../macros.h \ ../include/ieee802_3.h ../include/dot3.h ../include/internals.h \ ../include/constants.h ../include/packet_sender.h: ../include/network_interface.h: ../include/hw_address.h: ../include/cxxstd.h: ../include/ip_address.h: ../include/macros.h: ../include/pdu.h: ../include/exceptions.h: ../include/macros.h: ../include/network_interface.h: ../include/ethernetII.h: ../include/pdu.h: ../include/endianness.h: ../include/radiotap.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../pdu_option.h: ../include/dot11/../exceptions.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/ieee802_3.h: ../include/dot3.h: ../include/internals.h: ../include/constants.h: ../src/packet_writer.o: ../src/packet_writer.cpp \ ../include/packet_writer.h ../include/utils.h ../include/macros.h \ ../include/ip_address.h ../include/cxxstd.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h \ ../include/pdu.h ../include/exceptions.h ../include/pdu.h ../include/packet_writer.h: ../include/utils.h: ../include/macros.h: ../include/ip_address.h: ../include/cxxstd.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/exceptions.h: ../include/pdu.h: ../src/pdu.o: ../src/pdu.cpp ../include/pdu.h ../include/macros.h \ ../include/cxxstd.h ../include/exceptions.h ../include/rawpdu.h \ ../include/pdu.h ../include/packet_sender.h \ ../include/network_interface.h ../include/hw_address.h \ ../include/ip_address.h ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/rawpdu.h: ../include/pdu.h: ../include/packet_sender.h: ../include/network_interface.h: ../include/hw_address.h: ../include/ip_address.h: ../src/pppoe.o: ../src/pppoe.cpp ../include/pppoe.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h ../include/pdu_option.h \ ../include/exceptions.h ../include/pppoe.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/exceptions.h: ../src/radiotap.o: ../src/radiotap.cpp ../include/macros.h \ ../include/radiotap.h ../include/macros.h ../include/pdu.h \ ../include/cxxstd.h ../include/exceptions.h ../include/endianness.h \ ../include/dot11/dot11_base.h ../include/dot11/../pdu.h \ ../include/dot11/../pdu_option.h ../include/dot11/../exceptions.h \ ../include/dot11/../small_uint.h ../include/dot11/../hw_address.h \ ../include/dot11/../cxxstd.h ../include/dot11/../endianness.h \ ../include/dot11/../cxxstd.h ../include/dot11/../macros.h \ ../include/utils.h ../include/ip_address.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h \ ../include/packet_sender.h ../include/network_interface.h \ ../include/exceptions.h ../include/macros.h: ../include/radiotap.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../pdu_option.h: ../include/dot11/../exceptions.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../cxxstd.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/packet_sender.h: ../include/network_interface.h: ../include/exceptions.h: ../src/rawpdu.o: ../src/rawpdu.cpp ../include/rawpdu.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h ../include/rawpdu.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../src/rsn_information.o: ../src/rsn_information.cpp \ ../include/rsn_information.h ../include/endianness.h ../include/macros.h \ ../include/exceptions.h ../include/rsn_information.h: ../include/endianness.h: ../include/macros.h: ../include/exceptions.h: ../src/sll.o: ../src/sll.cpp ../include/sll.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/hw_address.h ../include/internals.h \ ../include/constants.h ../include/exceptions.h ../include/sll.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/exceptions.h: ../src/snap.o: ../src/snap.cpp ../include/snap.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h ../include/constants.h \ ../include/arp.h ../include/hw_address.h ../include/ip_address.h \ ../include/ip.h ../include/pdu_option.h ../include/eapol.h \ ../include/internals.h ../include/constants.h ../include/exceptions.h ../include/snap.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/constants.h: ../include/arp.h: ../include/hw_address.h: ../include/ip_address.h: ../include/ip.h: ../include/pdu_option.h: ../include/eapol.h: ../include/internals.h: ../include/constants.h: ../include/exceptions.h: ../src/sniffer.o: ../src/sniffer.cpp ../include/sniffer.h \ ../include/pdu.h ../include/macros.h ../include/cxxstd.h \ ../include/exceptions.h ../include/ethernetII.h ../include/endianness.h \ ../include/hw_address.h ../include/radiotap.h ../include/packet.h \ ../include/timestamp.h ../include/loopback.h \ ../include/dot11/dot11_base.h ../include/dot11/../pdu.h \ ../include/dot11/../pdu_option.h ../include/dot11/../exceptions.h \ ../include/dot11/../small_uint.h ../include/dot11/../hw_address.h \ ../include/dot11/../endianness.h ../include/dot11/../cxxstd.h \ ../include/dot11/../macros.h ../include/dot3.h ../include/sll.h ../include/sniffer.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/ethernetII.h: ../include/endianness.h: ../include/hw_address.h: ../include/radiotap.h: ../include/packet.h: ../include/timestamp.h: ../include/loopback.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../pdu_option.h: ../include/dot11/../exceptions.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/dot3.h: ../include/sll.h: ../src/stp.o: ../src/stp.cpp ../include/stp.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/hw_address.h ../include/small_uint.h \ ../include/exceptions.h ../include/stp.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/hw_address.h: ../include/small_uint.h: ../include/exceptions.h: ../src/tcp.o: ../src/tcp.cpp ../include/tcp.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h ../include/pdu_option.h \ ../include/ip.h ../include/ip_address.h ../include/ipv6.h \ ../include/ipv6_address.h ../include/constants.h ../include/rawpdu.h \ ../include/utils.h ../include/hw_address.h ../include/internals.h \ ../include/constants.h ../include/exceptions.h ../include/tcp.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/ip.h: ../include/ip_address.h: ../include/ipv6.h: ../include/ipv6_address.h: ../include/constants.h: ../include/rawpdu.h: ../include/utils.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/exceptions.h: ../src/tcp_stream.o: ../src/tcp_stream.cpp ../include/rawpdu.h \ ../include/pdu.h ../include/macros.h ../include/cxxstd.h \ ../include/exceptions.h ../include/tcp_stream.h ../include/sniffer.h \ ../include/ethernetII.h ../include/endianness.h ../include/hw_address.h \ ../include/radiotap.h ../include/packet.h ../include/timestamp.h \ ../include/loopback.h ../include/dot11/dot11_base.h \ ../include/dot11/../pdu.h ../include/dot11/../pdu_option.h \ ../include/dot11/../exceptions.h ../include/dot11/../small_uint.h \ ../include/dot11/../hw_address.h ../include/dot11/../endianness.h \ ../include/dot11/../cxxstd.h ../include/dot11/../macros.h \ ../include/dot3.h ../include/sll.h ../include/tcp.h \ ../include/small_uint.h ../include/pdu_option.h ../include/utils.h \ ../include/ip_address.h ../include/ipv6_address.h ../include/internals.h \ ../include/constants.h ../include/ip.h ../include/rawpdu.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/tcp_stream.h: ../include/sniffer.h: ../include/ethernetII.h: ../include/endianness.h: ../include/hw_address.h: ../include/radiotap.h: ../include/packet.h: ../include/timestamp.h: ../include/loopback.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../pdu_option.h: ../include/dot11/../exceptions.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/dot3.h: ../include/sll.h: ../include/tcp.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/internals.h: ../include/constants.h: ../include/ip.h: ../src/udp.o: ../src/udp.cpp ../include/udp.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/constants.h ../include/utils.h \ ../include/ip_address.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h \ ../include/ip.h ../include/small_uint.h ../include/pdu_option.h \ ../include/ipv6.h ../include/rawpdu.h ../include/exceptions.h ../include/udp.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/constants.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/ip.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/ipv6.h: ../include/rawpdu.h: ../include/exceptions.h: ../src/utils.o: ../src/utils.cpp ../include/utils.h ../include/macros.h \ ../include/ip_address.h ../include/cxxstd.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h \ ../include/pdu.h ../include/exceptions.h ../include/pdu.h \ ../include/arp.h ../include/endianness.h ../include/ethernetII.h \ ../include/endianness.h ../include/network_interface.h \ ../include/packet_sender.h ../include/network_interface.h \ ../include/cxxstd.h ../include/utils.h: ../include/macros.h: ../include/ip_address.h: ../include/cxxstd.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/exceptions.h: ../include/pdu.h: ../include/arp.h: ../include/endianness.h: ../include/ethernetII.h: ../include/endianness.h: ../include/network_interface.h: ../include/packet_sender.h: ../include/network_interface.h: ../include/cxxstd.h: src/arp.o: src/arp.cpp ../include/arp.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/hw_address.h ../include/ip_address.h \ ../include/utils.h ../include/ipv6_address.h ../include/internals.h \ ../include/constants.h ../include/ip_address.h ../include/arp.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/hw_address.h: ../include/ip_address.h: ../include/utils.h: ../include/ipv6_address.h: ../include/internals.h: ../include/constants.h: ../include/ip_address.h: src/dhcp.o: src/dhcp.cpp ../include/dhcp.h ../include/bootp.h \ ../include/pdu.h ../include/macros.h ../include/cxxstd.h \ ../include/exceptions.h ../include/endianness.h ../include/ip_address.h \ ../include/hw_address.h ../include/pdu_option.h ../include/utils.h \ ../include/ipv6_address.h ../include/internals.h ../include/constants.h \ ../include/ethernetII.h ../include/hw_address.h ../include/ip_address.h ../include/dhcp.h: ../include/bootp.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/ip_address.h: ../include/hw_address.h: ../include/pdu_option.h: ../include/utils.h: ../include/ipv6_address.h: ../include/internals.h: ../include/constants.h: ../include/ethernetII.h: ../include/hw_address.h: ../include/ip_address.h: src/dhcpv6.o: src/dhcpv6.cpp ../include/dhcpv6.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h \ ../include/ipv6_address.h ../include/pdu_option.h ../include/dhcpv6.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/ipv6_address.h: ../include/pdu_option.h: src/dns.o: src/dns.cpp ../include/dns.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/dns_record.h \ ../include/ipv6_address.h ../include/utils.h ../include/ip_address.h \ ../include/ipv6_address.h ../include/hw_address.h ../include/internals.h \ ../include/constants.h ../include/dns.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/dns_record.h: ../include/ipv6_address.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: src/dot11/ack.o: src/dot11/ack.cpp ../include/dot11/dot11_control.h \ ../include/dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../pdu.h ../include/dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../macros.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_control.h: ../include/dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../macros.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../macros.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: src/dot11/assoc_request.o: src/dot11/assoc_request.cpp \ ../include/dot11/dot11_assoc.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h \ include/tests/dot11_mgmt.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_mgmt.h ../include/dot11/dot11_assoc.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: include/tests/dot11_mgmt.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: src/dot11/assoc_response.o: src/dot11/assoc_response.cpp \ ../include/dot11/dot11_assoc.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h \ include/tests/dot11_mgmt.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_mgmt.h ../include/dot11/dot11_assoc.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: include/tests/dot11_mgmt.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: src/dot11/authentication.o: src/dot11/authentication.cpp \ ../include/dot11/dot11_auth.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h \ include/tests/dot11_mgmt.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_mgmt.h ../include/dot11/dot11_auth.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: include/tests/dot11_mgmt.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: src/dot11/beacon.o: src/dot11/beacon.cpp ../include/dot11/dot11_beacon.h \ ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/rsn_information.h ../include/endianness.h \ include/tests/dot11_mgmt.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_mgmt.h ../include/dot11/dot11_beacon.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/rsn_information.h: ../include/endianness.h: include/tests/dot11_mgmt.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: src/dot11/block_ack_request.o: src/dot11/block_ack_request.cpp \ ../include/dot11/dot11_control.h ../include/dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../pdu.h ../include/dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../macros.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_control.h: ../include/dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../macros.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../macros.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: src/dot11/cfend.o: src/dot11/cfend.cpp include/tests/dot11_control.h \ include/tests/dot11.h ../include/dot11/dot11_base.h \ ../include/dot11/../pdu.h ../include/dot11/../macros.h \ ../include/dot11/../cxxstd.h ../include/dot11/../exceptions.h \ ../include/dot11/../pdu_option.h ../include/dot11/../small_uint.h \ ../include/dot11/../hw_address.h ../include/dot11/../endianness.h \ ../include/dot11/../cxxstd.h ../include/dot11/../macros.h \ ../include/dot11/dot11_control.h ../include/dot11/../dot11/dot11_base.h include/tests/dot11_control.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../macros.h: ../include/dot11/../cxxstd.h: ../include/dot11/../exceptions.h: ../include/dot11/../pdu_option.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/dot11/dot11_control.h: ../include/dot11/../dot11/dot11_base.h: src/dot11/cfendack.o: src/dot11/cfendack.cpp \ include/tests/dot11_control.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/../pdu.h \ ../include/dot11/../macros.h ../include/dot11/../cxxstd.h \ ../include/dot11/../exceptions.h ../include/dot11/../pdu_option.h \ ../include/dot11/../small_uint.h ../include/dot11/../hw_address.h \ ../include/dot11/../endianness.h ../include/dot11/../cxxstd.h \ ../include/dot11/../macros.h ../include/dot11/dot11_control.h \ ../include/dot11/../dot11/dot11_base.h include/tests/dot11_control.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../macros.h: ../include/dot11/../cxxstd.h: ../include/dot11/../exceptions.h: ../include/dot11/../pdu_option.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/dot11/dot11_control.h: ../include/dot11/../dot11/dot11_base.h: src/dot11/data.o: src/dot11/data.cpp include/tests/dot11_data.h \ include/tests/dot11.h ../include/dot11/dot11_base.h \ ../include/dot11/../pdu.h ../include/dot11/../macros.h \ ../include/dot11/../cxxstd.h ../include/dot11/../exceptions.h \ ../include/dot11/../pdu_option.h ../include/dot11/../small_uint.h \ ../include/dot11/../hw_address.h ../include/dot11/../endianness.h \ ../include/dot11/../cxxstd.h ../include/dot11/../macros.h \ ../include/dot11/dot11_data.h ../include/dot11/../dot11/dot11_base.h include/tests/dot11_data.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../macros.h: ../include/dot11/../cxxstd.h: ../include/dot11/../exceptions.h: ../include/dot11/../pdu_option.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/dot11/dot11_data.h: ../include/dot11/../dot11/dot11_base.h: src/dot11/deauthentication.o: src/dot11/deauthentication.cpp \ ../include/dot11/dot11_auth.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h \ include/tests/dot11_mgmt.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_mgmt.h ../include/dot11/dot11_auth.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: include/tests/dot11_mgmt.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: src/dot11/disassoc.o: src/dot11/disassoc.cpp \ ../include/dot11/dot11_assoc.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h \ include/tests/dot11_mgmt.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_mgmt.h ../include/dot11/dot11_assoc.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: include/tests/dot11_mgmt.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: src/dot11/dot11.o: src/dot11/dot11.cpp include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/../pdu.h \ ../include/dot11/../macros.h ../include/dot11/../cxxstd.h \ ../include/dot11/../exceptions.h ../include/dot11/../pdu_option.h \ ../include/dot11/../small_uint.h ../include/dot11/../hw_address.h \ ../include/dot11/../endianness.h ../include/dot11/../cxxstd.h \ ../include/dot11/../macros.h ../include/utils.h ../include/macros.h \ ../include/ip_address.h ../include/cxxstd.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h \ ../include/pdu.h include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../macros.h: ../include/dot11/../cxxstd.h: ../include/dot11/../exceptions.h: ../include/dot11/../pdu_option.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/utils.h: ../include/macros.h: ../include/ip_address.h: ../include/cxxstd.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: src/dot11/probe_request.o: src/dot11/probe_request.cpp \ ../include/dot11/dot11_probe.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h \ include/tests/dot11_mgmt.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_mgmt.h ../include/dot11/dot11_probe.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: include/tests/dot11_mgmt.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: src/dot11/probe_response.o: src/dot11/probe_response.cpp \ ../include/dot11/dot11_probe.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h \ include/tests/dot11_mgmt.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_mgmt.h ../include/dot11/dot11_probe.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: include/tests/dot11_mgmt.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: src/dot11/pspoll.o: src/dot11/pspoll.cpp include/tests/dot11_control.h \ include/tests/dot11.h ../include/dot11/dot11_base.h \ ../include/dot11/../pdu.h ../include/dot11/../macros.h \ ../include/dot11/../cxxstd.h ../include/dot11/../exceptions.h \ ../include/dot11/../pdu_option.h ../include/dot11/../small_uint.h \ ../include/dot11/../hw_address.h ../include/dot11/../endianness.h \ ../include/dot11/../cxxstd.h ../include/dot11/../macros.h \ ../include/dot11/dot11_control.h ../include/dot11/../dot11/dot11_base.h include/tests/dot11_control.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../macros.h: ../include/dot11/../cxxstd.h: ../include/dot11/../exceptions.h: ../include/dot11/../pdu_option.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/dot11/dot11_control.h: ../include/dot11/../dot11/dot11_base.h: src/dot11/reassoc_request.o: src/dot11/reassoc_request.cpp \ ../include/dot11/dot11_assoc.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h \ include/tests/dot11_mgmt.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_mgmt.h ../include/dot11/dot11_assoc.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: include/tests/dot11_mgmt.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: src/dot11/reassoc_response.o: src/dot11/reassoc_response.cpp \ ../include/dot11/dot11_assoc.h ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../dot11/../macros.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../dot11/../macros.h \ include/tests/dot11_mgmt.h include/tests/dot11.h \ ../include/dot11/dot11_base.h ../include/dot11/dot11_mgmt.h ../include/dot11/dot11_assoc.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../dot11/../macros.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../dot11/../macros.h: include/tests/dot11_mgmt.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/dot11_mgmt.h: src/dot11/rts.o: src/dot11/rts.cpp include/tests/dot11_control.h \ include/tests/dot11.h ../include/dot11/dot11_base.h \ ../include/dot11/../pdu.h ../include/dot11/../macros.h \ ../include/dot11/../cxxstd.h ../include/dot11/../exceptions.h \ ../include/dot11/../pdu_option.h ../include/dot11/../small_uint.h \ ../include/dot11/../hw_address.h ../include/dot11/../endianness.h \ ../include/dot11/../cxxstd.h ../include/dot11/../macros.h \ ../include/dot11/dot11_control.h ../include/dot11/../dot11/dot11_base.h include/tests/dot11_control.h: include/tests/dot11.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../macros.h: ../include/dot11/../cxxstd.h: ../include/dot11/../exceptions.h: ../include/dot11/../pdu_option.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/dot11/dot11_control.h: ../include/dot11/../dot11/dot11_base.h: src/dot1q.o: src/dot1q.cpp ../include/dot1q.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h ../include/arp.h \ ../include/hw_address.h ../include/ip_address.h ../include/ethernetII.h ../include/dot1q.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/arp.h: ../include/hw_address.h: ../include/ip_address.h: ../include/ethernetII.h: src/ethernetII.o: src/ethernetII.cpp ../include/ethernetII.h \ ../include/macros.h ../include/pdu.h ../include/cxxstd.h \ ../include/exceptions.h ../include/endianness.h ../include/hw_address.h \ ../include/utils.h ../include/ip_address.h ../include/ipv6_address.h \ ../include/internals.h ../include/constants.h ../include/macros.h \ ../include/ipv6.h ../include/small_uint.h ../include/pdu_option.h \ ../include/ip.h ../include/ethernetII.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/hw_address.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/internals.h: ../include/constants.h: ../include/macros.h: ../include/ipv6.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/ip.h: src/hwaddress.o: src/hwaddress.cpp ../include/hw_address.h \ ../include/cxxstd.h ../include/hw_address.h: ../include/cxxstd.h: src/icmp.o: src/icmp.cpp ../include/icmp.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/utils.h ../include/ip_address.h \ ../include/ipv6_address.h ../include/hw_address.h ../include/internals.h \ ../include/constants.h ../include/icmp.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: src/icmpv6.o: src/icmpv6.cpp ../include/icmpv6.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/ipv6_address.h ../include/pdu_option.h \ ../include/endianness.h ../include/small_uint.h ../include/hw_address.h \ ../include/ip.h ../include/ip_address.h ../include/tcp.h \ ../include/utils.h ../include/internals.h ../include/constants.h \ ../include/hw_address.h ../include/icmpv6.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/ipv6_address.h: ../include/pdu_option.h: ../include/endianness.h: ../include/small_uint.h: ../include/hw_address.h: ../include/ip.h: ../include/ip_address.h: ../include/tcp.h: ../include/utils.h: ../include/internals.h: ../include/constants.h: ../include/hw_address.h: src/ip.o: src/ip.cpp ../include/ip.h ../include/pdu.h ../include/macros.h \ ../include/cxxstd.h ../include/exceptions.h ../include/small_uint.h \ ../include/endianness.h ../include/ip_address.h ../include/pdu_option.h \ ../include/tcp.h ../include/udp.h ../include/icmp.h \ ../include/ip_address.h ../include/utils.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h ../include/ip.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/small_uint.h: ../include/endianness.h: ../include/ip_address.h: ../include/pdu_option.h: ../include/tcp.h: ../include/udp.h: ../include/icmp.h: ../include/ip_address.h: ../include/utils.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: src/ipaddress.o: src/ipaddress.cpp ../include/ip_address.h \ ../include/cxxstd.h ../include/utils.h ../include/macros.h \ ../include/ip_address.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h \ ../include/pdu.h ../include/exceptions.h ../include/ip_address.h: ../include/cxxstd.h: ../include/utils.h: ../include/macros.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/exceptions.h: src/ipv6.o: src/ipv6.cpp ../include/ipv6.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h ../include/pdu_option.h \ ../include/ipv6_address.h ../include/tcp.h ../include/udp.h \ ../include/icmp.h ../include/icmpv6.h ../include/hw_address.h \ ../include/ipv6_address.h ../include/utils.h ../include/ip_address.h \ ../include/internals.h ../include/constants.h ../include/ipv6.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/ipv6_address.h: ../include/tcp.h: ../include/udp.h: ../include/icmp.h: ../include/icmpv6.h: ../include/hw_address.h: ../include/ipv6_address.h: ../include/utils.h: ../include/ip_address.h: ../include/internals.h: ../include/constants.h: src/ipv6address.o: src/ipv6address.cpp ../include/ipv6_address.h \ ../include/cxxstd.h ../include/utils.h ../include/macros.h \ ../include/ip_address.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h \ ../include/pdu.h ../include/exceptions.h ../include/ipv6_address.h: ../include/cxxstd.h: ../include/utils.h: ../include/macros.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/exceptions.h: src/llc.o: src/llc.cpp ../include/llc.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/llc.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: src/main.o: src/main.cpp src/matches_response.o: src/matches_response.cpp ../include/ethernetII.h \ ../include/macros.h ../include/pdu.h ../include/cxxstd.h \ ../include/exceptions.h ../include/endianness.h ../include/hw_address.h \ ../include/rawpdu.h ../include/udp.h ../include/dhcp.h \ ../include/bootp.h ../include/ip_address.h ../include/pdu_option.h \ ../include/dhcpv6.h ../include/small_uint.h ../include/ipv6_address.h ../include/ethernetII.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/hw_address.h: ../include/rawpdu.h: ../include/udp.h: ../include/dhcp.h: ../include/bootp.h: ../include/ip_address.h: ../include/pdu_option.h: ../include/dhcpv6.h: ../include/small_uint.h: ../include/ipv6_address.h: src/network_interface.o: src/network_interface.cpp \ ../include/network_interface.h ../include/hw_address.h \ ../include/cxxstd.h ../include/ip_address.h ../include/utils.h \ ../include/macros.h ../include/ipv6_address.h ../include/internals.h \ ../include/constants.h ../include/pdu.h ../include/exceptions.h \ ../include/macros.h ../include/network_interface.h: ../include/hw_address.h: ../include/cxxstd.h: ../include/ip_address.h: ../include/utils.h: ../include/macros.h: ../include/ipv6_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/exceptions.h: ../include/macros.h: src/pdu.o: src/pdu.cpp ../include/ip.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/small_uint.h ../include/endianness.h ../include/ip_address.h \ ../include/pdu_option.h ../include/tcp.h ../include/udp.h \ ../include/rawpdu.h ../include/pdu.h ../include/packet.h \ ../include/timestamp.h ../include/ip.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/small_uint.h: ../include/endianness.h: ../include/ip_address.h: ../include/pdu_option.h: ../include/tcp.h: ../include/udp.h: ../include/rawpdu.h: ../include/pdu.h: ../include/packet.h: ../include/timestamp.h: src/pppoe.o: src/pppoe.cpp ../include/pppoe.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h ../include/pdu_option.h \ ../include/ethernetII.h ../include/hw_address.h ../include/pppoe.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/ethernetII.h: ../include/hw_address.h: src/radiotap.o: src/radiotap.cpp ../include/radiotap.h \ ../include/macros.h ../include/pdu.h ../include/cxxstd.h \ ../include/exceptions.h ../include/endianness.h \ ../include/dot11/dot11_data.h ../include/dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../macros.h ../include/dot11/dot11_beacon.h \ ../include/dot11/../dot11/dot11_mgmt.h \ ../include/dot11/../dot11/../dot11/dot11_base.h ../include/utils.h \ ../include/ip_address.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h ../include/radiotap.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/dot11/dot11_data.h: ../include/dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../macros.h: ../include/dot11/dot11_beacon.h: ../include/dot11/../dot11/dot11_mgmt.h: ../include/dot11/../dot11/../dot11/dot11_base.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: src/rc4eapol.o: src/rc4eapol.cpp ../include/eapol.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/small_uint.h ../include/endianness.h ../include/utils.h \ ../include/ip_address.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h ../include/eapol.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/small_uint.h: ../include/endianness.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: src/rsn_eapol.o: src/rsn_eapol.cpp ../include/eapol.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/small_uint.h ../include/endianness.h ../include/utils.h \ ../include/ip_address.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h \ ../include/rsn_information.h ../include/eapol.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/small_uint.h: ../include/endianness.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/rsn_information.h: src/sll.o: src/sll.cpp ../include/sll.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/hw_address.h ../include/hw_address.h \ ../include/constants.h ../include/ip.h ../include/small_uint.h \ ../include/ip_address.h ../include/pdu_option.h ../include/sll.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/hw_address.h: ../include/hw_address.h: ../include/constants.h: ../include/ip.h: ../include/small_uint.h: ../include/ip_address.h: ../include/pdu_option.h: src/snap.o: src/snap.cpp ../include/snap.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h ../include/utils.h \ ../include/ip_address.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h ../include/snap.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: src/stp.o: src/stp.cpp ../include/stp.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/hw_address.h ../include/small_uint.h \ ../include/dot3.h ../include/llc.h ../include/stp.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/hw_address.h: ../include/small_uint.h: ../include/dot3.h: ../include/llc.h: src/tcp.o: src/tcp.cpp ../include/tcp.h ../include/pdu.h \ ../include/macros.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/small_uint.h ../include/pdu_option.h \ ../include/ip.h ../include/ip_address.h ../include/utils.h \ ../include/ipv6_address.h ../include/hw_address.h ../include/internals.h \ ../include/constants.h ../include/tcp.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/ip.h: ../include/ip_address.h: ../include/utils.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: src/tcp_stream.o: src/tcp_stream.cpp ../include/tcp_stream.h \ ../include/sniffer.h ../include/pdu.h ../include/macros.h \ ../include/cxxstd.h ../include/exceptions.h ../include/ethernetII.h \ ../include/endianness.h ../include/hw_address.h ../include/radiotap.h \ ../include/packet.h ../include/timestamp.h ../include/loopback.h \ ../include/dot11/dot11_base.h ../include/dot11/../pdu.h \ ../include/dot11/../pdu_option.h ../include/dot11/../exceptions.h \ ../include/dot11/../small_uint.h ../include/dot11/../hw_address.h \ ../include/dot11/../endianness.h ../include/dot11/../cxxstd.h \ ../include/dot11/../macros.h ../include/dot3.h ../include/sll.h \ ../include/tcp.h ../include/small_uint.h ../include/pdu_option.h \ ../include/utils.h ../include/ip_address.h ../include/ipv6_address.h \ ../include/internals.h ../include/constants.h ../include/ip.h \ ../include/tcp.h ../include/utils.h ../include/tcp_stream.h: ../include/sniffer.h: ../include/pdu.h: ../include/macros.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/ethernetII.h: ../include/endianness.h: ../include/hw_address.h: ../include/radiotap.h: ../include/packet.h: ../include/timestamp.h: ../include/loopback.h: ../include/dot11/dot11_base.h: ../include/dot11/../pdu.h: ../include/dot11/../pdu_option.h: ../include/dot11/../exceptions.h: ../include/dot11/../small_uint.h: ../include/dot11/../hw_address.h: ../include/dot11/../endianness.h: ../include/dot11/../cxxstd.h: ../include/dot11/../macros.h: ../include/dot3.h: ../include/sll.h: ../include/tcp.h: ../include/small_uint.h: ../include/pdu_option.h: ../include/utils.h: ../include/ip_address.h: ../include/ipv6_address.h: ../include/internals.h: ../include/constants.h: ../include/ip.h: ../include/tcp.h: ../include/utils.h: src/udp.o: src/udp.cpp ../include/udp.h ../include/macros.h \ ../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \ ../include/endianness.h ../include/ip.h ../include/small_uint.h \ ../include/ip_address.h ../include/pdu_option.h ../include/udp.h: ../include/macros.h: ../include/pdu.h: ../include/cxxstd.h: ../include/exceptions.h: ../include/endianness.h: ../include/ip.h: ../include/small_uint.h: ../include/ip_address.h: ../include/pdu_option.h: src/utils.o: src/utils.cpp ../include/utils.h ../include/macros.h \ ../include/ip_address.h ../include/cxxstd.h ../include/ipv6_address.h \ ../include/hw_address.h ../include/internals.h ../include/constants.h \ ../include/pdu.h ../include/exceptions.h ../include/endianness.h \ ../include/ip_address.h ../include/ipv6_address.h ../include/utils.h: ../include/macros.h: ../include/ip_address.h: ../include/cxxstd.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/exceptions.h: ../include/endianness.h: ../include/ip_address.h: ../include/ipv6_address.h: src/wep_decrypt.o: src/wep_decrypt.cpp ../include/crypto.h \ ../include/utils.h ../include/macros.h ../include/ip_address.h \ ../include/cxxstd.h ../include/ipv6_address.h ../include/hw_address.h \ ../include/internals.h ../include/constants.h ../include/pdu.h \ ../include/exceptions.h ../include/snap.h ../include/endianness.h \ ../include/small_uint.h ../include/rawpdu.h \ ../include/handshake_capturer.h ../include/eapol.h ../include/config.h \ ../include/arp.h ../include/dot11/dot11_data.h \ ../include/dot11/../dot11/dot11_base.h \ ../include/dot11/../dot11/../pdu.h \ ../include/dot11/../dot11/../pdu_option.h \ ../include/dot11/../dot11/../exceptions.h \ ../include/dot11/../dot11/../small_uint.h \ ../include/dot11/../dot11/../hw_address.h \ ../include/dot11/../dot11/../endianness.h \ ../include/dot11/../dot11/../cxxstd.h \ ../include/dot11/../dot11/../macros.h ../include/crypto.h: ../include/utils.h: ../include/macros.h: ../include/ip_address.h: ../include/cxxstd.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/exceptions.h: ../include/snap.h: ../include/endianness.h: ../include/small_uint.h: ../include/rawpdu.h: ../include/handshake_capturer.h: ../include/eapol.h: ../include/config.h: ../include/arp.h: ../include/dot11/dot11_data.h: ../include/dot11/../dot11/dot11_base.h: ../include/dot11/../dot11/../pdu.h: ../include/dot11/../dot11/../pdu_option.h: ../include/dot11/../dot11/../exceptions.h: ../include/dot11/../dot11/../small_uint.h: ../include/dot11/../dot11/../hw_address.h: ../include/dot11/../dot11/../endianness.h: ../include/dot11/../dot11/../cxxstd.h: ../include/dot11/../dot11/../macros.h: src/wpa2_decrypt.o: src/wpa2_decrypt.cpp ../include/crypto.h \ ../include/utils.h ../include/macros.h ../include/ip_address.h \ ../include/cxxstd.h ../include/ipv6_address.h ../include/hw_address.h \ ../include/internals.h ../include/constants.h ../include/pdu.h \ ../include/exceptions.h ../include/snap.h ../include/endianness.h \ ../include/small_uint.h ../include/rawpdu.h \ ../include/handshake_capturer.h ../include/eapol.h ../include/config.h \ ../include/radiotap.h ../include/udp.h ../include/crypto.h: ../include/utils.h: ../include/macros.h: ../include/ip_address.h: ../include/cxxstd.h: ../include/ipv6_address.h: ../include/hw_address.h: ../include/internals.h: ../include/constants.h: ../include/pdu.h: ../include/exceptions.h: ../include/snap.h: ../include/endianness.h: ../include/small_uint.h: ../include/rawpdu.h: ../include/handshake_capturer.h: ../include/eapol.h: ../include/config.h: ../include/radiotap.h: ../include/udp.h: libtins-1.1/tests/configure.ac0000664000175000017500000000105612154360113015765 0ustar matiasmatiasAC_INIT(myconfig, 0.1) AC_PROG_CXX() AC_LANG(C++) CFLAGS="-DTINS_DEBUG -g" AC_ARG_ENABLE( c++11, [ --enable-c++11 enable C++11 features], [CFLAGS="$CFLAGS -std=c++0x"] ) SOURCE_FILES=$(ls ../src/*cpp ../src/dot11/*cpp src/*cpp src/dot11/*cpp | tr '\n' ' ') AC_CHECK_HEADERS([pcap.h gtest/gtest.h]) AC_CHECK_LIB(pcap, pcap_loop, [], [AC_MSG_ERROR([pcap library is needed!])]) AC_CHECK_LIB(crypto, PKCS5_PBKDF2_HMAC_SHA1, [], [AC_MSG_ERROR([crypto library is needed!])]) AC_SUBST(CFLAGS) AC_SUBST(SOURCE_FILES) AC_OUTPUT(Makefile) libtins-1.1/tests/configure0000775000175000017500000036146612154360113015424 0ustar matiasmatias#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for myconfig 0.1. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='myconfig' PACKAGE_TARNAME='myconfig' PACKAGE_VERSION='0.1' PACKAGE_STRING='myconfig 0.1' PACKAGE_BUGREPORT='' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS SOURCE_FILES CFLAGS EGREP GREP CXXCPP OBJEXT EXEEXT ac_ct_CXX CPPFLAGS LDFLAGS CXXFLAGS CXX target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_c__11 ' ac_precious_vars='build_alias host_alias target_alias CXX CXXFLAGS LDFLAGS LIBS CPPFLAGS CCC CXXCPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures myconfig 0.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/myconfig] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of myconfig 0.1:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-c++11 enable C++11 features Some influential environment variables: CXX C++ compiler command CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF myconfig configure 0.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_mongrel # ac_fn_cxx_try_run LINENO # ------------------------ # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_cxx_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_run # ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_cxx_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by myconfig $as_me 0.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 $as_echo_n "checking whether the C++ compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C++ compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 $as_echo_n "checking for C++ compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CFLAGS="-DTINS_DEBUG -g" # Check whether --enable-c++11 was given. if test "${enable_c__11+set}" = set; then : enableval=$enable_c__11; CFLAGS="$CFLAGS -std=c++0x" fi SOURCE_FILES=$(ls ../src/*cpp ../src/dot11/*cpp src/*cpp src/dot11/*cpp | tr '\n' ' ') ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in pcap.h gtest/gtest.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_loop in -lpcap" >&5 $as_echo_n "checking for pcap_loop in -lpcap... " >&6; } if ${ac_cv_lib_pcap_pcap_loop+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pcap_loop (); int main () { return pcap_loop (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_pcap_pcap_loop=yes else ac_cv_lib_pcap_pcap_loop=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_pcap_loop" >&5 $as_echo "$ac_cv_lib_pcap_pcap_loop" >&6; } if test "x$ac_cv_lib_pcap_pcap_loop" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPCAP 1 _ACEOF LIBS="-lpcap $LIBS" else as_fn_error $? "pcap library is needed!" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PKCS5_PBKDF2_HMAC_SHA1 in -lcrypto" >&5 $as_echo_n "checking for PKCS5_PBKDF2_HMAC_SHA1 in -lcrypto... " >&6; } if ${ac_cv_lib_crypto_PKCS5_PBKDF2_HMAC_SHA1+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypto $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char PKCS5_PBKDF2_HMAC_SHA1 (); int main () { return PKCS5_PBKDF2_HMAC_SHA1 (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_crypto_PKCS5_PBKDF2_HMAC_SHA1=yes else ac_cv_lib_crypto_PKCS5_PBKDF2_HMAC_SHA1=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_PKCS5_PBKDF2_HMAC_SHA1" >&5 $as_echo "$ac_cv_lib_crypto_PKCS5_PBKDF2_HMAC_SHA1" >&6; } if test "x$ac_cv_lib_crypto_PKCS5_PBKDF2_HMAC_SHA1" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBCRYPTO 1 _ACEOF LIBS="-lcrypto $LIBS" else as_fn_error $? "crypto library is needed!" "$LINENO" 5 fi ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' :mline /\\$/{ N s,\\\n,, b mline } t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote b any :quote s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g s/\[/\\&/g s/\]/\\&/g s/\$/$$/g H :any ${ g s/^\n// s/\n/ /g p } ' DEFS=`sed -n "$ac_script" confdefs.h` ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by myconfig $as_me 0.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE Configuration files: $config_files Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ myconfig config.status 0.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --he | --h | --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" eval set X " :F $CONFIG_FILES " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi libtins-1.1/tests/Makefile.in0000664000175000017500000000121012154360113015534 0ustar matiasmatiasCXX=@CXX@ CFLAGS=-c -Wall @CFLAGS@ -DTINS_VERSION=@PACKAGE_VERSION@ LDFLAGS=-lpcap -lgtest -lpthread -lcrypto SOURCES=@SOURCE_FILES@ OBJECTS=$(SOURCES:.cpp=.o) INCLUDE=-Iinclude/ -I../include EXECUTABLE=test DEPS = $(SOURCES:.cpp=.d) all: $(SOURCES) $(EXECUTABLE) compile: $(OBJECTS) recompile: clean all depends: $(SOURCES) rm -f ./depends.d make do_make_deps do_make_deps: $(DEPS) $(EXECUTABLE): $(OBJECTS) $(CXX) $(OBJECTS) $(LDFLAGS) -o $@ .cpp.o: $(CXX) $(CFLAGS) $(INCLUDE) $< -o $@ %.d : %.cpp $(CXX) $(CXXFLAGS) $(INCLUDE) -MG -MM -MP -MT"$(<:.cpp=.o)" $< >> depends.d clean: rm $(OBJECTS) $(EXECUTABLE) include depends.d libtins-1.1/src/0000775000175000017500000000000012154360113013122 5ustar matiasmatiaslibtins-1.1/src/utils.cpp0000664000175000017500000001474612154360113015002 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include #include #include #include "utils.h" #ifndef WIN32 #if defined(BSD) || defined(__FreeBSD_kernel__) #include #include #include #else #include #endif #include #include #endif #include "pdu.h" #include "arp.h" #include "ethernetII.h" #include "endianness.h" #include "network_interface.h" #include "packet_sender.h" #include "cxxstd.h" using namespace std; /** \cond */ struct InterfaceCollector { set ifaces; #ifdef WIN32 bool operator() (PIP_ADAPTER_ADDRESSES addr) { ifaces.insert(addr->AdapterName); return true; } #else bool operator() (struct ifaddrs *addr) { ifaces.insert(addr->ifa_name); return true; } #endif }; addrinfo *resolve_domain(const std::string &to_resolve, int family) { addrinfo *result, hints = addrinfo(); hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; hints.ai_family = family; if(!getaddrinfo(to_resolve.c_str(), 0, &hints, &result)) return result; else { throw std::runtime_error("Could not resolve address"); } } namespace Tins { /** \endcond */ namespace Utils { IPv4Address resolve_domain(const std::string &to_resolve) { addrinfo *result = ::resolve_domain(to_resolve, AF_INET); IPv4Address addr(((sockaddr_in*)result->ai_addr)->sin_addr.s_addr); freeaddrinfo(result); return addr; } IPv6Address resolve_domain6(const std::string &to_resolve) { addrinfo *result = ::resolve_domain(to_resolve, AF_INET6); IPv6Address addr((const uint8_t*)&((sockaddr_in6*)result->ai_addr)->sin6_addr); freeaddrinfo(result); return addr; } HWAddress<6> resolve_hwaddr(const NetworkInterface &iface, IPv4Address ip, PacketSender &sender) { IPv4Address my_ip; NetworkInterface::Info info(iface.addresses()); EthernetII packet = ARP::make_arp_request(ip, info.ip_addr, info.hw_addr); Internals::smart_ptr::type response(sender.send_recv(packet, iface)); if(response.get()) { const ARP *arp_resp = response->find_pdu(); if(arp_resp) return arp_resp->sender_hw_addr(); } throw std::runtime_error("Could not resolve hardware address"); } HWAddress<6> resolve_hwaddr(IPv4Address ip, PacketSender &sender) { return resolve_hwaddr(sender.default_interface(), ip, sender); } bool gateway_from_ip(IPv4Address ip, IPv4Address &gw_addr) { typedef std::vector entries_type; entries_type entries; uint32_t ip_int = ip; route_entries(std::back_inserter(entries)); for(entries_type::const_iterator it(entries.begin()); it != entries.end(); ++it) { if((ip_int & it->mask) == it->destination) { gw_addr = it->gateway; return true; } } return false; } set network_interfaces() { InterfaceCollector collector; generic_iface_loop(collector); return collector.ifaces; } uint16_t channel_to_mhz(uint16_t channel) { return 2407 + (channel * 5); } uint16_t mhz_to_channel(uint16_t mhz) { return (mhz - 2407) / 5; } uint32_t do_checksum(const uint8_t *start, const uint8_t *end) { uint32_t checksum(0); uint16_t *ptr = (uint16_t*)start, *last = (uint16_t*)end, padding(0); if(((end - start) & 1) == 1) { last = (uint16_t*)end - 1; padding = *(end - 1) << 8; } while(ptr < last) checksum += Endian::host_to_be(*(ptr++)); return checksum + padding; } uint32_t pseudoheader_checksum(IPv4Address source_ip, IPv4Address dest_ip, uint32_t len, uint32_t flag) { uint32_t checksum(0); uint32_t source_ip_int = Endian::host_to_be(source_ip), dest_ip_int = Endian::host_to_be(dest_ip); char buffer[sizeof(uint32_t) * 2]; uint16_t *ptr = (uint16_t*)buffer, *end = (uint16_t*)(buffer + sizeof(buffer)); std::memcpy(buffer, &source_ip_int, sizeof(source_ip_int)); std::memcpy(buffer + sizeof(uint32_t), &dest_ip_int, sizeof(dest_ip_int)); while(ptr < end) checksum += (uint32_t)*ptr++; checksum += flag + len; return checksum; } uint32_t pseudoheader_checksum(IPv6Address source_ip, IPv6Address dest_ip, uint32_t len, uint32_t flag) { uint32_t checksum = 0; IPv6Address::const_iterator it; for(it = source_ip.begin(); it != source_ip.end(); ++it) checksum += *it; for(it = dest_ip.begin(); it != dest_ip.end(); ++it) checksum += *it; checksum += flag + len; return checksum; } uint32_t crc32(const uint8_t* data, uint32_t data_size) { uint32_t i, crc = 0; static uint32_t crc_table[] = { 0x4DBDF21C, 0x500AE278, 0x76D3D2D4, 0x6B64C2B0, 0x3B61B38C, 0x26D6A3E8, 0x000F9344, 0x1DB88320, 0xA005713C, 0xBDB26158, 0x9B6B51F4, 0x86DC4190, 0xD6D930AC, 0xCB6E20C8, 0xEDB71064, 0xF0000000 }; for (i = 0; i < data_size; ++i) { crc = (crc >> 4) ^ crc_table[(crc ^ data[i]) & 0x0F]; crc = (crc >> 4) ^ crc_table[(crc ^ (data[i] >> 4)) & 0x0F]; } return crc; } } } libtins-1.1/src/udp.cpp0000664000175000017500000001070312154360113014417 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #ifdef TINS_DEBUG #include #endif #include #include "udp.h" #include "constants.h" #include "utils.h" #include "ip.h" #include "ipv6.h" #include "rawpdu.h" #include "exceptions.h" namespace Tins { UDP::UDP(uint16_t dport, uint16_t sport) { this->dport(dport); this->sport(sport); _udp.check = 0; _udp.len = 0; } UDP::UDP(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(udphdr)) throw malformed_packet(); std::memcpy(&_udp, buffer, sizeof(udphdr)); total_sz -= sizeof(udphdr); if(total_sz) inner_pdu(new RawPDU(buffer + sizeof(udphdr), total_sz)); } void UDP::dport(uint16_t new_dport) { _udp.dport = Endian::host_to_be(new_dport); } void UDP::sport(uint16_t new_sport) { _udp.sport = Endian::host_to_be(new_sport); } void UDP::length(uint16_t new_len) { _udp.len = Endian::host_to_be(new_len); } uint32_t UDP::header_size() const { return sizeof(udphdr); } void UDP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) { #ifdef TINS_DEBUG assert(total_sz >= sizeof(udphdr)); #endif _udp.check = 0; if(inner_pdu()) length(sizeof(udphdr) + inner_pdu()->size()); else length(sizeof(udphdr)); std::memcpy(buffer, &_udp, sizeof(udphdr)); const Tins::IP *ip_packet = dynamic_cast(parent); if(ip_packet) { uint32_t checksum = Utils::pseudoheader_checksum( ip_packet->src_addr(), ip_packet->dst_addr(), size(), Constants::IP::PROTO_UDP ) + Utils::do_checksum(buffer, buffer + total_sz); while (checksum >> 16) checksum = (checksum & 0xffff)+(checksum >> 16); _udp.check = Endian::host_to_be(~checksum); ((udphdr*)buffer)->check = _udp.check; } else { const Tins::IPv6 *ip6_packet = dynamic_cast(parent); if(ip6_packet) { uint32_t checksum = Utils::pseudoheader_checksum( ip6_packet->src_addr(), ip6_packet->dst_addr(), size(), Constants::IP::PROTO_UDP ) + Utils::do_checksum(buffer, buffer + total_sz); while (checksum >> 16) checksum = (checksum & 0xffff)+(checksum >> 16); _udp.check = Endian::host_to_be(~checksum); ((udphdr*)buffer)->check = _udp.check; } } } bool UDP::matches_response(const uint8_t *ptr, uint32_t total_sz) const { if(total_sz < sizeof(udphdr)) return false; const udphdr *udp_ptr = (const udphdr*)ptr; if(udp_ptr->sport == _udp.dport && udp_ptr->dport == _udp.sport) { return inner_pdu() ? inner_pdu()->matches_response( ptr + sizeof(udphdr), total_sz - sizeof(udphdr) ) : 0; } return false; } } libtins-1.1/src/tcp_stream.cpp0000664000175000017500000001155212154360113015773 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include "rawpdu.h" #include "tcp_stream.h" namespace Tins { TCPStreamFollower::TCPStreamFollower() : last_identifier(0) { } TCPStream::StreamInfo::StreamInfo(IPv4Address client, IPv4Address server, uint16_t cport, uint16_t sport) : client_addr(client), server_addr(server), client_port(cport), server_port(sport) { } TCPStream::TCPStream(IP *ip, TCP *tcp, uint64_t identifier) : client_seq(tcp->seq()), server_seq(0), info(ip->src_addr(), ip->dst_addr(), tcp->sport(), tcp->dport()), identifier(identifier), syn_ack_sent(false), fin_sent(false) { } TCPStream::TCPStream(const TCPStream &rhs) { *this = rhs; } TCPStream& TCPStream::operator=(const TCPStream &rhs) { client_seq = rhs.client_seq; server_seq = rhs.server_seq; info = rhs.info; identifier = rhs.identifier; syn_ack_sent = rhs.syn_ack_sent; fin_sent = rhs.fin_sent; client_payload_ = rhs.client_payload_; server_payload_ = rhs.server_payload_; client_frags = clone_fragments(rhs.client_frags); server_frags = clone_fragments(rhs.server_frags); return *this; } TCPStream::~TCPStream() { free_fragments(client_frags); free_fragments(server_frags); } void TCPStream::free_fragments(fragments_type &frags) { for(fragments_type::iterator it = frags.begin(); it != frags.end(); ++it) delete it->second; } TCPStream::fragments_type TCPStream::clone_fragments(const fragments_type &frags) { fragments_type new_frags; for(fragments_type::const_iterator it = frags.begin(); it != frags.end(); ++it) new_frags.insert(std::make_pair(it->first, it->second->clone())); return new_frags; } bool TCPStream::generic_process(uint32_t &my_seq, uint32_t &other_seq, payload_type &pload, fragments_type &frags, TCP *tcp, RawPDU *raw) { bool added_some(false); if(tcp->get_flag(TCP::FIN) || tcp->get_flag(TCP::RST)) fin_sent = true; if(raw && tcp->seq() >= my_seq) { frags[tcp->seq()] = static_cast(tcp->release_inner_pdu()); fragments_type::iterator it = frags.begin(); while(it != frags.end() && it->first == my_seq) { pload.insert( pload.end(), it->second->payload().begin(), it->second->payload().end() ); my_seq += it->second->payload_size(); delete it->second; frags.erase(it); it = frags.begin(); added_some = true; } } return added_some; } bool TCPStream::update(IP *ip, TCP *tcp) { RawPDU *raw = tcp->find_pdu(); if(!syn_ack_sent && tcp->get_flag(TCP::SYN) && tcp->get_flag(TCP::ACK)) { server_seq = tcp->seq() + 1; client_seq = tcp->ack_seq(); syn_ack_sent = true; return false; } else { if(ip->src_addr() == info.client_addr) return generic_process(client_seq, server_seq, client_payload_, client_frags, tcp, raw); else return generic_process(server_seq, client_seq, server_payload_, server_frags, tcp, raw); } } bool TCPStream::StreamInfo::operator<(const StreamInfo &rhs) const { if(client_addr == rhs.client_addr) { if(server_addr == rhs.server_addr) { if(client_port == rhs.client_port) { return server_port < rhs.server_port; } else return client_port < rhs.client_port; } else return server_addr < rhs.server_addr; } else return client_addr < rhs.client_addr; } } libtins-1.1/src/tcp.cpp0000664000175000017500000002660612154360113014426 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include "tcp.h" #include "ip.h" #include "ipv6.h" #include "constants.h" #include "rawpdu.h" #include "utils.h" #include "exceptions.h" namespace Tins { const uint16_t TCP::DEFAULT_WINDOW = 32678; TCP::TCP(uint16_t dport, uint16_t sport) : _options_size(0), _total_options_size(0) { std::memset(&_tcp, 0, sizeof(tcphdr)); this->dport(dport); this->sport(sport); data_offset(sizeof(tcphdr) / sizeof(uint32_t)); window(DEFAULT_WINDOW); } TCP::TCP(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(tcphdr)) throw malformed_packet(); std::memcpy(&_tcp, buffer, sizeof(tcphdr)); buffer += sizeof(tcphdr); total_sz -= sizeof(tcphdr); _total_options_size = 0; _options_size = 0; uint32_t index = 0, header_end = (data_offset() * sizeof(uint32_t)) - sizeof(tcphdr); if(total_sz >= header_end) { uint8_t args[2] = {0}; while(index < header_end) { for(unsigned i(0); i < 2; ++i) { if(index == header_end) throw malformed_packet(); args[i] = buffer[index++]; // NOP and EOL contain no length field if(args[0] == NOP || args[0] == EOL) break; } // We don't want to store NOPs and EOLs if(args[0] != NOP && args[0] != EOL) { // Not enough size for this option args[1] -= (sizeof(uint8_t) << 1); if(header_end - index < args[1]) throw malformed_packet(); if(args[1]) add_option(option((OptionTypes)args[0], buffer + index, buffer + index + args[1])); else add_option(option((OptionTypes)args[0], args[1], 0)); index += args[1]; } else add_option(option((OptionTypes)args[0], 0)); } buffer += index; total_sz -= index; } if(total_sz) inner_pdu(new RawPDU(buffer, total_sz)); } void TCP::dport(uint16_t new_dport) { _tcp.dport = Endian::host_to_be(new_dport); } void TCP::sport(uint16_t new_sport) { _tcp.sport = Endian::host_to_be(new_sport); } void TCP::seq(uint32_t new_seq) { _tcp.seq = Endian::host_to_be(new_seq); } void TCP::ack_seq(uint32_t new_ack_seq) { _tcp.ack_seq = Endian::host_to_be(new_ack_seq); } void TCP::window(uint16_t new_window) { _tcp.window = Endian::host_to_be(new_window); } void TCP::checksum(uint16_t new_check) { _tcp.check = Endian::host_to_be(new_check); } void TCP::urg_ptr(uint16_t new_urg_ptr) { _tcp.urg_ptr = Endian::host_to_be(new_urg_ptr); } void TCP::data_offset(small_uint<4> new_doff) { this->_tcp.doff = new_doff; } void TCP::mss(uint16_t value) { value = Endian::host_to_be(value); add_option(option(MSS, 2, (uint8_t*)&value)); } uint16_t TCP::mss() const { return Endian::host_to_be(generic_search(MSS)); } void TCP::winscale(uint8_t value) { add_option(option(WSCALE, 1, &value)); } uint8_t TCP::winscale() const { return generic_search(WSCALE); } void TCP::sack_permitted() { add_option(option(SACK_OK, 0)); } bool TCP::has_sack_permitted() const { return bool(search_option(SACK_OK)); } void TCP::sack(const sack_type &edges) { uint32_t *value = 0; if(edges.size()) { value = new uint32_t[edges.size()]; uint32_t *ptr = value; for(sack_type::const_iterator it = edges.begin(); it != edges.end(); ++it) *(ptr++) = Endian::host_to_be(*it); } add_option( option( SACK, (uint8_t)(sizeof(uint32_t) * edges.size()), (const uint8_t*)value ) ); delete[] value; } TCP::sack_type TCP::sack() const { const option *option = search_option(SACK); if(!option || (option->data_size() % sizeof(uint32_t)) != 0) throw option_not_found(); const uint32_t *ptr = (const uint32_t*)option->data_ptr(); const uint32_t *end = ptr + (option->data_size() / sizeof(uint32_t)); sack_type edges(end - ptr); sack_type::iterator it = edges.begin(); while(ptr < end) *it++ = Endian::host_to_be(*(ptr++)); return edges; } void TCP::timestamp(uint32_t value, uint32_t reply) { uint64_t buffer = (uint64_t(value) << 32) | reply; buffer = Endian::host_to_be(buffer); add_option(option(TSOPT, 8, (uint8_t*)&buffer)); } std::pair TCP::timestamp() const { const option *option = search_option(TSOPT); if(!option || option->data_size() != (sizeof(uint32_t) << 1)) throw option_not_found(); uint64_t buffer = *(const uint64_t*)option->data_ptr(); buffer = Endian::be_to_host(buffer); return std::make_pair(static_cast(buffer >> 32), buffer & 0xffffffff); } void TCP::altchecksum(AltChecksums value) { uint8_t int_value = value; add_option(option(ALTCHK, 1, &int_value)); } TCP::AltChecksums TCP::altchecksum() const { return static_cast(generic_search(ALTCHK)); } small_uint<1> TCP::get_flag(Flags tcp_flag) { switch(tcp_flag) { case FIN: return _tcp.fin; break; case SYN: return _tcp.syn; break; case RST: return _tcp.rst; break; case PSH: return _tcp.psh; break; case ACK: return _tcp.ack; break; case URG: return _tcp.urg; break; case ECE: return _tcp.ece; break; case CWR: return _tcp.cwr; break; default: return 0; break; }; } void TCP::set_flag(Flags tcp_flag, small_uint<1> value) { switch(tcp_flag) { case FIN: _tcp.fin = value; break; case SYN: _tcp.syn = value; break; case RST: _tcp.rst = value; break; case PSH: _tcp.psh = value; break; case ACK: _tcp.ack = value; break; case URG: _tcp.urg = value; break; case ECE: _tcp.ece = value; break; case CWR: _tcp.cwr = value; break; }; } void TCP::add_option(const option &opt) { _options.push_back(opt); internal_add_option(opt); } uint32_t TCP::header_size() const { return sizeof(tcphdr) + _total_options_size; } void TCP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) { assert(total_sz >= header_size()); uint8_t *tcp_start = buffer; checksum(0); buffer += sizeof(tcphdr); _tcp.doff = (sizeof(tcphdr) + _total_options_size) / sizeof(uint32_t); for(options_type::iterator it = _options.begin(); it != _options.end(); ++it) buffer = write_option(*it, buffer); if(_options_size < _total_options_size) { uint8_t padding = _options_size; while(padding < _total_options_size) { *(buffer++) = 1; padding++; } } memcpy(tcp_start, &_tcp, sizeof(tcphdr)); const Tins::IP *ip_packet = dynamic_cast(parent); if(ip_packet) { uint32_t check = Utils::pseudoheader_checksum(ip_packet->src_addr(), ip_packet->dst_addr(), size(), Constants::IP::PROTO_TCP) + Utils::do_checksum(tcp_start, tcp_start + total_sz); while (check >> 16) check = (check & 0xffff) + (check >> 16); checksum(~check); ((tcphdr*)tcp_start)->check = _tcp.check; } else { const Tins::IPv6 *ipv6_packet = dynamic_cast(parent); if(ipv6_packet) { uint32_t check = Utils::pseudoheader_checksum(ipv6_packet->src_addr(), ipv6_packet->dst_addr(), size(), Constants::IP::PROTO_TCP) + Utils::do_checksum(tcp_start, tcp_start + total_sz); while (check >> 16) check = (check & 0xffff) + (check >> 16); checksum(~check); ((tcphdr*)tcp_start)->check = _tcp.check; } } } const TCP::option *TCP::search_option(OptionTypes opt) const { for(options_type::const_iterator it = _options.begin(); it != _options.end(); ++it) { if(it->option() == opt) return &(*it); } return 0; } /* options */ uint8_t *TCP::write_option(const option &opt, uint8_t *buffer) { if(opt.option() == 0 || opt.option() == 1) { *buffer = opt.option(); return buffer + 1; } else { buffer[0] = opt.option(); buffer[1] = opt.length_field(); // only add the identifier and size field sizes if the length // field hasn't been spoofed. if(opt.length_field() == opt.data_size()) buffer[1] += (sizeof(uint8_t) << 1); return std::copy(opt.data_ptr(), opt.data_ptr() + opt.data_size(), buffer + 2); } } void TCP::internal_add_option(const option &opt) { uint8_t padding; _options_size += sizeof(uint8_t); // SACK_OK contains length but not data.... if(opt.data_size() || opt.option() == SACK_OK) _options_size += sizeof(uint8_t); _options_size += opt.data_size(); padding = _options_size & 3; _total_options_size = (padding) ? _options_size - padding + 4 : _options_size; } bool TCP::matches_response(const uint8_t *ptr, uint32_t total_sz) const { if(total_sz < sizeof(tcphdr)) return false; const tcphdr *tcp_ptr = (const tcphdr*)ptr; if(tcp_ptr->sport == _tcp.dport && tcp_ptr->dport == _tcp.sport) { uint32_t sz = std::min(total_sz, tcp_ptr->doff * sizeof(uint32_t)); return inner_pdu() ? inner_pdu()->matches_response(ptr + sz, total_sz - sz) : true; } else return false; } } libtins-1.1/src/stp.cpp0000664000175000017500000000774612154360113014452 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #ifdef TINS_DEBUG #include #endif #include #include "stp.h" #include "exceptions.h" namespace Tins { STP::STP() : _header() { } STP::STP(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(_header)) throw malformed_packet(); std::memcpy(&_header, buffer ,sizeof(_header)); } void STP::proto_id(uint16_t new_proto_id) { _header.proto_id = Endian::host_to_be(new_proto_id); } void STP::proto_version(uint8_t new_proto_version) { _header.proto_version = new_proto_version; } void STP::bpdu_type(uint8_t new_bpdu_type) { _header.bpdu_type = new_bpdu_type; } void STP::bpdu_flags(uint8_t new_bpdu_flags) { _header.bpdu_flags = new_bpdu_flags; } void STP::root_path_cost(uint32_t new_root_path_cost) { _header.root_path_cost = Endian::host_to_be(new_root_path_cost); } void STP::port_id(uint16_t new_port_id) { _header.port_id = Endian::host_to_be(new_port_id); } void STP::msg_age(uint16_t new_msg_age) { _header.msg_age = Endian::host_to_be(new_msg_age * 256); } void STP::max_age(uint16_t new_max_age) { _header.max_age = Endian::host_to_be(new_max_age * 256); } void STP::hello_time(uint16_t new_hello_time) { _header.hello_time = Endian::host_to_be(new_hello_time * 256); } void STP::fwd_delay(uint16_t new_fwd_delay) { _header.fwd_delay = Endian::host_to_be(new_fwd_delay * 256); } STP::bpdu_id_type STP::root_id() const { return convert(_header.root_id); } STP::bpdu_id_type STP::bridge_id() const { return convert(_header.bridge_id); } void STP::root_id(const bpdu_id_type &id) { _header.root_id = convert(id); } void STP::bridge_id(const bpdu_id_type &id) { _header.bridge_id = convert(id); } void STP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) { #ifdef TINS_DEBUG assert(total_sz >= sizeof(_header)); #endif std::memcpy(buffer, &_header, sizeof(_header)); } uint32_t STP::header_size() const { return sizeof(_header); } STP::bpdu_id_type STP::convert(const pvt_bpdu_id &id) { bpdu_id_type result(id.priority, 0, id.id); #if TINS_IS_LITTLE_ENDIAN result.ext_id = (id.ext_id << 8) | id.ext_idL; #else result.ext_id = id.ext_id; #endif return result; } STP::pvt_bpdu_id STP::convert(const bpdu_id_type &id) { pvt_bpdu_id result; result.priority = id.priority; std::copy(id.id.begin(), id.id.end(), result.id); #if TINS_IS_LITTLE_ENDIAN result.ext_id = (id.ext_id >> 8) & 0xf; result.ext_idL = id.ext_id & 0xff; #else result.ext_id = id.ext_id; #endif return result; } } libtins-1.1/src/sniffer.cpp0000664000175000017500000001071212154360113015263 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include "sniffer.h" using std::string; using std::runtime_error; namespace Tins { BaseSniffer::BaseSniffer() : handle(0), mask(0) { actual_filter.bf_insns = 0; } BaseSniffer::~BaseSniffer() { if(actual_filter.bf_insns) pcap_freecode(&actual_filter); if(handle) pcap_close(handle); } void BaseSniffer::init(pcap_t *phandle, const std::string &filter, bpf_u_int32 if_mask) { handle = phandle; mask = if_mask; iface_type = pcap_datalink(handle); actual_filter.bf_insns = 0; if(!filter.empty() && !set_filter(filter)) throw runtime_error("Invalid filter"); } bool BaseSniffer::compile_set_filter(const string &filter, bpf_program &prog) { return (pcap_compile(handle, &prog, filter.c_str(), 0, mask) != -1 && pcap_setfilter(handle, &prog) != -1); } PtrPacket BaseSniffer::next_packet() { pcap_pkthdr header; PDU *ret = 0; const u_char *content = pcap_next(handle, &header); // timestamp_ = header.ts; if(content) { try { if(iface_type == DLT_EN10MB) { if(is_dot3((const uint8_t*)content, header.caplen)) ret = new Dot3((const uint8_t*)content, header.caplen); else ret = new EthernetII((const uint8_t*)content, header.caplen); } else if(iface_type == DLT_IEEE802_11_RADIO) ret = new RadioTap((const uint8_t*)content, header.caplen); else if(iface_type == DLT_IEEE802_11) ret = Dot11::from_bytes((const uint8_t*)content, header.caplen); else if(iface_type == DLT_LOOP) ret = new Tins::Loopback((const uint8_t*)content, header.caplen); else if(iface_type == DLT_LINUX_SLL) ret = new Tins::SLL((const uint8_t*)content, header.caplen); } catch(malformed_packet&) {} } return PtrPacket(ret, header.ts); } void BaseSniffer::stop_sniff() { pcap_breakloop(handle); } int BaseSniffer::get_fd() { return pcap_get_selectable_fd(handle); } bool BaseSniffer::set_filter(const std::string &filter) { if(actual_filter.bf_insns) pcap_freecode(&actual_filter); return compile_set_filter(filter, actual_filter); } // ****************************** Sniffer ****************************** Sniffer::Sniffer(const string &device, unsigned max_packet_size, bool promisc, const string &filter) { char error[PCAP_ERRBUF_SIZE]; bpf_u_int32 ip, if_mask; if (pcap_lookupnet(device.c_str(), &ip, &if_mask, error) == -1) { ip = 0; if_mask = 0; } pcap_t *phandle = pcap_open_live(device.c_str(), max_packet_size, promisc, 0, error); if(!phandle) throw runtime_error(error); init(phandle, filter, if_mask); } // **************************** FileSniffer **************************** FileSniffer::FileSniffer(const string &file_name, const string &filter) { char error[PCAP_ERRBUF_SIZE]; pcap_t *phandle = pcap_open_offline(file_name.c_str(), error); if(!phandle) throw std::runtime_error(error); init(phandle, filter, 0); } } libtins-1.1/src/snap.cpp0000664000175000017500000000713512154360113014575 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #ifdef TINS_DEBUG #include #endif #include #ifndef WIN32 #include #endif #include "snap.h" #include "constants.h" #include "arp.h" #include "ip.h" #include "eapol.h" #include "internals.h" #include "exceptions.h" Tins::SNAP::SNAP() { std::memset(&_snap, 0, sizeof(_snap)); _snap.dsap = _snap.ssap = 0xaa; control(3); } Tins::SNAP::SNAP(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(_snap)) throw malformed_packet(); std::memcpy(&_snap, buffer, sizeof(_snap)); buffer += sizeof(_snap); total_sz -= sizeof(_snap); if(total_sz) { inner_pdu( Internals::pdu_from_flag( (Constants::Ethernet::e)eth_type(), buffer, total_sz ) ); } } void Tins::SNAP::control(uint8_t new_control) { #if TINS_IS_LITTLE_ENDIAN _snap.control_org = (_snap.control_org & 0xffffff00) | (new_control); #else _snap.control_org = (_snap.control_org & 0xffffff) | (new_control << 24); #endif } void Tins::SNAP::org_code(small_uint<24> new_org) { #if TINS_IS_LITTLE_ENDIAN _snap.control_org = Endian::host_to_be(new_org) | control(); #else _snap.control_org = new_org | (control() << 24); #endif } void Tins::SNAP::eth_type(uint16_t new_eth) { _snap.eth_type = Endian::host_to_be(new_eth); } uint32_t Tins::SNAP::header_size() const { return sizeof(_snap); } void Tins::SNAP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) { #ifdef TINS_DEBUG assert(total_sz >= sizeof(_snap)); #endif if (!_snap.eth_type && inner_pdu()) { uint16_t type = Tins::Constants::Ethernet::IP; switch (inner_pdu()->pdu_type()) { case PDU::IP: type = Tins::Constants::Ethernet::IP; break; case PDU::ARP: type = Tins::Constants::Ethernet::ARP; break; case PDU::EAPOL: type = Tins::Constants::Ethernet::EAPOL; break; default: type = 0; } _snap.eth_type = Endian::host_to_be(type); } std::memcpy(buffer, &_snap, sizeof(_snap)); } libtins-1.1/src/sll.cpp0000664000175000017500000000557012154360113014427 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include "sll.h" #include "internals.h" #include "exceptions.h" namespace Tins { SLL::SLL() : _header() { } SLL::SLL(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(_header)) throw malformed_packet(); std::memcpy(&_header, buffer, sizeof(_header)); buffer += sizeof(_header); total_sz -= sizeof(_header); if(total_sz) { inner_pdu( Internals::pdu_from_flag( (Constants::Ethernet::e)protocol(), buffer, total_sz ) ); } } void SLL::packet_type(uint16_t new_packet_type) { _header.packet_type = Endian::host_to_be(new_packet_type); } void SLL::lladdr_type(uint16_t new_lladdr_type) { _header.lladdr_type = Endian::host_to_be(new_lladdr_type); } void SLL::lladdr_len(uint16_t new_lladdr_len) { _header.lladdr_len = Endian::host_to_be(new_lladdr_len); } void SLL::address(const address_type &new_address) { new_address.copy(_header.address); } void SLL::protocol(uint16_t new_protocol) { _header.protocol = Endian::host_to_be(new_protocol); } uint32_t SLL::header_size() const { return sizeof(_header); } void SLL::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) { if(inner_pdu()) { Constants::Ethernet::e flag = Internals::pdu_flag_to_ether_type( inner_pdu()->pdu_type() ); protocol(static_cast(flag)); } std::memcpy(buffer, &_header, sizeof(_header)); } } libtins-1.1/src/rsn_information.cpp0000664000175000017500000001150612154360113017040 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include "rsn_information.h" #include "exceptions.h" namespace Tins { template void check_size(uint32_t total_sz) { if(total_sz < sizeof(T)) throw malformed_packet(); } RSNInformation::RSNInformation() : _version(1), _capabilities(0) { } RSNInformation::RSNInformation(const serialization_type &buffer) { init(&buffer[0], buffer.size()); } RSNInformation::RSNInformation(const uint8_t *buffer, uint32_t total_sz) { init(buffer, total_sz); } void RSNInformation::init(const uint8_t *buffer, uint32_t total_sz) { if(total_sz <= sizeof(uint16_t) * 2 + sizeof(uint32_t)) throw malformed_packet(); version(Endian::le_to_host(*(uint16_t*)buffer)); buffer += sizeof(uint16_t); total_sz -= sizeof(uint16_t); group_suite((RSNInformation::CypherSuites)*(uint32_t*)buffer); buffer += sizeof(uint32_t); total_sz -= sizeof(uint32_t); uint16_t count = *(uint16_t*)buffer; buffer += sizeof(uint16_t); total_sz -= sizeof(uint16_t); if(count * sizeof(uint32_t) > total_sz) throw malformed_packet(); total_sz -= count * sizeof(uint32_t); while(count--) { add_pairwise_cypher((RSNInformation::CypherSuites)*(uint32_t*)buffer); buffer += sizeof(uint32_t); } check_size(total_sz); count = *(uint16_t*)buffer; buffer += sizeof(uint16_t); total_sz -= sizeof(uint16_t); if(count * sizeof(uint32_t) > total_sz) throw malformed_packet(); total_sz -= count * sizeof(uint32_t); while(count--) { add_akm_cypher((RSNInformation::AKMSuites)*(uint32_t*)buffer); buffer += sizeof(uint32_t); } check_size(total_sz); capabilities(Endian::le_to_host(*(uint16_t*)buffer)); } void RSNInformation::add_pairwise_cypher(CypherSuites cypher) { _pairwise_cyphers.push_back(cypher); } void RSNInformation::add_akm_cypher(AKMSuites akm) { _akm_cyphers.push_back(akm); } void RSNInformation::group_suite(CypherSuites group) { _group_suite = group; } void RSNInformation::version(uint16_t ver) { _version = Endian::host_to_le(ver); } void RSNInformation::capabilities(uint16_t cap) { _capabilities = Endian::host_to_le(cap); } RSNInformation::serialization_type RSNInformation::serialize() const { uint32_t size = sizeof(_version) + sizeof(_capabilities) + sizeof(uint32_t); size += (sizeof(uint16_t) << 1); // 2 lists count. size += sizeof(uint32_t) * (_akm_cyphers.size() + _pairwise_cyphers.size()); serialization_type buffer(size); serialization_type::value_type *ptr = &buffer[0]; *(uint16_t*)ptr = _version; ptr += sizeof(_version); *(uint32_t*)ptr = _group_suite; ptr += sizeof(uint32_t); *(uint16_t*)ptr = _pairwise_cyphers.size(); ptr += sizeof(uint16_t); for(cyphers_type::const_iterator it = _pairwise_cyphers.begin(); it != _pairwise_cyphers.end(); ++it) { *(uint32_t*)ptr = *it; ptr += sizeof(uint32_t); } *(uint16_t*)ptr = _akm_cyphers.size(); ptr += sizeof(uint16_t); for(akm_type::const_iterator it = _akm_cyphers.begin(); it != _akm_cyphers.end(); ++it) { *(uint32_t*)ptr = *it; ptr += sizeof(uint32_t); } *(uint16_t*)ptr = _capabilities; return buffer; } RSNInformation RSNInformation::wpa2_psk() { RSNInformation info; info.group_suite(RSNInformation::CCMP); info.add_pairwise_cypher(RSNInformation::CCMP); info.add_akm_cypher(RSNInformation::PSK); return info; } } libtins-1.1/src/rawpdu.cpp0000664000175000017500000000412512154360113015132 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifdef TINS_DEBUG #include #endif #include #include "rawpdu.h" namespace Tins { RawPDU::RawPDU(const uint8_t *pload, uint32_t size) : _payload(pload, pload + size) { } RawPDU::RawPDU(const std::string &data) : _payload(data.begin(), data.end()) { } uint32_t RawPDU::header_size() const { return _payload.size(); } void RawPDU::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) { #ifdef TINS_DEBUG assert(total_sz >= _payload.size()); #endif std::copy(_payload.begin(), _payload.end(), buffer); } void RawPDU::payload(const payload_type &pload) { _payload = pload; } bool RawPDU::matches_response(const uint8_t *ptr, uint32_t total_sz) const { return true; } } libtins-1.1/src/radiotap.cpp0000664000175000017500000002661112154360113015437 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #ifdef TINS_DEBUG #include #endif #include #include "macros.h" #ifndef WIN32 #if defined(BSD) || defined(__FreeBSD_kernel__) #include #else #include #endif #include #endif #include "radiotap.h" #include "dot11/dot11_base.h" #include "utils.h" #include "packet_sender.h" #include "exceptions.h" namespace Tins { void check_size(uint32_t total_sz, size_t field_size) { if(total_sz < field_size) throw malformed_packet(); } template void read_field(const uint8_t* &buffer, uint32_t &total_sz, T& field) { check_size(total_sz, sizeof(field)); memcpy(&field, buffer, sizeof(field)); buffer += sizeof(field); total_sz -= sizeof(field); } RadioTap::RadioTap() { std::memset(&_radio, 0, sizeof(_radio)); init(); } RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz) { check_size(total_sz, sizeof(_radio)); const uint8_t *buffer_start = buffer; std::memcpy(&_radio, buffer, sizeof(_radio)); uint32_t radiotap_hdr_size = Endian::le_to_host(_radio.it_len); check_size(total_sz, radiotap_hdr_size); buffer += sizeof(_radio); radiotap_hdr_size -= sizeof(_radio); if(_radio.tsft) read_field(buffer, radiotap_hdr_size, _tsft); if(_radio.flags) read_field(buffer, radiotap_hdr_size, _flags); if(_radio.rate) read_field(buffer, radiotap_hdr_size, _rate); if(_radio.channel) { if(((buffer - buffer_start) & 1) == 1) { buffer++; radiotap_hdr_size--; } read_field(buffer, radiotap_hdr_size, _channel_freq); uint16_t dummy; read_field(buffer, radiotap_hdr_size, dummy); _channel_type = dummy; } if(_radio.dbm_signal) read_field(buffer, radiotap_hdr_size, _dbm_signal); if(_radio.dbm_noise) read_field(buffer, radiotap_hdr_size, _dbm_noise); if(_radio.lock_quality) read_field(buffer, radiotap_hdr_size, _signal_quality); if(_radio.antenna) read_field(buffer, radiotap_hdr_size, _antenna); if(_radio.db_signal) read_field(buffer, radiotap_hdr_size, _db_signal); if(_radio.rx_flags) { if(((buffer - buffer_start) & 1) == 1) { buffer++; radiotap_hdr_size--; } read_field(buffer, radiotap_hdr_size, _rx_flags); } if(_radio.channel_plus) { uint32_t offset = ((buffer - buffer_start) % 4); if(offset) { offset = 4 - offset; buffer += offset; radiotap_hdr_size -= offset; } read_field(buffer, radiotap_hdr_size, _channel_type); read_field(buffer, radiotap_hdr_size, _channel_freq); read_field(buffer, radiotap_hdr_size, _channel); read_field(buffer, radiotap_hdr_size, _max_power); } total_sz -= Endian::le_to_host(_radio.it_len); buffer += radiotap_hdr_size; if((flags() & FCS) != 0) { check_size(total_sz, sizeof(uint32_t)); total_sz -= sizeof(uint32_t); if((flags() & FAILED_FCS) !=0) throw malformed_packet(); } if(total_sz) inner_pdu(Dot11::from_bytes(buffer, total_sz)); } void RadioTap::init() { channel(Utils::channel_to_mhz(1), 0xa0); flags(FCS); tsft(0); dbm_signal(0xce); rx_flags(0); antenna(0); } void RadioTap::version(uint8_t new_version) { _radio.it_version = new_version; } void RadioTap::padding(uint8_t new_padding) { _radio.it_pad = new_padding; } void RadioTap::length(uint16_t new_length) { _radio.it_len = Endian::host_to_le(new_length); } void RadioTap::tsft(uint64_t new_tsft) { _tsft = Endian::host_to_le(new_tsft); _radio.tsft = 1; } void RadioTap::flags(FrameFlags new_flags) { _flags = (uint8_t)new_flags; _radio.flags = 1; } void RadioTap::rate(uint8_t new_rate) { _rate = new_rate; _radio.rate = 1; } void RadioTap::channel(uint16_t new_freq, uint16_t new_type) { _channel_freq = Endian::host_to_le(new_freq); _channel_type = Endian::host_to_le(new_type); _radio.channel = 1; } void RadioTap::dbm_signal(uint8_t new_dbm_signal) { _dbm_signal = new_dbm_signal; _radio.dbm_signal = 1; } void RadioTap::dbm_noise(uint8_t new_dbm_noise) { _dbm_noise = new_dbm_noise; _radio.dbm_noise = 1; } void RadioTap::signal_quality(uint8_t new_signal_quality) { _signal_quality = new_signal_quality; _radio.lock_quality = 1; } void RadioTap::antenna(uint8_t new_antenna) { _antenna = new_antenna; _radio.antenna = 1; } void RadioTap::db_signal(uint8_t new_db_signal) { _db_signal = new_db_signal; _radio.db_signal = 1; } void RadioTap::rx_flags(uint16_t new_rx_flag) { _rx_flags = Endian::host_to_le(new_rx_flag); _radio.rx_flags = 1; } uint32_t RadioTap::header_size() const { uint32_t total_bytes = 0; if(_radio.tsft) total_bytes += sizeof(_tsft); if(_radio.flags) total_bytes += sizeof(_flags); if(_radio.rate) total_bytes += sizeof(_rate); if(_radio.channel) { total_bytes += (total_bytes & 1); total_bytes += sizeof(uint16_t) * 2; } if(_radio.dbm_signal) total_bytes += sizeof(_dbm_signal); if(_radio.dbm_noise) total_bytes += sizeof(_dbm_noise); if(_radio.lock_quality) { total_bytes += (total_bytes & 1); total_bytes += sizeof(_signal_quality); } if(_radio.antenna) total_bytes += sizeof(_antenna); if(_radio.db_signal) total_bytes += sizeof(_db_signal); if(_radio.rx_flags) { total_bytes += (total_bytes & 1); total_bytes += sizeof(_rx_flags); } if(_radio.channel_plus) { uint32_t offset = total_bytes % 4; if(offset) total_bytes += 4 - offset; total_bytes += 8; } return sizeof(_radio) + total_bytes; } uint32_t RadioTap::trailer_size() const { // will be sizeof(uint32_t) if the FCS-at-the-end bit is on. return ((_flags & 0x10) != 0) ? sizeof(uint32_t) : 0; } #ifndef WIN32 void RadioTap::send(PacketSender &sender, const NetworkInterface &iface) { if(!iface) throw invalid_interface(); #if !defined(BSD) && !defined(__FreeBSD_kernel__) struct sockaddr_ll addr; memset(&addr, 0, sizeof(struct sockaddr_ll)); addr.sll_family = Endian::host_to_be(PF_PACKET); addr.sll_protocol = Endian::host_to_be(ETH_P_ALL); addr.sll_halen = 6; addr.sll_ifindex = iface.id(); Tins::Dot11 *wlan = dynamic_cast(inner_pdu()); if(wlan) { Tins::Dot11::address_type dot11_addr(wlan->addr1()); std::copy(dot11_addr.begin(), dot11_addr.end(), addr.sll_addr); } sender.send_l2(*this, (struct sockaddr*)&addr, (uint32_t)sizeof(addr)); #else sender.send_l2(*this, 0, 0, iface); #endif } #endif bool RadioTap::matches_response(const uint8_t *ptr, uint32_t total_sz) const { if(sizeof(_radio) < total_sz) return false; const radiotap_hdr *radio_ptr = (const radiotap_hdr*)ptr; if(radio_ptr->it_len <= total_sz) { ptr += radio_ptr->it_len; total_sz -= radio_ptr->it_len; return inner_pdu() ? inner_pdu()->matches_response(ptr, total_sz) : true; } return false; } void RadioTap::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) { uint32_t sz = header_size(); uint8_t *buffer_start = buffer; #ifdef TINS_DEBUG assert(total_sz >= sz); #endif _radio.it_len = Endian::host_to_le(sz); memcpy(buffer, &_radio, sizeof(_radio)); buffer += sizeof(_radio); if(_radio.tsft) { memcpy(buffer, &_tsft, sizeof(_tsft)); buffer += sizeof(_tsft); } if(_radio.flags) { memcpy(buffer, &_flags, sizeof(_flags)); buffer += sizeof(_flags); } if(_radio.rate) { memcpy(buffer, &_rate, sizeof(_rate)); buffer += sizeof(_rate); } if(_radio.channel) { if(((buffer - buffer_start) & 1) == 1) *(buffer++) = 0; uint16_t dummy = _channel_type; memcpy(buffer, &_channel_freq, sizeof(_channel_freq)); buffer += sizeof(_channel_freq); memcpy(buffer, &dummy, sizeof(dummy)); buffer += sizeof(dummy); } if(_radio.dbm_signal) { memcpy(buffer, &_dbm_signal, sizeof(_dbm_signal)); buffer += sizeof(_dbm_signal); } if(_radio.dbm_noise) { memcpy(buffer, &_dbm_noise, sizeof(_dbm_noise)); buffer += sizeof(_dbm_noise); } if(_radio.lock_quality) { if(((buffer - buffer_start) & 1) == 1) *(buffer++) = 0; memcpy(buffer, &_signal_quality, sizeof(_signal_quality)); buffer += sizeof(_signal_quality); } if(_radio.antenna) { memcpy(buffer, &_antenna, sizeof(_antenna)); buffer += sizeof(_antenna); } if(_radio.db_signal) { memcpy(buffer, &_db_signal, sizeof(_db_signal)); buffer += sizeof(_db_signal); } if(_radio.rx_flags) { if(((buffer - buffer_start) & 1) == 1) *(buffer++) = 0; memcpy(buffer, &_rx_flags, sizeof(_rx_flags)); buffer += sizeof(_rx_flags); } if(_radio.channel_plus) { uint32_t offset = ((buffer - buffer_start) % 4); if(offset) { offset = 4 - offset; while(offset--) { *buffer++ = 0; } } memcpy(buffer, &_channel_type, sizeof(_channel_type)); buffer += sizeof(_channel_type); memcpy(buffer, &_channel_freq, sizeof(_channel_freq)); buffer += sizeof(_channel_freq); memcpy(buffer, &_channel, sizeof(_channel)); buffer += sizeof(_channel); memcpy(buffer, &_max_power, sizeof(_max_power)); buffer += sizeof(_max_power); } if((_flags & 0x10) != 0 && inner_pdu()) { *(uint32_t*)(buffer + inner_pdu()->size()) = Endian::host_to_le( Utils::crc32(buffer, inner_pdu()->size()) ); } } } libtins-1.1/src/pppoe.cpp0000664000175000017500000001554512154360113014763 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifdef TINS_DEBUG #include #endif #include #include "pppoe.h" #include "exceptions.h" namespace Tins { PPPoE::PPPoE() : _header(), _tags_size() { version(1); type(1); } PPPoE::PPPoE(const uint8_t *buffer, uint32_t total_sz) : _tags_size() { if(total_sz < sizeof(_header)) throw malformed_packet(); std::memcpy(&_header, buffer, sizeof(_header)); buffer += sizeof(_header); total_sz -= sizeof(_header); const uint8_t *end = buffer + total_sz; while(buffer < end) { if(buffer + sizeof(uint32_t) * 2 > end) throw malformed_packet(); uint16_t opt_type = *(const uint16_t*)buffer; uint16_t opt_len = *(const uint16_t*)(buffer + sizeof(uint16_t)); buffer += sizeof(uint16_t) * 2; total_sz -= sizeof(uint16_t) * 2; if(Endian::be_to_host(opt_len) > total_sz) throw malformed_packet(); add_tag( tag( static_cast(opt_type), Endian::be_to_host(opt_len), buffer ) ); buffer += Endian::be_to_host(opt_len); total_sz -= Endian::be_to_host(opt_len); } } const PPPoE::tag *PPPoE::search_tag(TagTypes identifier) const { for(tags_type::const_iterator it = _tags.begin(); it != _tags.end(); ++it) { if(it->option() == identifier) return &*it; } return 0; } void PPPoE::version(small_uint<4> new_version) { _header.version = new_version; } void PPPoE::type(small_uint<4> new_type) { _header.type = new_type; } void PPPoE::code(uint8_t new_code) { _header.code = new_code; } void PPPoE::session_id(uint16_t new_session_id) { _header.session_id = Endian::host_to_be(new_session_id); } void PPPoE::payload_length(uint16_t new_payload_length) { _header.payload_length = Endian::host_to_be(new_payload_length); } uint32_t PPPoE::header_size() const { return sizeof(_header) + _tags_size; } void PPPoE::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) { #ifdef TINS_DEBUG assert(total_sz == sizeof(_header) + _tags_size); #endif std::memcpy(buffer, &_header, sizeof(_header)); if(_tags_size > 0) ((pppoe_hdr*)buffer)->payload_length = Endian::host_to_be(_tags_size); buffer += sizeof(_header); for(tags_type::const_iterator it = _tags.begin(); it != _tags.end(); ++it) { *(uint16_t*)buffer = it->option(); *(uint16_t*)(buffer + sizeof(uint16_t)) = Endian::host_to_be(it->length_field()); std::copy( it->data_ptr(), it->data_ptr() + it->data_size(), buffer + sizeof(uint16_t) * 2 ); buffer += sizeof(uint16_t) * 2 + it->data_size(); } } void PPPoE::add_tag(const tag &option) { _tags_size += option.data_size() + sizeof(uint16_t) * 2; _tags.push_back(option); } // *********************** Setters ************************* void PPPoE::end_of_list() { add_tag( END_OF_LIST ); } void PPPoE::service_name(const std::string &value) { add_tag_iterable(SERVICE_NAME, value); } void PPPoE::ac_name(const std::string &value) { add_tag_iterable(AC_NAME, value); } void PPPoE::host_uniq(const byte_array &value) { add_tag_iterable(HOST_UNIQ, value); } void PPPoE::ac_cookie(const byte_array &value) { add_tag_iterable(AC_COOKIE, value); } void PPPoE::vendor_specific(const vendor_spec_type &value) { std::vector buffer(sizeof(uint32_t) + value.data.size()); *(uint32_t*)&buffer[0] = Endian::host_to_be(value.vendor_id); std::copy( value.data.begin(), value.data.end(), buffer.begin() + sizeof(uint32_t) ); add_tag( tag( VENDOR_SPECIFIC, buffer.begin(), buffer.end() ) ); } void PPPoE::relay_session_id(const byte_array &value) { add_tag_iterable(RELAY_SESSION_ID, value); } void PPPoE::service_name_error(const std::string &value) { add_tag_iterable(SERVICE_NAME_ERROR, value); } void PPPoE::ac_system_error(const std::string &value) { add_tag_iterable(AC_SYSTEM_ERROR, value); } void PPPoE::generic_error(const std::string &value) { add_tag_iterable(GENERIC_ERROR, value); } // *********************** Getters ************************* std::string PPPoE::service_name() const { return retrieve_tag_iterable(SERVICE_NAME); } std::string PPPoE::ac_name() const { return retrieve_tag_iterable(AC_NAME); } byte_array PPPoE::host_uniq() const { return retrieve_tag_iterable(HOST_UNIQ); } byte_array PPPoE::ac_cookie() const { return retrieve_tag_iterable(AC_COOKIE); } PPPoE::vendor_spec_type PPPoE::vendor_specific() const { const tag *tag = safe_search_tag( VENDOR_SPECIFIC, sizeof(uint32_t) ); vendor_spec_type output; output.vendor_id = Endian::be_to_host(*(const uint32_t*)tag->data_ptr()); output.data.assign( tag->data_ptr() + sizeof(uint32_t), tag->data_ptr() + tag->data_size() ); return output; } byte_array PPPoE::relay_session_id() const { return retrieve_tag_iterable(RELAY_SESSION_ID); } std::string PPPoE::service_name_error() const { return retrieve_tag_iterable(SERVICE_NAME_ERROR); } std::string PPPoE::ac_system_error() const { return retrieve_tag_iterable(AC_SYSTEM_ERROR); } std::string PPPoE::generic_error() const { return retrieve_tag_iterable(GENERIC_ERROR); } } //namespace Tins libtins-1.1/src/pdu.cpp0000664000175000017500000000607112154360113014422 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifdef TINS_DEBUG #include #endif #include "pdu.h" #include "rawpdu.h" #include "packet_sender.h" namespace Tins { PDU::PDU() : _inner_pdu() { } PDU::PDU(const PDU &other) : _inner_pdu(0) { copy_inner_pdu(other); } PDU &PDU::operator=(const PDU &other) { copy_inner_pdu(other); return *this; } PDU::~PDU() { delete _inner_pdu; } void PDU::copy_inner_pdu(const PDU &pdu) { if(pdu.inner_pdu()) inner_pdu(pdu.inner_pdu()->clone()); } uint32_t PDU::size() const { uint32_t sz = header_size() + trailer_size(); const PDU *ptr(_inner_pdu); while(ptr) { sz += ptr->header_size() + ptr->trailer_size(); ptr = ptr->inner_pdu(); } return sz; } void PDU::send(PacketSender &, const NetworkInterface &) { } PDU *PDU::recv_response(PacketSender &, const NetworkInterface &) { return 0; } void PDU::inner_pdu(PDU *next_pdu) { delete _inner_pdu; _inner_pdu = next_pdu; } void PDU::inner_pdu(const PDU &next_pdu) { inner_pdu(next_pdu.clone()); } PDU *PDU::release_inner_pdu() { PDU *result = 0; std::swap(result, _inner_pdu); return result; } PDU::serialization_type PDU::serialize() { std::vector buffer(size()); serialize(&buffer[0], buffer.size(), 0); // Copy elision, do your magic return buffer; } void PDU::serialize(uint8_t *buffer, uint32_t total_sz, const PDU *parent) { uint32_t sz = header_size() + trailer_size(); /* Must not happen... */ #ifdef TINS_DEBUG assert(total_sz >= sz); #endif prepare_for_serialize(parent); if(_inner_pdu) _inner_pdu->serialize(buffer + header_size(), total_sz - sz, this); write_serialization(buffer, total_sz, parent); } } libtins-1.1/src/packet_writer.cpp0000664000175000017500000000461712154360113016501 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef WIN32 #include #endif #include #include "packet_writer.h" #include "pdu.h" namespace Tins { PacketWriter::PacketWriter(const std::string &file_name, LinkType lt) { handle = pcap_open_dead(lt, 65535); if(!handle) throw std::runtime_error("Error creating pcap handle"); dumper = pcap_dump_open(handle, file_name.c_str()); if(!dumper) { // RAII plx pcap_close(handle); throw std::runtime_error(pcap_geterr(handle)); } } PacketWriter::~PacketWriter() { if(dumper && handle) { pcap_dump_close(dumper); pcap_close(handle); } } void PacketWriter::write(PDU &pdu) { PDU::serialization_type buffer = pdu.serialize(); timeval tm; #ifndef WIN32 gettimeofday(&tm, 0); #else // fixme tm = timeval(); #endif struct pcap_pkthdr header = { tm, static_cast(buffer.size()), static_cast(buffer.size()) }; pcap_dump((u_char*)dumper, &header, &buffer[0]); } } libtins-1.1/src/packet_sender.cpp0000664000175000017500000002711612154360113016444 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include "packet_sender.h" #ifndef WIN32 #include #include #include #include #include #if defined(BSD) || defined(__FreeBSD_kernel__) #include #include #include #include #include #include #else #include #include #endif #include #include #include #else #define NOMINMAX #include #include #endif #include #include #include "pdu.h" #include "macros.h" #include "network_interface.h" // PDUs required by PacketSender::send(PDU&, NetworkInterface) #include "ethernetII.h" #include "radiotap.h" #include "dot11/dot11_base.h" #include "radiotap.h" #include "ieee802_3.h" #include "internals.h" namespace Tins { const int PacketSender::INVALID_RAW_SOCKET = -1; const uint32_t PacketSender::DEFAULT_TIMEOUT = 2; #ifndef WIN32 const char *make_error_string() { return strerror(errno); } #else // fixme const char *make_error_string() { return "error"; } #endif PacketSender::PacketSender(const NetworkInterface &iface, uint32_t recv_timeout, uint32_t usec) : _sockets(SOCKETS_END, INVALID_RAW_SOCKET), #if !defined(BSD) && !defined(WIN32) && !defined(__FreeBSD_kernel__) _ether_socket(INVALID_RAW_SOCKET), #endif _timeout(recv_timeout), _timeout_usec(usec), default_iface(iface) { _types[IP_TCP_SOCKET] = IPPROTO_TCP; _types[IP_UDP_SOCKET] = IPPROTO_UDP; _types[IP_RAW_SOCKET] = IPPROTO_RAW; _types[IPV6_SOCKET] = IPPROTO_RAW; _types[ICMP_SOCKET] = IPPROTO_ICMP; } PacketSender::~PacketSender() { for(unsigned i(0); i < _sockets.size(); ++i) { if(_sockets[i] != INVALID_RAW_SOCKET) #ifndef WIN32 ::close(_sockets[i]); #else ::closesocket(_sockets[i]); #endif } #if defined(BSD) || defined(__FreeBSD_kernel__) for(BSDEtherSockets::iterator it = _ether_socket.begin(); it != _ether_socket.end(); ++it) ::close(it->second); #elif !defined(WIN32) if(_ether_socket != INVALID_RAW_SOCKET) ::close(_ether_socket); #endif } void PacketSender::default_interface(const NetworkInterface &iface) { default_iface = iface; } const NetworkInterface& PacketSender::default_interface() { return default_iface; } #ifndef WIN32 bool PacketSender::ether_socket_initialized(const NetworkInterface& iface) const { #if defined(BSD) || defined(__FreeBSD_kernel__) return _ether_socket.count(iface.id()); #else return _ether_socket != INVALID_RAW_SOCKET; #endif } int PacketSender::get_ether_socket(const NetworkInterface& iface) { if(!ether_socket_initialized(iface)) open_l2_socket(iface); #if defined(BSD) || defined(__FreeBSD_kernel__) return _ether_socket[iface.id()]; #else return _ether_socket; #endif } void PacketSender::open_l2_socket(const NetworkInterface& iface) { #if defined(BSD) || defined(__FreeBSD_kernel__) int sock = -1; // At some point, there should be an available device for (int i = 0; sock == -1;i++) { std::ostringstream oss; oss << "/dev/bpf" << i; sock = open(oss.str().c_str(), O_RDWR); } if(sock == -1) throw socket_open_error(make_error_string()); struct ifreq ifr; strncpy(ifr.ifr_name, iface.name().c_str(), sizeof(ifr.ifr_name) - 1); if(ioctl(sock, BIOCSETIF, (caddr_t)&ifr) < 0) { ::close(sock); throw socket_open_error(make_error_string()); } _ether_socket[iface.id()] = sock; #else if (_ether_socket == INVALID_RAW_SOCKET) { _ether_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (_ether_socket == -1) throw socket_open_error(make_error_string()); } #endif } #endif // WIN32 void PacketSender::open_l3_socket(SocketType type) { int socktype = find_type(type); if(socktype == -1) throw invalid_socket_type(); if(_sockets[type] == INVALID_RAW_SOCKET) { int sockfd; sockfd = socket((type == IPV6_SOCKET) ? AF_INET6 : AF_INET, SOCK_RAW, socktype); if (sockfd < 0) throw socket_open_error(make_error_string()); const int on = 1; #ifndef WIN32 typedef const void* option_ptr; #else typedef const char* option_ptr; #endif setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL,(option_ptr)&on,sizeof(on)); _sockets[type] = sockfd; } } void PacketSender::close_socket(SocketType type, const NetworkInterface &iface) { if(type == ETHER_SOCKET) { #if defined(BSD) || defined(__FreeBSD_kernel__) BSDEtherSockets::iterator it = _ether_socket.find(iface.id()); if(it == _ether_socket.end()) throw invalid_socket_type(); if(::close(it->second) == -1) throw socket_close_error(make_error_string()); _ether_socket.erase(it); #elif !defined(WIN32) if(_ether_socket == INVALID_RAW_SOCKET) throw invalid_socket_type(); if(::close(_ether_socket) == -1) throw socket_close_error(make_error_string()); _ether_socket = INVALID_RAW_SOCKET; #endif } else { if(type >= SOCKETS_END || _sockets[type] == INVALID_RAW_SOCKET) throw invalid_socket_type(); #ifndef WIN32 if(close(_sockets[type]) == -1) throw socket_close_error(make_error_string()); #else closesocket(_sockets[type]); #endif _sockets[type] = INVALID_RAW_SOCKET; } } void PacketSender::send(PDU &pdu) { pdu.send(*this, default_iface); } void PacketSender::send(PDU &pdu, const NetworkInterface &iface) { PDU::PDUType type = pdu.pdu_type(); switch(type) { case PDU::ETHERNET_II: send(pdu, iface); break; case PDU::DOT11: send(pdu, iface); break; case PDU::RADIOTAP: send(pdu, iface); break; case PDU::IEEE802_3: send(pdu, iface); break; default: send(pdu); }; } PDU *PacketSender::send_recv(PDU &pdu) { return send_recv(pdu, NetworkInterface()); } PDU *PacketSender::send_recv(PDU &pdu, const NetworkInterface &iface) { try { pdu.send(*this, iface); } catch(std::runtime_error&) { return 0; } return pdu.recv_response(*this, iface); } #ifndef WIN32 void PacketSender::send_l2(PDU &pdu, struct sockaddr* link_addr, uint32_t len_addr, const NetworkInterface &iface) { int sock = get_ether_socket(iface); PDU::serialization_type buffer = pdu.serialize(); if(!buffer.empty()) { #if defined(BSD) || defined(__FreeBSD_kernel__) if(::write(sock, &buffer[0], buffer.size()) == -1) #else if(::sendto(sock, &buffer[0], buffer.size(), 0, link_addr, len_addr) == -1) #endif throw socket_write_error(make_error_string()); } } PDU *PacketSender::recv_l2(PDU &pdu, struct sockaddr *link_addr, uint32_t len_addr, const NetworkInterface &iface) { int sock = get_ether_socket(iface); return recv_match_loop(sock, pdu, link_addr, len_addr); } #endif // WIN32 PDU *PacketSender::recv_l3(PDU &pdu, struct sockaddr* link_addr, uint32_t len_addr, SocketType type) { open_l3_socket(type); return recv_match_loop(_sockets[type], pdu, link_addr, len_addr); } void PacketSender::send_l3(PDU &pdu, struct sockaddr* link_addr, uint32_t len_addr, SocketType type) { open_l3_socket(type); int sock = _sockets[type]; PDU::serialization_type buffer = pdu.serialize(); if(sendto(sock, (const char*)&buffer[0], buffer.size(), 0, link_addr, len_addr) == -1) throw socket_write_error(make_error_string()); } PDU *PacketSender::recv_match_loop(int sock, PDU &pdu, struct sockaddr* link_addr, uint32_t addrlen) { fd_set readfds; struct timeval timeout, end_time; int read; uint8_t buffer[2048]; timeout.tv_sec = _timeout; end_time.tv_sec = time(0) + _timeout; end_time.tv_usec = timeout.tv_usec = _timeout_usec; while(true) { FD_ZERO(&readfds); FD_SET(sock, &readfds); if((read = select(sock + 1, &readfds, 0, 0, &timeout)) == -1) { return 0; } if(FD_ISSET(sock, &readfds)) { #ifdef WIN32 int length = addrlen; int size; #else socklen_t length = addrlen; ssize_t size; #endif size = recvfrom(sock, (char*)buffer, 2048, 0, link_addr, &length); if(pdu.matches_response(buffer, size)) { return Internals::pdu_from_flag(pdu.pdu_type(), buffer, size); } } struct timeval this_time, diff; #ifdef WIN32 // fixme #else gettimeofday(&this_time, 0); #endif // WIN32 if(timeval_subtract(&diff, &end_time, &this_time)) return 0; timeout.tv_sec = diff.tv_sec; timeout.tv_usec = diff.tv_usec; } return 0; } int PacketSender::timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y) { /* Perform the carry for the later subtraction by updating y. */ if (x->tv_usec < y->tv_usec) { int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1; y->tv_usec -= 1000000 * nsec; y->tv_sec += nsec; } if (x->tv_usec - y->tv_usec > 1000000) { int nsec = (x->tv_usec - y->tv_usec) / 1000000; y->tv_usec += 1000000 * nsec; y->tv_sec -= nsec; } /* Compute the time remaining to wait. tv_usec is certainly positive. */ result->tv_sec = x->tv_sec - y->tv_sec; result->tv_usec = x->tv_usec - y->tv_usec; /* Return 1 if result is negative. */ return x->tv_sec < y->tv_sec; } int PacketSender::find_type(SocketType type) { SocketTypeMap::iterator it = _types.find(type); if(it == _types.end()) return -1; else return it->second; } } libtins-1.1/src/network_interface.cpp0000664000175000017500000001623612154360113017347 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include #include "macros.h" #ifndef WIN32 #include #if defined(BSD) || defined(__FreeBSD_kernel__) #include #include #include #else #include #endif #include #else #define NOMINMAX #include #endif #include "network_interface.h" #include "utils.h" #include "endianness.h" /** \cond */ struct InterfaceInfoCollector { typedef Tins::NetworkInterface::Info info_type; info_type *info; int iface_id; const char* iface_name; bool found; InterfaceInfoCollector(info_type *res, int id, const char* if_name) : info(res), iface_id(id), iface_name(if_name), found(false) { } #ifndef WIN32 bool operator() (const struct ifaddrs *addr) { using Tins::Endian::host_to_be; using Tins::IPv4Address; #if defined(BSD) || defined(__FreeBSD_kernel__) const struct sockaddr_dl* addr_ptr = ((struct sockaddr_dl*)addr->ifa_addr); if(addr->ifa_addr->sa_family == AF_LINK && addr_ptr->sdl_index == iface_id) info->hw_addr = (const uint8_t*)LLADDR(addr_ptr); // mmmm else if(addr->ifa_addr->sa_family == AF_INET && !std::strcmp(addr->ifa_name, iface_name)) { info->ip_addr = IPv4Address(((struct sockaddr_in *)addr->ifa_addr)->sin_addr.s_addr); info->netmask = IPv4Address(((struct sockaddr_in *)addr->ifa_netmask)->sin_addr.s_addr); if((addr->ifa_flags & (IFF_BROADCAST | IFF_POINTOPOINT))) info->bcast_addr = IPv4Address(((struct sockaddr_in *)addr->ifa_dstaddr)->sin_addr.s_addr); else info->bcast_addr = 0; found = true; } return found; #else const struct sockaddr_ll* addr_ptr = ((struct sockaddr_ll*)addr->ifa_addr); if(addr->ifa_addr->sa_family == AF_PACKET && addr_ptr->sll_ifindex == iface_id) info->hw_addr = addr_ptr->sll_addr; else if(addr->ifa_addr->sa_family == AF_INET && !std::strcmp(addr->ifa_name, iface_name)) { info->ip_addr = IPv4Address(((struct sockaddr_in *)addr->ifa_addr)->sin_addr.s_addr); info->netmask = IPv4Address(((struct sockaddr_in *)addr->ifa_netmask)->sin_addr.s_addr); if((addr->ifa_flags & (IFF_BROADCAST | IFF_POINTOPOINT))) info->bcast_addr = IPv4Address(((struct sockaddr_in *)addr->ifa_ifu.ifu_broadaddr)->sin_addr.s_addr); else info->bcast_addr = 0; found = true; } return found; #endif } #else // WIN32 bool operator() (const IP_ADAPTER_ADDRESSES *iface) { using Tins::IPv4Address; using Tins::Endian::host_to_be; if(iface_id == uint32_t(iface->IfIndex)) { std::copy(iface->PhysicalAddress, iface->PhysicalAddress + 6, info->hw_addr.begin()); const IP_ADAPTER_UNICAST_ADDRESS *unicast = iface->FirstUnicastAddress; if(unicast) { info->ip_addr = IPv4Address(((const struct sockaddr_in *)unicast->Address.lpSockaddr)->sin_addr.s_addr); info->netmask = IPv4Address(host_to_be(0xffffffff << (32 - unicast->OnLinkPrefixLength))); info->bcast_addr = IPv4Address((info->ip_addr & info->netmask) | ~info->netmask); found = true; } } return found; } #endif // WIN32 }; /** \endcond */ namespace Tins { // static NetworkInterface NetworkInterface::default_interface() { return NetworkInterface(IPv4Address(uint32_t(0))); } NetworkInterface::NetworkInterface() : iface_id(0) { } NetworkInterface::NetworkInterface(const char *name) { iface_id = name ? resolve_index(name) : 0; } NetworkInterface::NetworkInterface(const std::string &name) { iface_id = resolve_index(name.c_str()); } NetworkInterface::NetworkInterface(IPv4Address ip) : iface_id(0) { typedef std::vector entries_type; if(ip == "127.0.0.1") #if defined(BSD) || defined(__FreeBSD_kernel__) iface_id = resolve_index("lo0"); #else iface_id = resolve_index("lo"); #endif else { const Utils::RouteEntry *best_match = 0; entries_type entries; uint32_t ip_int = ip; Utils::route_entries(std::back_inserter(entries)); for(entries_type::const_iterator it(entries.begin()); it != entries.end(); ++it) { if((ip_int & it->mask) == it->destination) { if(!best_match || it->mask > best_match->mask) { best_match = &*it; } } } if(!best_match) throw std::runtime_error("Error looking up interface"); iface_id = resolve_index(best_match->interface.c_str()); } } std::string NetworkInterface::name() const { #ifndef WIN32 char iface_name[IF_NAMESIZE]; if(!if_indextoname(iface_id, iface_name)) throw std::runtime_error("Error fetching this interface's name"); return iface_name; #else // WIN32 return "Not implemented"; #endif // WIN32 } NetworkInterface::Info NetworkInterface::addresses() const { const std::string &iface_name = name(); Info info; InterfaceInfoCollector collector(&info, iface_id, iface_name.c_str()); Utils::generic_iface_loop(collector); if(!collector.found) throw std::runtime_error("Error looking up interface address"); return info; } NetworkInterface::id_type NetworkInterface::resolve_index(const char *name) { id_type id = if_nametoindex(name); if(!id) throw std::runtime_error("Invalid interface"); return id; } } libtins-1.1/src/loopback.cpp0000664000175000017500000000641612154360113015427 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef WIN32 #include #ifdef BSD #include #include #include #endif #endif #include #ifdef TINS_DEBUG #include #endif #include #include "loopback.h" #include "packet_sender.h" #include "ip.h" #include "llc.h" #include "rawpdu.h" #include "exceptions.h" #if !defined(PF_LLC) // compilation fix, nasty but at least works on BSD #define PF_LLC 26 #endif namespace Tins { Loopback::Loopback() : _family() { } Loopback::Loopback(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(_family)) throw malformed_packet(); _family = *reinterpret_cast(buffer); buffer += sizeof(uint32_t); total_sz -= sizeof(uint32_t); #ifndef WIN32 if(total_sz) { switch(_family) { case PF_INET: inner_pdu(new Tins::IP(buffer, total_sz)); break; case PF_LLC: inner_pdu(new Tins::LLC(buffer, total_sz)); break; default: inner_pdu(new Tins::RawPDU(buffer, total_sz)); break; }; } #endif // WIN32 } void Loopback::family(uint32_t family_id) { _family = family_id; } uint32_t Loopback::header_size() const { return sizeof(_family); } void Loopback::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) { #ifdef TINS_DEBUG assert(total_sz >= sizeof(_family)); #endif if(dynamic_cast(inner_pdu())) _family = PF_INET; else if(dynamic_cast(inner_pdu())) _family = PF_LLC; *reinterpret_cast(buffer) = _family; } #ifdef BSD void Loopback::send(PacketSender &sender, const NetworkInterface &iface) { if(!iface) throw invalid_interface(); sender.send_l2(*this, 0, 0, iface); } #endif // WIN32 } libtins-1.1/src/llc.cpp0000664000175000017500000001464012154360113014405 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #ifdef TINS_DEBUG #include #endif #include "llc.h" #include "stp.h" #include "rawpdu.h" #include "exceptions.h" using std::list; namespace Tins { const uint8_t LLC::GLOBAL_DSAP_ADDR = 0xFF; const uint8_t LLC::NULL_ADDR = 0x00; LLC::LLC() : _type(LLC::INFORMATION) { memset(&_header, 0, sizeof(llchdr)); control_field_length = 2; memset(&control_field, 0, sizeof(control_field)); information_field_length = 0; } LLC::LLC(uint8_t dsap, uint8_t ssap) : _type(LLC::INFORMATION) { _header.dsap = dsap; _header.ssap = ssap; control_field_length = 2; memset(&control_field, 0, sizeof(control_field)); information_field_length = 0; } LLC::LLC(const uint8_t *buffer, uint32_t total_sz) { // header + 1 info byte if(total_sz < sizeof(_header) + 1) throw malformed_packet(); std::memcpy(&_header, buffer, sizeof(_header)); buffer += sizeof(_header); total_sz -= sizeof(_header); information_field_length = 0; if ((buffer[0] & 0x03) == LLC::UNNUMBERED) { if(total_sz < sizeof(un_control_field)) throw malformed_packet(); type(LLC::UNNUMBERED); std::memcpy(&control_field.unnumbered, buffer, sizeof(un_control_field)); buffer += sizeof(un_control_field); total_sz -= sizeof(un_control_field); //TODO: Create information fields if corresponding. } else { if(total_sz < sizeof(info_control_field)) throw malformed_packet(); type((Format)(buffer[0] & 0x03)); control_field_length = 2; std::memcpy(&control_field.info, buffer, sizeof(info_control_field)); buffer += 2; total_sz -= 2; } if(total_sz > 0) { if(dsap() == 0x42 && ssap() == 0x42) inner_pdu(new Tins::STP(buffer, total_sz)); else inner_pdu(new Tins::RawPDU(buffer, total_sz)); } } void LLC::group(bool value) { if (value) { _header.dsap |= 0x01; } else { _header.dsap &= 0xFE; } } void LLC::dsap(uint8_t new_dsap) { _header.dsap = new_dsap; } void LLC::response(bool value) { if (value) { _header.ssap |= 0x01; } else { _header.ssap &= 0xFE; } } void LLC::ssap(uint8_t new_ssap) { _header.ssap = new_ssap; } void LLC::type(LLC::Format type) { _type = type; switch (type) { case LLC::INFORMATION: control_field_length = 2; control_field.info.type_bit = 0; break; case LLC::SUPERVISORY: control_field_length = 2; control_field.super.type_bit = 1; break; case LLC::UNNUMBERED: control_field_length = 1; control_field.unnumbered.type_bits = 3; break; } } void LLC::send_seq_number(uint8_t seq_number) { if (type() != LLC::INFORMATION) return; control_field.info.send_seq_num = seq_number; } void LLC::receive_seq_number(uint8_t seq_number) { switch (type()) { case LLC::UNNUMBERED: return; case LLC::INFORMATION: control_field.info.recv_seq_num = seq_number; break; case LLC::SUPERVISORY: control_field.super.recv_seq_num = seq_number; break; } } void LLC::poll_final(bool value) { switch (type()) { case LLC::UNNUMBERED: control_field.unnumbered.poll_final_bit = value; break; case LLC::INFORMATION: control_field.info.poll_final_bit = value; return; case LLC::SUPERVISORY: control_field.super.poll_final_bit = value; break; } } void LLC::supervisory_function(LLC::SupervisoryFunctions new_func) { if (type() != LLC::SUPERVISORY) return; control_field.super.supervisory_func = new_func; } void LLC::modifier_function(LLC::ModifierFunctions mod_func) { if (type() != LLC::UNNUMBERED) return; control_field.unnumbered.mod_func1 = mod_func >> 3; control_field.unnumbered.mod_func2 = mod_func & 0x07; } void LLC::add_xid_information(uint8_t xid_id, uint8_t llc_type_class, uint8_t receive_window) { field_type xid(3); xid[0] = xid_id; xid[1] = llc_type_class; xid[2] = receive_window; information_field_length += xid.size(); information_fields.push_back(xid); } uint32_t LLC::header_size() const { return sizeof(_header) + control_field_length + information_field_length; } void LLC::clear_information_fields() { information_field_length = 0; information_fields.clear(); } void LLC::write_serialization(uint8_t *buffer, uint32_t total_sz, const Tins::PDU *parent) { #ifdef TINS_DEBUG assert(total_sz >= header_size()); #endif if(inner_pdu() && inner_pdu()->pdu_type() == PDU::STP) { dsap(0x42); ssap(0x42); } std::memcpy(buffer, &_header, sizeof(_header)); buffer += sizeof(_header); switch (type()) { case LLC::UNNUMBERED: std::memcpy(buffer, &(control_field.unnumbered), sizeof(un_control_field)); buffer += sizeof(un_control_field); break; case LLC::INFORMATION: std::memcpy(buffer, &(control_field.info), sizeof(info_control_field)); buffer += sizeof(info_control_field); break; case LLC::SUPERVISORY: std::memcpy(buffer, &(control_field.super), sizeof(super_control_field)); buffer += sizeof(super_control_field); break; } for (list::const_iterator it = information_fields.begin(); it != information_fields.end(); it++) { std::copy(it->begin(), it->end(), buffer); buffer += it->size(); } } } libtins-1.1/src/ipv6_address.cpp0000664000175000017500000000665312154360113016231 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include "macros.h" #ifndef WIN32 #include #ifdef BSD #include #endif #else #include #include #endif #include #include #include "ipv6_address.h" namespace Tins { IPv6Address::IPv6Address() { std::fill(address, address + address_size, 0); } IPv6Address::IPv6Address(const char *addr) { init(addr); } IPv6Address::IPv6Address(const_iterator ptr) { std::copy(ptr, ptr + address_size, address); } IPv6Address::IPv6Address(const std::string &addr) { init(addr.c_str()); } void IPv6Address::init(const char *addr) { #ifdef WIN32 // mingw on linux somehow doesn't have InetPton #ifdef _MSC_VER if(InetPtonA(AF_INET6, addr, address) != 1) throw malformed_address(); #else ULONG dummy1; USHORT dummy2; // Maybe change this, mingw doesn't have any other conversion function if(RtlIpv6StringToAddressExA(addr, (IN6_ADDR*)address, &dummy1, &dummy2) != NO_ERROR) throw malformed_address(); #endif #else if(inet_pton(AF_INET6, addr, address) == 0) throw malformed_address(); #endif } std::string IPv6Address::to_string() const { char buffer[INET6_ADDRSTRLEN]; #ifdef WIN32 // mingw on linux somehow doesn't have InetNtop #ifdef _MSC_VER if(InetNtopA(AF_INET6, (PVOID)address, buffer, sizeof(buffer)) != 0) throw malformed_address(); #else ULONG sz = sizeof(buffer); if(RtlIpv6AddressToStringExA((const IN6_ADDR*)address, 0, 0, buffer, &sz) != NO_ERROR) throw malformed_address(); #endif #else if(inet_ntop(AF_INET6, address, buffer, sizeof(buffer)) == 0) throw malformed_address(); #endif return buffer; } } libtins-1.1/src/ipv6.cpp0000664000175000017500000002223412154360113014515 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #ifdef TINS_DEBUG #include #endif #ifndef WIN32 #include #include #else #include #endif #include #include "ipv6.h" #include "constants.h" #include "packet_sender.h" #include "ip.h" #include "tcp.h" #include "udp.h" #include "icmp.h" #include "icmpv6.h" #include "rawpdu.h" #include "exceptions.h" namespace Tins { IPv6::IPv6(address_type ip_dst, address_type ip_src, PDU *child) : headers_size(0) { std::memset(&_header, 0, sizeof(_header)); version(6); dst_addr(ip_dst); src_addr(ip_src); } IPv6::IPv6(const uint8_t *buffer, uint32_t total_sz) : headers_size(0) { if(total_sz < sizeof(_header)) throw malformed_packet(); std::memcpy(&_header, buffer, sizeof(_header)); buffer += sizeof(_header); total_sz -= sizeof(_header); uint8_t current_header = _header.next_header; while(total_sz) { if(is_extension_header(current_header)) { if(total_sz < 8) throw malformed_packet(); // every ext header is at least 8 bytes long // minus one, from the next_header field. uint32_t size = static_cast(buffer[1]) + 8; // -1 -> next header identifier if(total_sz < size) throw malformed_packet(); // minus one, from the size field add_ext_header( ext_header(buffer[0], size - sizeof(uint8_t)*2, buffer + 2) ); current_header = buffer[0]; buffer += size; total_sz -= size; } else { switch(current_header) { case Constants::IP::PROTO_TCP: inner_pdu(new Tins::TCP(buffer, total_sz)); break; case Constants::IP::PROTO_UDP: inner_pdu(new Tins::UDP(buffer, total_sz)); break; case Constants::IP::PROTO_ICMP: inner_pdu(new Tins::ICMP(buffer, total_sz)); break; case Constants::IP::PROTO_ICMPV6: inner_pdu(new Tins::ICMPv6(buffer, total_sz)); break; default: inner_pdu(new Tins::RawPDU(buffer, total_sz)); break; } total_sz = 0; } } } bool IPv6::is_extension_header(uint8_t header_id) { return header_id == HOP_BY_HOP || header_id == DESTINATION_ROUTING_OPTIONS || header_id == ROUTING || header_id == FRAGMENT || header_id == AUTHENTICATION || header_id == SECURITY_ENCAPSULATION || header_id == DESTINATION_OPTIONS || header_id == MOBILITY || header_id == NO_NEXT_HEADER; } void IPv6::version(small_uint<4> new_version) { _header.version = new_version; } void IPv6::traffic_class(uint8_t new_traffic_class) { #if TINS_IS_LITTLE_ENDIAN _header.traffic_class = (new_traffic_class >> 4) & 0xf; _header.flow_label[0] = (_header.flow_label[0] & 0x0f) | ((new_traffic_class << 4) & 0xf0); #else _header.traffic_class = new_traffic_class; #endif } void IPv6::flow_label(small_uint<20> new_flow_label) { #if TINS_IS_LITTLE_ENDIAN uint32_t value = Endian::host_to_be(new_flow_label); _header.flow_label[2] = (value >> 24) & 0xff; _header.flow_label[1] = (value >> 16) & 0xff; _header.flow_label[0] = ((value >> 8) & 0x0f) | (_header.flow_label[0] & 0xf0); #else _header.flow_label = new_flow_label; #endif } void IPv6::payload_length(uint16_t new_payload_length) { _header.payload_length = Endian::host_to_be(new_payload_length); } void IPv6::next_header(uint8_t new_next_header) { _header.next_header = new_next_header; } void IPv6::hop_limit(uint8_t new_hop_limit) { _header.hop_limit = new_hop_limit; } void IPv6::src_addr(const address_type &new_src_addr) { new_src_addr.copy(_header.src_addr); } void IPv6::dst_addr(const address_type &new_dst_addr) { new_dst_addr.copy(_header.dst_addr); } uint32_t IPv6::header_size() const { return sizeof(_header) + headers_size; } bool IPv6::matches_response(const uint8_t *ptr, uint32_t total_sz) const { if(total_sz < sizeof(ipv6_header)) return false; const ipv6_header *hdr_ptr = (const ipv6_header*)ptr; // checks for ff02 multicast if(src_addr() == hdr_ptr->dst_addr && (dst_addr() == hdr_ptr->src_addr || (_header.dst_addr[0] == 0xff && _header.dst_addr[1] == 0x02))) { // is this OK? there's no inner pdu, simple dst/src addr match should suffice if(!inner_pdu()) return true; ptr += sizeof(ipv6_header); total_sz -= sizeof(ipv6_header); uint8_t current = hdr_ptr->next_header; // 8 == minimum header size while(total_sz > 8 && is_extension_header(current)) { if(static_cast(ptr[1] + 1) * 8 > total_sz) return false; current = ptr[0]; total_sz -= (ptr[1] + 1) * 8; ptr += (ptr[1] + 1) * 8; } if(!is_extension_header(current)) return inner_pdu()->matches_response(ptr, total_sz); } return false; } void IPv6::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) { #ifdef TINS_DEBUG assert(total_sz >= header_size()); #endif if(inner_pdu()) { uint8_t new_flag = 0xff; switch(inner_pdu()->pdu_type()) { case PDU::IP: new_flag = Constants::IP::PROTO_IPIP; break; case PDU::TCP: new_flag = Constants::IP::PROTO_TCP; break; case PDU::UDP: new_flag = Constants::IP::PROTO_UDP; break; case PDU::ICMP: new_flag = Constants::IP::PROTO_ICMP; break; case PDU::ICMPv6: new_flag = Constants::IP::PROTO_ICMPV6; break; default: break; }; if(new_flag != 0xff) set_last_next_header(new_flag); } payload_length(total_sz - sizeof(_header)); std::memcpy(buffer, &_header, sizeof(_header)); buffer += sizeof(_header); for(headers_type::const_iterator it = ext_headers.begin(); it != ext_headers.end(); ++it) { buffer = write_header(*it, buffer); } } #ifndef BSD void IPv6::send(PacketSender &sender, const NetworkInterface &) { struct sockaddr_in6 link_addr; PacketSender::SocketType type = PacketSender::IPV6_SOCKET; link_addr.sin6_family = AF_INET6; link_addr.sin6_port = 0; std::copy(_header.dst_addr, _header.dst_addr + address_type::address_size, (uint8_t*)&link_addr.sin6_addr); if(inner_pdu() && inner_pdu()->pdu_type() == PDU::ICMP) type = PacketSender::ICMP_SOCKET; sender.send_l3(*this, (struct sockaddr*)&link_addr, sizeof(link_addr), type); } #endif void IPv6::add_ext_header(const ext_header &header) { ext_headers.push_back(header); headers_size += header.data_size() + sizeof(uint8_t) * 2; } const IPv6::ext_header *IPv6::search_header(ExtensionHeader id) const { uint8_t current_header = _header.next_header; headers_type::const_iterator it = ext_headers.begin(); while(it != ext_headers.end() && current_header != id) { current_header = it->option(); ++it; } if(it == ext_headers.end()) return 0; return &*it; } void IPv6::set_last_next_header(uint8_t value) { if(ext_headers.empty()) _header.next_header = value; else ext_headers.back().option(value); } uint8_t *IPv6::write_header(const ext_header &header, uint8_t *buffer) { *buffer++ = header.option(); *buffer++ = (header.length_field() > 8) ? (header.length_field() - 8) : 0; return std::copy(header.data_ptr(), header.data_ptr() + header.data_size(), buffer); } } libtins-1.1/src/ip_address.cpp0000664000175000017500000000607012154360113015746 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include "ip_address.h" #include "endianness.h" using std::string; namespace Tins{ IPv4Address::IPv4Address(uint32_t ip) : ip_addr(Endian::be_to_host(ip)) { } IPv4Address::IPv4Address(const char *ip) { ip_addr = ip ? ip_to_int(ip) : 0; } IPv4Address::IPv4Address(const std::string &ip) : ip_addr(ip_to_int(ip)) { } IPv4Address::operator uint32_t() const { return Endian::host_to_be(ip_addr); } std::string IPv4Address::to_string() const { std::ostringstream oss; oss << *this; return oss.str(); } uint32_t IPv4Address::ip_to_int(const string &ip) { uint32_t result(0), i(0), end, bytes_found(0); while(i < ip.size() && bytes_found < 4) { uint16_t this_byte(0); end = i + 3; while(i < ip.size() && i < end && ip[i] != '.') { if(ip[i] < '0' || ip[i] > '9') throw std::runtime_error("Non-digit character found in ip"); this_byte = (this_byte * 10) + (ip[i] - '0'); i++; } if (this_byte > 0xFF) { throw std::runtime_error("Byte greater than 255"); } result = (result << 8) | (this_byte & 0xFF); bytes_found++; if(bytes_found < 4 && i < ip.size() && ip[i] == '.') i++; } if(bytes_found < 4 || (i < ip.size() && bytes_found == 4)) throw std::runtime_error("Invalid ip address"); return result; } std::ostream &operator<<(std::ostream &output, const IPv4Address &addr) { int mask(24); uint32_t ip_addr = addr.ip_addr; while(mask >=0) { output << ((ip_addr >> mask) & 0xff); if(mask) output << '.'; mask -= 8; } return output;; } } libtins-1.1/src/ip.cpp0000664000175000017500000003247412154360113014250 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #ifdef TINS_DEBUG #include #endif #include #ifndef WIN32 #include #include #include #else #define NOMINMAX #include #endif #include "ip.h" #include "ipv6.h" #include "tcp.h" #include "udp.h" #include "icmp.h" #include "rawpdu.h" #include "utils.h" #include "packet_sender.h" #include "constants.h" #include "network_interface.h" #include "exceptions.h" using std::list; namespace Tins { const uint8_t IP::DEFAULT_TTL = 128; IP::IP(address_type ip_dst, address_type ip_src) { init_ip_fields(); this->dst_addr(ip_dst); this->src_addr(ip_src); } IP::IP(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(iphdr)) throw malformed_packet(); std::memcpy(&_ip, buffer, sizeof(iphdr)); /* Options... */ /* Establish beginning and ending of the options */ const uint8_t* ptr_buffer = buffer + sizeof(iphdr); if(total_sz < head_len() * sizeof(uint32_t)) throw malformed_packet(); if(head_len() * sizeof(uint32_t) < sizeof(iphdr)) throw malformed_packet(); buffer += head_len() * sizeof(uint32_t); _options_size = 0; //_padded_options_size = head_len() * sizeof(uint32_t) - sizeof(iphdr); /* While the end of the options is not reached read an option */ while (ptr_buffer < buffer && (*ptr_buffer != 0)) { //ip_option opt_to_add; option_identifier opt_type; memcpy(&opt_type, ptr_buffer, sizeof(uint8_t)); ptr_buffer++; if(opt_type.number > NOOP) { /* Multibyte options with length as second byte */ if(ptr_buffer == buffer || *ptr_buffer == 0) throw malformed_packet(); const uint8_t data_size = *ptr_buffer - 2; if(data_size > 0) { ptr_buffer++; if(buffer - ptr_buffer < data_size) throw malformed_packet(); _ip_options.push_back(option(opt_type, ptr_buffer, ptr_buffer + data_size)); } else _ip_options.push_back(option(opt_type)); ptr_buffer += _ip_options.back().data_size() + 1; _options_size += _ip_options.back().data_size() + 2; } else { _ip_options.push_back(option(opt_type)); _options_size++; } } uint8_t padding = _options_size % 4; _padded_options_size = padding ? (_options_size - padding + 4) : _options_size; // check this line PLX total_sz -= head_len() * sizeof(uint32_t); if (total_sz) { switch(_ip.protocol) { case Constants::IP::PROTO_TCP: inner_pdu(new Tins::TCP(buffer, total_sz)); break; case Constants::IP::PROTO_UDP: inner_pdu(new Tins::UDP(buffer, total_sz)); break; case Constants::IP::PROTO_ICMP: inner_pdu(new Tins::ICMP(buffer, total_sz)); break; case Constants::IP::PROTO_IPV6: inner_pdu(new Tins::IPv6(buffer, total_sz)); break; default: inner_pdu(new Tins::RawPDU(buffer, total_sz)); break; } } } void IP::init_ip_fields() { memset(&_ip, 0, sizeof(iphdr)); _ip.version = 4; ttl(DEFAULT_TTL); id(1); _options_size = 0; _padded_options_size = 0; } /* Setters */ void IP::tos(uint8_t new_tos) { _ip.tos = new_tos; } void IP::tot_len(uint16_t new_tot_len) { _ip.tot_len = Endian::host_to_be(new_tot_len); } void IP::id(uint16_t new_id) { _ip.id = Endian::host_to_be(new_id); } void IP::frag_off(uint16_t new_frag_off) { _ip.frag_off = Endian::host_to_be(new_frag_off); } void IP::ttl(uint8_t new_ttl) { _ip.ttl = new_ttl; } void IP::protocol(uint8_t new_protocol) { _ip.protocol = new_protocol; } void IP::checksum(uint16_t new_check) { _ip.check = Endian::host_to_be(new_check); } void IP::src_addr(address_type ip) { _ip.saddr = ip; } void IP::dst_addr(address_type ip) { _ip.daddr = ip; } void IP::head_len(small_uint<4> new_head_len) { _ip.ihl = new_head_len; } void IP::version(small_uint<4> ver) { _ip.version = ver; } void IP::eol() { add_option(option_identifier(IP::END, IP::CONTROL, 0)); } void IP::noop() { add_option(option_identifier(IP::NOOP, IP::CONTROL, 0)); } void IP::security(const security_type &data) { uint8_t array[9]; uint16_t *ptr = reinterpret_cast(array); uint32_t value = data.transmission_control; *ptr++ = Endian::host_to_be(data.security); *ptr++ = Endian::host_to_be(data.compartments); *ptr++ = Endian::host_to_be(data.handling_restrictions); array[8] = (value & 0xff); array[7] = ((value >> 8) & 0xff); array[6] = ((value >> 16) & 0xff); add_option( option( 130, sizeof(array), array ) ); } void IP::stream_identifier(uint16_t stream_id) { stream_id = Endian::host_to_be(stream_id); add_option( option( 136, sizeof(uint16_t), (const uint8_t*)&stream_id ) ); } void IP::add_route_option(option_identifier id, const generic_route_option_type &data) { std::vector opt_data(1 + sizeof(uint32_t) * data.routes.size()); opt_data[0] = data.pointer; for(size_t i(0); i < data.routes.size(); ++i) { uint32_t ip = data.routes[i]; #if TINS_IS_BIG_ENDIAN ip = Endian::change_endian(ip); #endif opt_data[1 + i * 4] = ip & 0xff; opt_data[1 + i * 4 + 1] = (ip >> 8) & 0xff; opt_data[1 + i * 4 + 2] = (ip >> 16) & 0xff; opt_data[1 + i * 4 + 3] = (ip >> 24) & 0xff; } add_option( option( id, opt_data.size(), &opt_data[0] ) ); } IP::generic_route_option_type IP::search_route_option(option_identifier id) const { const option *option = search_option(id); if(!option || option->data_size() < 1 + sizeof(uint32_t) || ((option->data_size() - 1) % sizeof(uint32_t)) != 0) throw option_not_found(); generic_route_option_type output; output.pointer = *option->data_ptr(); const uint32_t *route = (const uint32_t*)(option->data_ptr() + 1), *end = route + (option->data_size() - 1) / sizeof(uint32_t); while(route < end) output.routes.push_back(address_type(*route++)); return output; } IP::security_type IP::security() const { const option *option = search_option(130); if(!option || option->data_size() < 9) throw option_not_found(); security_type output; const uint16_t *ptr = reinterpret_cast(option->data_ptr()); output.security = Endian::be_to_host(*ptr++); output.compartments = Endian::be_to_host(*ptr++); output.handling_restrictions = Endian::be_to_host(*ptr++); uint32_t tcc = option->data_ptr()[6]; tcc = (tcc << 8) | option->data_ptr()[7]; tcc = (tcc << 8) | option->data_ptr()[8]; output.transmission_control = tcc; return output; } uint16_t IP::stream_identifier() const { const option *option = search_option(136); if(!option || option->data_size() != sizeof(uint16_t)) throw option_not_found(); return Endian::be_to_host(*(const uint16_t*)option->data_ptr()); } void IP::add_option(const option &opt) { internal_add_option(opt); _ip_options.push_back(opt); } void IP::internal_add_option(const option &opt) { _options_size += 1 + opt.data_size(); uint8_t padding = _options_size % 4; _padded_options_size = padding ? (_options_size - padding + 4) : _options_size; } const IP::option *IP::search_option(option_identifier id) const { for(options_type::const_iterator it = _ip_options.begin(); it != _ip_options.end(); ++it) { if(it->option() == id) return &(*it); } return 0; } uint8_t* IP::write_option(const option &opt, uint8_t* buffer) { option_identifier opt_type = opt.option(); memcpy(buffer, &opt_type, 1); if(*buffer <= 1) return ++buffer; buffer++; *buffer = opt.length_field(); if(opt.data_size() == opt.length_field()) *buffer += 2; buffer++; return std::copy(opt.data_ptr(), opt.data_ptr() + opt.data_size(), buffer); } /* Virtual method overriding. */ uint32_t IP::header_size() const { return sizeof(iphdr) + _padded_options_size; } PacketSender::SocketType pdu_type_to_sender_type(PDU::PDUType type) { switch(type) { case PDU::TCP: return PacketSender::IP_TCP_SOCKET; case PDU::UDP: return PacketSender::IP_UDP_SOCKET; case PDU::ICMP: return PacketSender::ICMP_SOCKET; default: return PacketSender::IP_RAW_SOCKET; } } void IP::send(PacketSender& sender, const NetworkInterface &) { sockaddr_in link_addr; PacketSender::SocketType type = PacketSender::IP_RAW_SOCKET; link_addr.sin_family = AF_INET; link_addr.sin_port = 0; link_addr.sin_addr.s_addr = _ip.daddr; if(inner_pdu()) type = pdu_type_to_sender_type(inner_pdu()->pdu_type()); sender.send_l3(*this, (struct sockaddr*)&link_addr, sizeof(link_addr), type); } PDU *IP::recv_response(PacketSender &sender, const NetworkInterface &) { sockaddr_in link_addr; PacketSender::SocketType type = PacketSender::IP_RAW_SOCKET; std::memset(&link_addr, 0, sizeof(link_addr)); if(inner_pdu()) type = pdu_type_to_sender_type(inner_pdu()->pdu_type()); return sender.recv_l3(*this, 0, sizeof(link_addr), type); } void IP::prepare_for_serialize(const PDU *parent) { if(!parent && _ip.saddr == 0) { NetworkInterface iface(dst_addr()); src_addr(iface.addresses().ip_addr); } } void IP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU* parent) { uint32_t my_sz = header_size(); #ifdef TINS_DEBUG assert(total_sz >= my_sz); #endif checksum(0); if(inner_pdu()) { uint32_t new_flag; switch(inner_pdu()->pdu_type()) { case PDU::IP: new_flag = Constants::IP::PROTO_IPIP; break; case PDU::TCP: new_flag = Constants::IP::PROTO_TCP; break; case PDU::UDP: new_flag = Constants::IP::PROTO_UDP; break; case PDU::ICMP: new_flag = Constants::IP::PROTO_ICMP; break; default: // check for other protos new_flag = 0xff; }; protocol(new_flag); //flag(new_flag); } #if __FreeBSD__ || defined(__FreeBSD_kernel__) if(!parent) total_sz = Endian::host_to_be(total_sz); #endif tot_len(total_sz); head_len(my_sz / sizeof(uint32_t)); memcpy(buffer, &_ip, sizeof(_ip)); uint8_t* ptr_buffer = buffer + sizeof(_ip); for(options_type::const_iterator it = _ip_options.begin(); it != _ip_options.end(); ++it) { ptr_buffer = write_option(*it, ptr_buffer); } memset(buffer + sizeof(_ip) + _options_size, 0, _padded_options_size - _options_size); if(parent) { uint32_t check = Utils::do_checksum(buffer, buffer + sizeof(_ip) + _padded_options_size); while (check >> 16) check = (check & 0xffff) + (check >> 16); checksum(~check); ((iphdr*)buffer)->check = _ip.check; } } bool IP::matches_response(const uint8_t *ptr, uint32_t total_sz) const { if(total_sz < sizeof(iphdr)) return false; const iphdr *ip_ptr = (const iphdr*)ptr; // checks for broadcast addr if((_ip.saddr == ip_ptr->daddr && (_ip.daddr == ip_ptr->saddr || _ip.daddr == 0xffffffff)) || (_ip.daddr == 0xffffffff && _ip.saddr == 0)) { uint32_t sz = std::min(_ip.ihl * sizeof(uint32_t), total_sz); return inner_pdu() ? inner_pdu()->matches_response(ptr + sz, total_sz - sz) : true; } return false; } } libtins-1.1/src/internals.cpp0000664000175000017500000001212512154360113015626 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include "internals.h" #include "ip.h" #include "ethernetII.h" #include "ieee802_3.h" #include "radiotap.h" #include "dot11/dot11_base.h" #include "ipv6.h" #include "arp.h" #include "eapol.h" #include "rawpdu.h" #include "dot1q.h" #include "pppoe.h" using std::string; namespace Tins { namespace Internals { bool from_hex(const string &str, uint32_t &result) { unsigned i(0); result = 0; while(i < str.size()) { uint8_t tmp; if(str[i] >= 'A' && str[i] <= 'F') tmp = (str[i] - 'A' + 10); else if(str[i] >= '0' && str[i] <= '9') tmp = (str[i] - '0'); else return false; result = (result << 4) | tmp; i++; } return true; } void skip_line(std::istream &input) { int c = 0; while(c != '\n' && input) c = input.get(); } Tins::PDU *pdu_from_flag(Constants::Ethernet::e flag, const uint8_t *buffer, uint32_t size, bool rawpdu_on_no_match) { switch(flag) { case Tins::Constants::Ethernet::IP: return new Tins::IP(buffer, size); case Constants::Ethernet::IPV6: return new Tins::IPv6(buffer, size); case Tins::Constants::Ethernet::ARP: return new Tins::ARP(buffer, size); case Tins::Constants::Ethernet::PPPOED: return new Tins::PPPoE(buffer, size); case Tins::Constants::Ethernet::EAPOL: return Tins::EAPOL::from_bytes(buffer, size); case Tins::Constants::Ethernet::VLAN: return new Tins::Dot1Q(buffer, size); default: return rawpdu_on_no_match ? new RawPDU(buffer, size) : 0; }; } Tins::PDU *pdu_from_flag(PDU::PDUType type, const uint8_t *buffer, uint32_t size) { switch(type) { case Tins::PDU::ETHERNET_II: return new Tins::EthernetII(buffer, size); case Tins::PDU::IP: return new Tins::IP(buffer, size); case Tins::PDU::IPv6: return new Tins::IPv6(buffer, size); case Tins::PDU::ARP: return new Tins::ARP(buffer, size); case Tins::PDU::IEEE802_3: return new Tins::IEEE802_3(buffer, size); case Tins::PDU::RADIOTAP: return new Tins::RadioTap(buffer, size); case Tins::PDU::PPPOE: return new Tins::PPPoE(buffer, size); case Tins::PDU::DOT11: case Tins::PDU::DOT11_ACK: case Tins::PDU::DOT11_ASSOC_REQ: case Tins::PDU::DOT11_ASSOC_RESP: case Tins::PDU::DOT11_AUTH: case Tins::PDU::DOT11_BEACON: case Tins::PDU::DOT11_BLOCK_ACK: case Tins::PDU::DOT11_BLOCK_ACK_REQ: case Tins::PDU::DOT11_CF_END: case Tins::PDU::DOT11_DATA: case Tins::PDU::DOT11_CONTROL: case Tins::PDU::DOT11_DEAUTH: case Tins::PDU::DOT11_DIASSOC: case Tins::PDU::DOT11_END_CF_ACK: case Tins::PDU::DOT11_MANAGEMENT: case Tins::PDU::DOT11_PROBE_REQ: case Tins::PDU::DOT11_PROBE_RESP: case Tins::PDU::DOT11_PS_POLL: case Tins::PDU::DOT11_REASSOC_REQ: case Tins::PDU::DOT11_REASSOC_RESP: case Tins::PDU::DOT11_RTS: case Tins::PDU::DOT11_QOS_DATA: return Tins::Dot11::from_bytes(buffer, size); default: return 0; }; } Constants::Ethernet::e pdu_flag_to_ether_type(PDU::PDUType flag) { switch (flag) { case PDU::IP: return Constants::Ethernet::IP; case PDU::IPv6: return Constants::Ethernet::IPV6; case PDU::ARP: return Constants::Ethernet::ARP; case PDU::DOT1Q: return Constants::Ethernet::VLAN; case PDU::PPPOE: return Constants::Ethernet::PPPOED; default: return Constants::Ethernet::UNKNOWN; } } } } libtins-1.1/src/icmpv6.cpp0000664000175000017500000007111212154360113015034 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifdef TINS_DEBUG #include #endif #include #include "icmpv6.h" #include "ipv6.h" #include "rawpdu.h" #include "utils.h" #include "constants.h" #include "exceptions.h" namespace Tins { ICMPv6::ICMPv6(Types tp) : _options_size(), reach_time(0), retrans_timer(0) { std::memset(&_header, 0, sizeof(_header)); type(tp); } ICMPv6::ICMPv6(const uint8_t *buffer, uint32_t total_sz) : _options_size(), reach_time(0), retrans_timer(0) { if(total_sz < sizeof(_header)) throw malformed_packet(); std::memcpy(&_header, buffer, sizeof(_header)); buffer += sizeof(_header); total_sz -= sizeof(_header); if(has_target_addr()) { if(total_sz < ipaddress_type::address_size) throw malformed_packet(); target_addr(buffer); buffer += ipaddress_type::address_size; total_sz -= ipaddress_type::address_size; } if(has_dest_addr()) { if(total_sz < ipaddress_type::address_size) throw malformed_packet(); dest_addr(buffer); buffer += ipaddress_type::address_size; total_sz -= ipaddress_type::address_size; } if(type() == ROUTER_ADVERT) { if(total_sz < sizeof(uint32_t) * 2) throw malformed_packet(); const uint32_t *ptr_32 = (const uint32_t*)buffer; reach_time = *ptr_32++; retrans_timer = *ptr_32++; buffer += sizeof(uint32_t) * 2; total_sz -= sizeof(uint32_t) * 2; } if(has_options()) parse_options(buffer, total_sz); if(total_sz > 0) inner_pdu(new RawPDU(buffer, total_sz)); } void ICMPv6::parse_options(const uint8_t *&buffer, uint32_t &total_sz) { while(total_sz > 0) { if(total_sz < 8 || (static_cast(buffer[1]) * 8) > total_sz || buffer[1] < 1) throw malformed_packet(); // size(option) = option_size - identifier_size - length_identifier_size add_option( option( buffer[0], static_cast(buffer[1]) * 8 - sizeof(uint8_t) * 2, buffer + 2 ) ); total_sz -= buffer[1] * 8; buffer += buffer[1] * 8; } } void ICMPv6::type(Types new_type) { _header.type = new_type; } void ICMPv6::code(uint8_t new_code) { _header.code = new_code; } void ICMPv6::checksum(uint16_t new_cksum) { _header.cksum = Endian::host_to_be(new_cksum); } void ICMPv6::identifier(uint16_t new_identifier) { _header.u_echo.identifier = Endian::host_to_be(new_identifier); } void ICMPv6::sequence(uint16_t new_sequence) { _header.u_echo.sequence = Endian::host_to_be(new_sequence); } void ICMPv6::override(small_uint<1> new_override) { _header.u_nd_advt.override = new_override; } void ICMPv6::solicited(small_uint<1> new_solicited) { _header.u_nd_advt.solicited = new_solicited; } void ICMPv6::router(small_uint<1> new_router) { _header.u_nd_advt.router = new_router; } void ICMPv6::hop_limit(uint8_t new_hop_limit) { _header.u_nd_ra.hop_limit = new_hop_limit; } void ICMPv6::router_pref(small_uint<2> new_router_pref) { _header.u_nd_ra.router_pref = new_router_pref; } void ICMPv6::home_agent(small_uint<1> new_home_agent) { _header.u_nd_ra.home_agent = new_home_agent; } void ICMPv6::other(small_uint<1> new_other) { _header.u_nd_ra.other = new_other; } void ICMPv6::managed(small_uint<1> new_managed) { _header.u_nd_ra.managed = new_managed; } void ICMPv6::router_lifetime(uint16_t new_router_lifetime) { _header.u_nd_ra.router_lifetime = Endian::host_to_be(new_router_lifetime); } void ICMPv6::reachable_time(uint32_t new_reachable_time) { reach_time = Endian::host_to_be(new_reachable_time); } void ICMPv6::retransmit_timer(uint32_t new_retrans_timer) { retrans_timer = Endian::host_to_be(new_retrans_timer); } void ICMPv6::target_addr(const ipaddress_type &new_target_addr) { _target_address = new_target_addr; } void ICMPv6::dest_addr(const ipaddress_type &new_dest_addr) { _dest_address = new_dest_addr; } uint32_t ICMPv6::header_size() const { uint32_t extra = 0; if(type() == ROUTER_ADVERT) extra = sizeof(uint32_t) * 2; return sizeof(_header) + _options_size + extra + (has_target_addr() ? ipaddress_type::address_size : 0) + (has_dest_addr() ? ipaddress_type::address_size : 0); } bool ICMPv6::matches_response(const uint8_t *ptr, uint32_t total_sz) const { if(total_sz < sizeof(icmp6hdr)) return false; const icmp6hdr *hdr_ptr = (const icmp6hdr*)ptr; if(type() == ECHO_REQUEST && hdr_ptr->type == ECHO_REPLY) return hdr_ptr->u_echo.identifier == _header.u_echo.identifier && hdr_ptr->u_echo.sequence == _header.u_echo.sequence; return false; } void ICMPv6::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) { #ifdef TINS_DEBUG assert(total_sz >= header_size()); #endif icmp6hdr* ptr_header = (icmp6hdr*)buffer; std::memcpy(buffer, &_header, sizeof(_header)); buffer += sizeof(_header); total_sz -= sizeof(_header); if(has_target_addr()) { buffer = _target_address.copy(buffer); total_sz -= sizeof(ipaddress_type::address_size); } if(has_dest_addr()) { buffer = _dest_address.copy(buffer); total_sz -= sizeof(ipaddress_type::address_size); } if(type() == ROUTER_ADVERT) { *(uint32_t*)buffer = reach_time; buffer += sizeof(uint32_t); *(uint32_t*)buffer = retrans_timer; buffer += sizeof(uint32_t); total_sz -= sizeof(uint32_t) * 2; } for(options_type::const_iterator it = _options.begin(); it != _options.end(); ++it) { #ifdef TINS_DEBUG assert(total_sz >= it->data_size() + sizeof(uint8_t) * 2); // total_sz is only used if TINS_DEBUG is defined. total_sz -= it->data_size() + sizeof(uint8_t) * 2; #endif buffer = write_option(*it, buffer); } if(!_header.cksum) { const Tins::IPv6 *ipv6 = dynamic_cast(parent); if(ipv6) { uint32_t checksum = Utils::pseudoheader_checksum( ipv6->src_addr(), ipv6->dst_addr(), size(), Constants::IP::PROTO_ICMPV6 ) + Utils::do_checksum((uint8_t*)ptr_header, buffer); while (checksum >> 16) checksum = (checksum & 0xffff) + (checksum >> 16); ptr_header->cksum = Endian::host_to_be(~checksum); } } } // can i haz more? bool ICMPv6::has_options() const { return type() == NEIGHBOUR_SOLICIT || type() == ROUTER_ADVERT; } void ICMPv6::add_option(const option &option) { internal_add_option(option); _options.push_back(option); } void ICMPv6::internal_add_option(const option &option) { _options_size += option.data_size() + sizeof(uint8_t) * 2; } uint8_t *ICMPv6::write_option(const option &opt, uint8_t *buffer) { *buffer++ = opt.option(); *buffer++ = (opt.length_field() + sizeof(uint8_t) * 2) / 8; return std::copy(opt.data_ptr(), opt.data_ptr() + opt.data_size(), buffer); } const ICMPv6::option *ICMPv6::search_option(OptionTypes id) const { for(options_type::const_iterator it = _options.begin(); it != _options.end(); ++it) { if(it->option() == id) return &*it; } return 0; } // ******************************************************************** // Option setters // ******************************************************************** void ICMPv6::source_link_layer_addr(const hwaddress_type &addr) { add_option(option(SOURCE_ADDRESS, addr.begin(), addr.end())); } void ICMPv6::target_link_layer_addr(const hwaddress_type &addr) { add_option(option(TARGET_ADDRESS, addr.begin(), addr.end())); } void ICMPv6::prefix_info(prefix_info_type info) { uint8_t buffer[2 + sizeof(uint32_t) * 3 + ipaddress_type::address_size]; buffer[0] = info.prefix_len; buffer[1] = (info.L << 7) | (info.A << 6); *(uint32_t*)(buffer + 2) = Endian::host_to_be(info.valid_lifetime); *(uint32_t*)(buffer + 2 + sizeof(uint32_t)) = Endian::host_to_be(info.preferred_lifetime); *(uint32_t*)(buffer + 2 + sizeof(uint32_t) * 2) = 0; info.prefix.copy(buffer + 2 + sizeof(uint32_t) * 3); add_option( option(PREFIX_INFO, buffer, buffer + sizeof(buffer)) ); } void ICMPv6::redirect_header(PDU::serialization_type data) { // Reserved fields data.insert(data.begin(), 6, 0); // Padding(if necessary) uint8_t padding = 8 - (data.size() + sizeof(uint8_t) * 2) % 8; if(padding == 8) padding = 0; data.insert(data.end(), padding, 0); add_option(option(REDIRECT_HEADER, data.begin(), data.end())); } void ICMPv6::mtu(uint32_t value) { uint8_t buffer[sizeof(uint16_t) + sizeof(uint32_t)] = {0}; *((uint32_t*)(buffer + sizeof(uint16_t))) = Endian::host_to_be(value); add_option(option(MTU, sizeof(buffer), buffer)); } void ICMPv6::shortcut_limit(uint8_t value) { uint8_t buffer[sizeof(uint16_t) + sizeof(uint32_t)] = {0}; buffer[0] = value; add_option(option(NBMA_SHORT_LIMIT, sizeof(buffer), buffer)); } void ICMPv6::new_advert_interval(uint32_t value) { uint8_t buffer[sizeof(uint16_t) + sizeof(uint32_t)] = {0}; *((uint32_t*)(buffer + sizeof(uint16_t))) = Endian::host_to_be(value); add_option(option(ADVERT_INTERVAL, sizeof(buffer), buffer)); } void ICMPv6::new_home_agent_info(const new_ha_info_type &value) { uint8_t buffer[sizeof(uint16_t) + sizeof(uint32_t)] = {0}; *((uint16_t*)(buffer + sizeof(uint16_t))) = Endian::host_to_be(value.first); *((uint16_t*)(buffer + sizeof(uint16_t) * 2)) = Endian::host_to_be(value.second); add_option(option(HOME_AGENT_INFO, sizeof(buffer), buffer)); } void ICMPv6::source_addr_list(const addr_list_type &value) { add_addr_list(S_ADDRESS_LIST, value); } void ICMPv6::target_addr_list(const addr_list_type &value) { add_addr_list(T_ADDRESS_LIST, value); } void ICMPv6::add_addr_list(uint8_t type, const addr_list_type &value) { std::vector buffer; buffer.reserve(value.size() + 6); buffer.insert(buffer.end(), 6, 0); for(addr_list_type::const_iterator it(value.begin()); it != value.end(); ++it) buffer.insert(buffer.end(), it->begin(), it->end()); add_option(option(type, buffer.begin(), buffer.end())); } void ICMPv6::rsa_signature(const rsa_sign_type &value) { uint32_t total_sz = 4 + sizeof(value.key_hash) + value.signature.size(); uint8_t padding = 8 - total_sz % 8; if(padding == 8) padding = 0; std::vector buffer; buffer.reserve(total_sz + padding); buffer.insert(buffer.end(), 2, 0); buffer.insert(buffer.end(), value.key_hash, value.key_hash + sizeof(value.key_hash)); buffer.insert(buffer.end(), value.signature.begin(), value.signature.end()); buffer.insert(buffer.end(), padding, 0); add_option(option(RSA_SIGN, buffer.begin(), buffer.end())); } void ICMPv6::timestamp(uint64_t value) { std::vector buffer(6 + sizeof(uint64_t)); buffer.insert(buffer.begin(), 6, 0); *((uint64_t*)&buffer[6]) = Endian::host_to_be(value); add_option(option(TIMESTAMP, buffer.begin(), buffer.end())); } void ICMPv6::nonce(const nonce_type &value) { add_option(option(NONCE, value.begin(), value.end())); } void ICMPv6::ip_prefix(const ip_prefix_type &value) { std::vector buffer; buffer.reserve(6 + ipaddress_type::address_size); buffer.push_back(value.option_code); buffer.push_back(value.prefix_len); // reserved buffer.insert(buffer.end(), sizeof(uint32_t), 0); buffer.insert(buffer.end(), value.address.begin(), value.address.end()); add_option(option(IP_PREFIX, buffer.begin(), buffer.end())); } void ICMPv6::link_layer_addr(lladdr_type value) { value.address.insert(value.address.begin(), value.option_code); uint8_t padding = 8 - (2 + value.address.size()) % 8; if(padding == 8) padding = 0; value.address.insert(value.address.end(), padding, 0); add_option(option(LINK_ADDRESS, value.address.begin(), value.address.end())); } void ICMPv6::naack(const naack_type &value) { uint8_t buffer[6]; buffer[0] = value.first; buffer[1] = value.second; add_option(option(NAACK, buffer, buffer + sizeof(buffer))); } void ICMPv6::map(const map_type &value) { uint8_t buffer[sizeof(uint8_t) * 2 + sizeof(uint32_t) + ipaddress_type::address_size]; buffer[0] = value.dist << 4 | value.pref; buffer[1] = value.r << 7; *(uint32_t*)(buffer + 2) = Endian::host_to_be(value.valid_lifetime); value.address.copy(buffer + 2 + sizeof(uint32_t)); add_option(option(MAP, buffer, buffer + sizeof(buffer))); } void ICMPv6::route_info(const route_info_type &value) { uint8_t padding = 8 - value.prefix.size() % 8; if(padding == 8) padding = 0; std::vector buffer(2 + sizeof(uint32_t) + value.prefix.size() + padding); buffer[0] = value.prefix_len; buffer[1] = value.pref << 3; *(uint32_t*)&buffer[2] = Endian::host_to_be(value.route_lifetime); // copy the prefix and then fill with padding buffer.insert( std::copy(value.prefix.begin(), value.prefix.end(), buffer.begin() + 2 + sizeof(uint32_t)), padding, 0 ); add_option(option(ROUTE_INFO, buffer.begin(), buffer.end())); } void ICMPv6::recursive_dns_servers(const recursive_dns_type &value) { std::vector buffer( 2 + sizeof(uint32_t) + value.servers.size() * ipaddress_type::address_size ); buffer[0] = buffer[1] = 0; *(uint32_t*)&buffer[2] = Endian::host_to_be(value.lifetime); std::vector::iterator out = buffer.begin() + 2 + sizeof(uint32_t); typedef recursive_dns_type::servers_type::const_iterator iterator; for(iterator it = value.servers.begin(); it != value.servers.end(); ++it) out = it->copy(out); add_option(option(RECURSIVE_DNS_SERV, buffer.begin(), buffer.end())); } void ICMPv6::handover_key_request(const handover_key_req_type &value) { uint8_t padding = 8 - (value.key.size() + 4) % 8; if(padding == 8) padding = 0; std::vector buffer(2 + value.key.size() + padding); buffer[0] = padding; buffer[1] = value.AT << 4; // copy the key, and fill with padding std::fill( std::copy(value.key.begin(), value.key.end(), buffer.begin() + 2), buffer.end(), 0 ); add_option(option(HANDOVER_KEY_REQ, buffer.begin(), buffer.end())); } void ICMPv6::handover_key_reply(const handover_key_reply_type &value) { const uint32_t data_size = value.key.size() + 2 + sizeof(uint16_t); uint8_t padding = 8 - (data_size+2) % 8; if(padding == 8) padding = 0; std::vector buffer(data_size + padding); buffer[0] = padding; buffer[1] = value.AT << 4; *(uint16_t*)&buffer[2] = Endian::host_to_be(value.lifetime); // copy the key, and fill with padding std::fill( std::copy(value.key.begin(), value.key.end(), buffer.begin() + 2 + sizeof(uint16_t)), buffer.end(), 0 ); add_option(option(HANDOVER_KEY_REPLY, buffer.begin(), buffer.end())); } void ICMPv6::handover_assist_info(const handover_assist_info_type &value) { const uint32_t data_size = value.hai.size() + 2; uint8_t padding = 8 - (data_size+2) % 8; if(padding == 8) padding = 0; std::vector buffer(data_size + padding); buffer[0] = value.option_code; buffer[1] = static_cast(value.hai.size()); // copy hai + padding buffer.insert( std::copy(value.hai.begin(), value.hai.end(), buffer.begin() + 2), padding, 0 ); add_option(option(HANDOVER_ASSIST_INFO, buffer.begin(), buffer.end())); } void ICMPv6::mobile_node_identifier(const mobile_node_id_type &value) { const uint32_t data_size = value.mn.size() + 2; uint8_t padding = 8 - (data_size+2) % 8; if(padding == 8) padding = 0; std::vector buffer(data_size + padding); buffer[0] = value.option_code; buffer[1] = static_cast(value.mn.size()); // copy mn + padding buffer.insert( std::copy(value.mn.begin(), value.mn.end(), buffer.begin() + 2), padding, 0 ); add_option(option(MOBILE_NODE_ID, buffer.begin(), buffer.end())); } void ICMPv6::dns_search_list(const dns_search_list_type &value) { // at least it's got this size std::vector buffer(2 + sizeof(uint32_t)); *(uint32_t*)&buffer[2] = Endian::host_to_be(value.lifetime); typedef dns_search_list_type::domains_type::const_iterator iterator; for(iterator it = value.domains.begin(); it != value.domains.end(); ++it) { size_t prev = 0, index; do { index = it->find('.', prev); std::string::const_iterator end = (index == std::string::npos) ? it->end() : (it->begin() + index); buffer.push_back(end - (it->begin() + prev)); buffer.insert(buffer.end(), it->begin() + prev, end); prev = index + 1; } while(index != std::string::npos); // delimiter buffer.push_back(0); } uint8_t padding = 8 - (buffer.size() + 2) % 8; if(padding == 8) padding = 0; buffer.insert(buffer.end(), padding, 0); add_option(option(DNS_SEARCH_LIST, buffer.begin(), buffer.end())); } // ******************************************************************** // Option getters // ******************************************************************** ICMPv6::hwaddress_type ICMPv6::source_link_layer_addr() const { const option *opt = search_option(SOURCE_ADDRESS); if(!opt || opt->data_size() != hwaddress_type::address_size) throw option_not_found(); return hwaddress_type(opt->data_ptr()); } ICMPv6::hwaddress_type ICMPv6::target_link_layer_addr() const { const option *opt = search_option(TARGET_ADDRESS); if(!opt || opt->data_size() != hwaddress_type::address_size) throw option_not_found(); return hwaddress_type(opt->data_ptr()); } ICMPv6::prefix_info_type ICMPv6::prefix_info() const { const option *opt = search_option(PREFIX_INFO); if(!opt || opt->data_size() != 2 + sizeof(uint32_t) * 3 + ipaddress_type::address_size) throw option_not_found(); const uint8_t *ptr = opt->data_ptr(); prefix_info_type output; output.prefix_len = *ptr++; output.L = (*ptr >> 7) & 0x1; output.A = (*ptr++ >> 6) & 0x1; output.valid_lifetime = Endian::be_to_host(*(uint32_t*)ptr); ptr += sizeof(uint32_t); output.preferred_lifetime = Endian::be_to_host(*(uint32_t*)ptr); output.prefix = ptr + sizeof(uint32_t) * 2; return output; } PDU::serialization_type ICMPv6::redirect_header() const { const option *opt = search_option(REDIRECT_HEADER); if(!opt || opt->data_size() < 6) throw option_not_found(); const uint8_t *ptr = opt->data_ptr() + 6; return serialization_type(ptr, ptr + opt->data_size() - 6); } uint32_t ICMPv6::mtu() const { const option *opt = search_option(MTU); if(!opt || opt->data_size() != sizeof(uint16_t) + sizeof(uint32_t)) throw option_not_found(); return Endian::be_to_host(*(const uint32_t*)(opt->data_ptr() + sizeof(uint16_t))); } uint8_t ICMPv6::shortcut_limit() const { const option *opt = search_option(NBMA_SHORT_LIMIT); if(!opt || opt->data_size() != sizeof(uint16_t) + sizeof(uint32_t)) throw option_not_found(); return *opt->data_ptr(); } uint32_t ICMPv6::new_advert_interval() const { const option *opt = search_option(ADVERT_INTERVAL); if(!opt || opt->data_size() != sizeof(uint16_t) + sizeof(uint32_t)) throw option_not_found(); return Endian::be_to_host(*(const uint32_t*)(opt->data_ptr() + sizeof(uint16_t))); } ICMPv6::new_ha_info_type ICMPv6::new_home_agent_info() const { const option *opt = search_option(HOME_AGENT_INFO); if(!opt || opt->data_size() != sizeof(uint16_t) + sizeof(uint32_t)) throw option_not_found(); return std::make_pair( Endian::be_to_host(*(const uint16_t*)(opt->data_ptr() + sizeof(uint16_t))), Endian::be_to_host(*(const uint16_t*)(opt->data_ptr() + sizeof(uint16_t) * 2)) ); } ICMPv6::addr_list_type ICMPv6::source_addr_list() const { return search_addr_list(S_ADDRESS_LIST); } ICMPv6::addr_list_type ICMPv6::target_addr_list() const { return search_addr_list(T_ADDRESS_LIST); } ICMPv6::addr_list_type ICMPv6::search_addr_list(OptionTypes type) const { const option *opt = search_option(type); if(!opt || opt->data_size() < 6 + ipaddress_type::address_size) throw option_not_found(); addr_list_type output; const uint8_t *ptr = opt->data_ptr() + 6, *end = opt->data_ptr() + opt->data_size(); while(ptr < end) { if(ptr + ipaddress_type::address_size > end) throw option_not_found(); output.push_back(ipaddress_type(ptr)); ptr += ipaddress_type::address_size; } return output; } ICMPv6::rsa_sign_type ICMPv6::rsa_signature() const { const option *opt = search_option(RSA_SIGN); // 2 bytes reserved + at least 1 byte signature. // 16 == sizeof(rsa_sign_type::key_hash), removed the sizeof // expression since gcc 4.2 doesn't like it if(!opt || opt->data_size() < 2 + 16 + 1) throw option_not_found(); const uint8_t *ptr = opt->data_ptr() + 2; rsa_sign_type output; std::copy(ptr, ptr + sizeof(output.key_hash), output.key_hash); ptr += sizeof(output.key_hash); output.signature.assign(ptr, opt->data_ptr() + opt->data_size()); return output; } uint64_t ICMPv6::timestamp() const { const option *opt = safe_search_option( TIMESTAMP, 6 + sizeof(uint64_t) ); return Endian::be_to_host(*(uint64_t*)(opt->data_ptr() + 6)); } ICMPv6::nonce_type ICMPv6::nonce() const { const option *opt = safe_search_option( NONCE, 0 ); return nonce_type(opt->data_ptr(), opt->data_ptr() + opt->data_size()); } ICMPv6::ip_prefix_type ICMPv6::ip_prefix() const { const option *opt = safe_search_option( IP_PREFIX, 2 ); const uint8_t *ptr = opt->data_ptr(); ip_prefix_type output; output.option_code = *ptr++; output.prefix_len = *ptr++; // skip padding ptr += sizeof(uint32_t); output.address = ipaddress_type(ptr); return output; } ICMPv6::lladdr_type ICMPv6::link_layer_addr() const { // at least the option_code and 1 byte from the link layer address const option *opt = safe_search_option( LINK_ADDRESS, 2 ); const uint8_t *ptr = opt->data_ptr(); lladdr_type output(*ptr++); output.address.assign(ptr, opt->data_ptr() + opt->data_size()); return output; } ICMPv6::naack_type ICMPv6::naack() const { const option *opt = safe_search_option( NAACK, 6 ); const uint8_t *ptr = opt->data_ptr(); return naack_type(ptr[0], ptr[1]); } ICMPv6::map_type ICMPv6::map() const { const option *opt = safe_search_option( MAP, 2 + sizeof(uint32_t) + ipaddress_type::address_size ); const uint8_t *ptr = opt->data_ptr(); map_type output; output.dist = (*ptr >> 4) & 0x0f; output.pref = *ptr++ & 0x0f; output.r = (*ptr++ >> 7) & 0x01; output.valid_lifetime = *(uint32_t*)ptr; ptr += sizeof(uint32_t); output.address = ptr; return output; } ICMPv6::route_info_type ICMPv6::route_info() const { const option *opt = safe_search_option( ROUTE_INFO, 2 + sizeof(uint32_t) ); const uint8_t *ptr = opt->data_ptr(); route_info_type output; output.prefix_len = *ptr++; output.pref = (*ptr++ >> 3) & 0x3; output.route_lifetime = Endian::be_to_host(*(uint32_t*)ptr); ptr += sizeof(uint32_t); output.prefix.assign(ptr, opt->data_ptr() + opt->data_size()); return output; } ICMPv6::recursive_dns_type ICMPv6::recursive_dns_servers() const { const option *opt = safe_search_option( RECURSIVE_DNS_SERV, 2 + sizeof(uint32_t) + ipaddress_type::address_size ); const uint8_t *ptr = opt->data_ptr() + 2, *end = opt->data_ptr() + opt->data_size(); recursive_dns_type output; output.lifetime = Endian::be_to_host(*(uint32_t*)ptr); ptr += sizeof(uint32_t); while(ptr < end) { if(ptr + ipaddress_type::address_size > end) throw option_not_found(); output.servers.push_back(ptr); ptr += ipaddress_type::address_size; } return output; } ICMPv6::handover_key_req_type ICMPv6::handover_key_request() const { const option *opt = safe_search_option( HANDOVER_KEY_REQ, 2 + sizeof(uint32_t) ); const uint8_t *ptr = opt->data_ptr() + 1, *end = opt->data_ptr() + opt->data_size(); handover_key_req_type output; output.AT = (*ptr++ >> 4) & 0x3; // is there enough size for the indicated padding? if(end - ptr < *opt->data_ptr()) throw option_not_found(); output.key.assign(ptr, ptr + ((end - ptr) - *opt->data_ptr())); return output; } ICMPv6::handover_key_reply_type ICMPv6::handover_key_reply() const { const option *opt = safe_search_option( HANDOVER_KEY_REPLY, 2 + sizeof(uint32_t) ); const uint8_t *ptr = opt->data_ptr() + 1, *end = opt->data_ptr() + opt->data_size(); handover_key_reply_type output; output.AT = (*ptr++ >> 4) & 0x3; output.lifetime = Endian::be_to_host(*(uint16_t*)ptr); ptr += sizeof(uint16_t); // is there enough size for the indicated padding? if(end - ptr < *opt->data_ptr()) throw option_not_found(); output.key.assign(ptr, ptr + ((end - ptr) - *opt->data_ptr())); return output; } ICMPv6::handover_assist_info_type ICMPv6::handover_assist_info() const { const option *opt = safe_search_option( HANDOVER_ASSIST_INFO, 2 ); const uint8_t *ptr = opt->data_ptr(), *end = ptr + opt->data_size(); handover_assist_info_type output; output.option_code = *ptr++; if((end - ptr - 1) < *ptr) throw option_not_found(); output.hai.assign(ptr + 1, ptr + 1 + *ptr); return output; } ICMPv6::mobile_node_id_type ICMPv6::mobile_node_identifier() const { const option *opt = safe_search_option( MOBILE_NODE_ID, 2 ); const uint8_t *ptr = opt->data_ptr(), *end = ptr + opt->data_size(); mobile_node_id_type output; output.option_code = *ptr++; if((end - ptr - 1) < *ptr) throw option_not_found(); output.mn.assign(ptr + 1, ptr + 1 + *ptr); return output; } ICMPv6::dns_search_list_type ICMPv6::dns_search_list() const { const option *opt = safe_search_option( DNS_SEARCH_LIST, 2 + sizeof(uint32_t) ); const uint8_t *ptr = opt->data_ptr(), *end = ptr + opt->data_size(); dns_search_list_type output; output.lifetime = Endian::be_to_host(*(uint32_t*)(ptr + 2)); ptr += 2 + sizeof(uint32_t); while(ptr < end && *ptr) { std::string domain; while(ptr < end && *ptr && *ptr < (end - ptr)) { if(!domain.empty()) domain.push_back('.'); domain.insert(domain.end(), ptr + 1, ptr + *ptr + 1); ptr += *ptr + 1; } // not enough size if(ptr < end && *ptr != 0) throw option_not_found(); output.domains.push_back(domain); ptr++; } return output; } } libtins-1.1/src/icmp.cpp0000664000175000017500000001135212154360113014560 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #ifdef TINS_DEBUG #include #endif #ifndef WIN32 #define NOMINMAX #include #endif #include "icmp.h" #include "rawpdu.h" #include "utils.h" #include "exceptions.h" namespace Tins { ICMP::ICMP(Flags flag) { std::memset(&_icmp, 0, sizeof(icmphdr)); type(flag); } ICMP::ICMP(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(icmphdr)) throw malformed_packet(); std::memcpy(&_icmp, buffer, sizeof(icmphdr)); total_sz -= sizeof(icmphdr); if(total_sz) inner_pdu(new RawPDU(buffer + sizeof(icmphdr), total_sz)); } void ICMP::code(uint8_t new_code) { _icmp.code = new_code; } void ICMP::type(Flags new_type) { _icmp.type = new_type; } void ICMP::check(uint16_t new_check) { _icmp.check = Endian::host_to_be(new_check); } void ICMP::id(uint16_t new_id) { _icmp.un.echo.id = Endian::host_to_be(new_id); } void ICMP::sequence(uint16_t new_seq) { _icmp.un.echo.sequence = Endian::host_to_be(new_seq); } void ICMP::gateway(uint32_t new_gw) { _icmp.un.gateway = Endian::host_to_be(new_gw); } void ICMP::mtu(uint16_t new_mtu) { _icmp.un.frag.mtu = Endian::host_to_be(new_mtu); } void ICMP::pointer(uint8_t new_pointer) { _icmp.un.pointer = new_pointer; } uint32_t ICMP::header_size() const { return sizeof(icmphdr); } void ICMP::set_echo_request(uint16_t id, uint16_t seq) { type(ECHO_REQUEST); this->id(id); sequence(seq); } void ICMP::set_echo_reply(uint16_t id, uint16_t seq) { type(ECHO_REPLY); this->id(id); sequence(seq); } void ICMP::set_info_request(uint16_t id, uint16_t seq) { type(INFO_REQUEST); code(0); this->id(id); sequence(seq); } void ICMP::set_info_reply(uint16_t id, uint16_t seq) { type(INFO_REPLY); code(0); this->id(id); sequence(seq); } void ICMP::set_dest_unreachable() { type(DEST_UNREACHABLE); } void ICMP::set_time_exceeded(bool ttl_exceeded) { type(TIME_EXCEEDED); code((ttl_exceeded) ? 0 : 1); } void ICMP::set_param_problem(bool set_pointer, uint8_t bad_octet) { type(PARAM_PROBLEM); if(set_pointer) { code(0); pointer(bad_octet); } else code(1); } void ICMP::set_source_quench() { type(SOURCE_QUENCH); } void ICMP::set_redirect(uint8_t icode, uint32_t address) { type(REDIRECT); code(icode); gateway(address); } void ICMP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) { #ifdef TINS_DEBUG assert(total_sz >= sizeof(icmphdr)); #endif if(!_icmp.check) { uint32_t checksum = Utils::do_checksum(buffer + sizeof(icmphdr), buffer + total_sz) + Utils::do_checksum((uint8_t*)&_icmp, ((uint8_t*)&_icmp) + sizeof(icmphdr)); while (checksum >> 16) checksum = (checksum & 0xffff) + (checksum >> 16); _icmp.check = Endian::host_to_be(~checksum); } memcpy(buffer, &_icmp, sizeof(icmphdr)); _icmp.check = 0; } bool ICMP::matches_response(const uint8_t *ptr, uint32_t total_sz) const { if(total_sz < sizeof(icmphdr)) return false; const icmphdr *icmp_ptr = (const icmphdr*)ptr; if(_icmp.type == ECHO_REQUEST && icmp_ptr->type == ECHO_REPLY) { return icmp_ptr->un.echo.id == _icmp.un.echo.id && icmp_ptr->un.echo.sequence == _icmp.un.echo.sequence; } return false; } } // namespace Tins libtins-1.1/src/handshake_capturer.cpp0000664000175000017500000000716712154360113017474 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include "handshake_capturer.h" #include "dot11/dot11_data.h" namespace Tins { bool RSNHandshakeCapturer::process_packet(const PDU &pdu) { const RSNEAPOL *eapol = pdu.find_pdu(); const Dot11Data *dot11 = pdu.find_pdu(); if(!eapol || !dot11) return false; std::pair addresses; if(dot11->to_ds()) { addresses.first = dot11->addr1(); addresses.second = dot11->addr2(); } else if(dot11->from_ds()) { addresses.first = dot11->addr2(); addresses.second = dot11->addr1(); } else return false; // 1st if(eapol->key_t() && eapol->key_ack() && !eapol->key_mic() && !eapol->install()) { handshakes_[addresses].assign(eapol, eapol + 1); } else if(eapol->key_t() && eapol->key_mic() && !eapol->install() && !eapol->key_ack()) { if(*std::max_element(eapol->nonce(), eapol->nonce() + RSNEAPOL::nonce_size) > 0) do_insert(addresses, eapol, 1); else if(do_insert(addresses, eapol, 3)) { completed_handshakes_.push_back( handshake_type( addresses.first, addresses.second, handshakes_[addresses] ) ); handshakes_.erase(addresses); return true; } } else if(eapol->key_t() && eapol->install() && eapol->key_ack() && eapol->key_mic()) { do_insert(addresses, eapol, 2); } return false; } bool RSNHandshakeCapturer::do_insert(const handshake_map::key_type &key, const RSNEAPOL *eapol, size_t expected) { handshake_map::iterator iter = handshakes_.find(key); if(iter != handshakes_.end()) { if(iter->second.size() != expected) { // skip repeated if(iter->second.size() != expected + 1) iter->second.clear(); } else { iter->second.push_back(*eapol); return true; } } return false; } } // namespace Tins; libtins-1.1/src/ethernetII.cpp0000664000175000017500000001312212154360113015665 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifdef TINS_DEBUG #include #endif #include #include #include #include "macros.h" #ifndef WIN32 #if defined(BSD) || defined(__FreeBSD_kernel__) #include #else #include #endif #include #include #endif #include "ethernetII.h" #include "packet_sender.h" #include "rawpdu.h" #include "ip.h" #include "ipv6.h" #include "arp.h" #include "constants.h" #include "internals.h" #include "exceptions.h" namespace Tins { const EthernetII::address_type EthernetII::BROADCAST("ff:ff:ff:ff:ff:ff"); EthernetII::EthernetII(const address_type &dst_hw_addr, const address_type &src_hw_addr) { memset(&_eth, 0, sizeof(ethhdr)); dst_addr(dst_hw_addr); src_addr(src_hw_addr); _eth.payload_type = 0; } EthernetII::EthernetII(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(ethhdr)) throw malformed_packet(); memcpy(&_eth, buffer, sizeof(ethhdr)); buffer += sizeof(ethhdr); total_sz -= sizeof(ethhdr); if(total_sz) { inner_pdu( Internals::pdu_from_flag( (Constants::Ethernet::e)payload_type(), buffer, total_sz ) ); } } void EthernetII::dst_addr(const address_type &new_dst_addr) { new_dst_addr.copy(_eth.dst_mac); } void EthernetII::src_addr(const address_type &new_src_addr) { new_src_addr.copy(_eth.src_mac); } void EthernetII::payload_type(uint16_t new_payload_type) { this->_eth.payload_type = Endian::host_to_be(new_payload_type); } uint32_t EthernetII::header_size() const { return sizeof(ethhdr); } #ifndef WIN32 void EthernetII::send(PacketSender &sender, const NetworkInterface &iface) { if(!iface) throw invalid_interface(); #if !defined(BSD) && !defined(__FreeBSD_kernel__) struct sockaddr_ll addr; memset(&addr, 0, sizeof(struct sockaddr_ll)); addr.sll_family = Endian::host_to_be(PF_PACKET); addr.sll_protocol = Endian::host_to_be(ETH_P_ALL); addr.sll_halen = address_type::address_size; addr.sll_ifindex = iface.id(); memcpy(&(addr.sll_addr), _eth.dst_mac, address_type::address_size); sender.send_l2(*this, (struct sockaddr*)&addr, (uint32_t)sizeof(addr)); #else sender.send_l2(*this, 0, 0, iface); #endif } #endif // WIN32 bool EthernetII::matches_response(const uint8_t *ptr, uint32_t total_sz) const { if(total_sz < sizeof(ethhdr)) return false; const size_t addr_sz = address_type::address_size; const ethhdr *eth_ptr = (const ethhdr*)ptr; if(std::equal(_eth.src_mac, _eth.src_mac + addr_sz, eth_ptr->dst_mac)) { if(std::equal(_eth.src_mac, _eth.src_mac + addr_sz, eth_ptr->dst_mac) || dst_addr() == BROADCAST || (_eth.src_mac[0] == 0x33 && _eth.src_mac[1] == 0x33)) { return (inner_pdu()) ? inner_pdu()->matches_response(ptr + sizeof(_eth), total_sz - sizeof(_eth)) : true; } } return false; } void EthernetII::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) { #ifdef TINS_DEBUG assert(total_sz >= header_size()); #endif /* Inner type defaults to IP */ if ((_eth.payload_type == 0) && inner_pdu()) { Constants::Ethernet::e flag = Internals::pdu_flag_to_ether_type( inner_pdu()->pdu_type() ); payload_type(static_cast(flag)); } memcpy(buffer, &_eth, sizeof(ethhdr)); } #ifndef WIN32 PDU *EthernetII::recv_response(PacketSender &sender, const NetworkInterface &iface) { #if !defined(BSD) && !defined(__FreeBSD_kernel__) struct sockaddr_ll addr; memset(&addr, 0, sizeof(struct sockaddr_ll)); addr.sll_family = Endian::host_to_be(PF_PACKET); addr.sll_protocol = Endian::host_to_be(ETH_P_ALL); addr.sll_halen = address_type::address_size; addr.sll_ifindex = iface.id(); memcpy(&(addr.sll_addr), _eth.dst_mac, address_type::address_size); return sender.recv_l2(*this, (struct sockaddr*)&addr, (uint32_t)sizeof(addr)); #else return sender.recv_l2(*this, 0, 0, iface); #endif } #endif // WIN32 } libtins-1.1/src/eapol.cpp0000664000175000017500000001737312154360113014741 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #ifdef TINS_DEBUG #include #endif #include #include "eapol.h" #include "rsn_information.h" #include "exceptions.h" namespace Tins { EAPOL::EAPOL(uint8_t packet_type, EAPOLTYPE type) { std::memset(&_header, 0, sizeof(_header)); _header.version = 1; _header.packet_type = packet_type; _header.type = (uint8_t)type; } EAPOL::EAPOL(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(_header)) throw malformed_packet(); std::memcpy(&_header, buffer, sizeof(_header)); } EAPOL *EAPOL::from_bytes(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(eapolhdr)) throw malformed_packet(); const eapolhdr *ptr = (const eapolhdr*)buffer; switch(ptr->type) { case RC4: return new Tins::RC4EAPOL(buffer, total_sz); break; case RSN: case EAPOL_WPA: return new Tins::RSNEAPOL(buffer, total_sz); break; } return 0; } void EAPOL::version(uint8_t new_version) { _header.version = new_version; } void EAPOL::packet_type(uint8_t new_ptype) { _header.packet_type = new_ptype; } void EAPOL::length(uint16_t new_length) { _header.length = Endian::host_to_be(new_length); } void EAPOL::type(uint8_t new_type) { _header.type = new_type; } void EAPOL::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) { #ifdef TINS_DEBUG assert(total_sz >= header_size()); #endif std::memcpy(buffer, &_header, sizeof(_header)); write_body(buffer + sizeof(_header), total_sz - sizeof(_header)); } /* RC4EAPOL */ RC4EAPOL::RC4EAPOL() : EAPOL(0x03, RC4) { std::memset(&_header, 0, sizeof(_header)); } RC4EAPOL::RC4EAPOL(const uint8_t *buffer, uint32_t total_sz) : EAPOL(buffer, total_sz) { buffer += sizeof(eapolhdr); total_sz -= sizeof(eapolhdr); if(total_sz < sizeof(_header)) throw malformed_packet(); std::memcpy(&_header, buffer, sizeof(_header)); buffer += sizeof(_header); total_sz -= sizeof(_header); if(total_sz == key_length()) _key.assign(buffer, buffer + total_sz); } void RC4EAPOL::key_length(uint16_t new_key_length) { _header.key_length = Endian::host_to_be(new_key_length); } void RC4EAPOL::replay_counter(uint64_t new_replay_counter) { _header.replay_counter = Endian::host_to_be(new_replay_counter); } void RC4EAPOL::key_iv(const uint8_t *new_key_iv) { std::copy(new_key_iv, new_key_iv + sizeof(_header.key_iv), _header.key_iv); } void RC4EAPOL::key_flag(small_uint<1> new_key_flag) { _header.key_flag = new_key_flag; } void RC4EAPOL::key_index(small_uint<7> new_key_index) { _header.key_index = new_key_index; } void RC4EAPOL::key_sign(const uint8_t *new_key_sign) { std::memcpy(_header.key_sign, new_key_sign, sizeof(_header.key_sign)); } void RC4EAPOL::key(const key_type &new_key) { _key = new_key; } uint32_t RC4EAPOL::header_size() const { return sizeof(eapolhdr) + sizeof(_header) + _key.size(); } void RC4EAPOL::write_body(uint8_t *buffer, uint32_t total_sz) { #ifdef TINS_DEBUG assert(total_sz >= sizeof(_header) + _key.size()); #endif if(_key.size()) _header.key_length = Endian::host_to_be(_key.size()); std::memcpy(buffer, &_header, sizeof(_header)); buffer += sizeof(_header); std::copy(_key.begin(), _key.end(), buffer); } /* RSNEAPOL */ RSNEAPOL::RSNEAPOL() : EAPOL(0x03, RSN) { std::memset(&_header, 0, sizeof(_header)); } RSNEAPOL::RSNEAPOL(const uint8_t *buffer, uint32_t total_sz) : EAPOL(buffer, total_sz) { buffer += sizeof(eapolhdr); total_sz -= sizeof(eapolhdr); if(total_sz < sizeof(_header)) throw malformed_packet(); std::memcpy(&_header, buffer, sizeof(_header)); buffer += sizeof(_header); total_sz -= sizeof(_header); if(total_sz == wpa_length()) _key.assign(buffer, buffer + total_sz); } void RSNEAPOL::nonce(const uint8_t *new_nonce) { std::copy(new_nonce, new_nonce + nonce_size, _header.nonce); } void RSNEAPOL::rsc(const uint8_t *new_rsc) { std::copy(new_rsc, new_rsc + rsc_size, _header.rsc); } void RSNEAPOL::id(const uint8_t *new_id) { std::copy(new_id, new_id + id_size, _header.id); } void RSNEAPOL::replay_counter(uint64_t new_replay_counter) { _header.replay_counter = Endian::host_to_be(new_replay_counter); } void RSNEAPOL::mic(const uint8_t *new_mic) { std::copy(new_mic, new_mic + mic_size, _header.mic); } void RSNEAPOL::wpa_length(uint16_t new_wpa_length) { _header.wpa_length = Endian::host_to_be(new_wpa_length); } void RSNEAPOL::key_iv(const uint8_t *new_key_iv) { std::copy(new_key_iv, new_key_iv + sizeof(_header.key_iv), _header.key_iv); } void RSNEAPOL::key_length(uint16_t new_key_length) { _header.key_length = Endian::host_to_be(new_key_length); } void RSNEAPOL::key(const key_type &new_key) { _key = new_key; _header.key_t = 0; } void RSNEAPOL::key_mic(small_uint<1> new_key_mic) { _header.key_mic = new_key_mic; } void RSNEAPOL::secure(small_uint<1> new_secure) { _header.secure = new_secure; } void RSNEAPOL::error(small_uint<1> new_error) { _header.error = new_error; } void RSNEAPOL::request(small_uint<1> new_request) { _header.request = new_request; } void RSNEAPOL::encrypted(small_uint<1 > new_encrypted) { _header.encrypted = new_encrypted; } void RSNEAPOL::key_descriptor(small_uint<3> new_key_descriptor) { _header.key_descriptor = new_key_descriptor; } void RSNEAPOL::key_t(small_uint<1> new_key_t) { _header.key_t = new_key_t; } void RSNEAPOL::key_index(small_uint<2> new_key_index) { _header.key_index = new_key_index; } void RSNEAPOL::install(small_uint<1> new_install) { _header.install = new_install; } void RSNEAPOL::key_ack(small_uint<1> new_key_ack) { _header.key_ack = new_key_ack; } uint32_t RSNEAPOL::header_size() const { return sizeof(eapolhdr) + sizeof(_header) + _key.size(); } void RSNEAPOL::write_body(uint8_t *buffer, uint32_t total_sz) { #ifdef TINS_DEBUG assert(total_sz >= header_size() - sizeof(eapolhdr)); #endif if(_key.size()) { if(!_header.key_t) { _header.key_length = Endian::host_to_be(32); wpa_length(_key.size()); } else if(_key.size()) { wpa_length(_key.size()); } } std::memcpy(buffer, &_header, sizeof(_header)); buffer += sizeof(_header); std::copy(_key.begin(), _key.end(), buffer); } } libtins-1.1/src/dot3.cpp0000664000175000017500000001234412154360113014503 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifdef TINS_DEBUG #include #endif #include #include #include #include "macros.h" #ifndef WIN32 #if defined(BSD) || defined(__FreeBSD_kernel__) #include #else #include #endif #include #include #endif #include "dot3.h" #include "packet_sender.h" #include "llc.h" #include "exceptions.h" namespace Tins { const Dot3::address_type Dot3::BROADCAST("ff:ff:ff:ff:ff:ff"); Dot3::Dot3(const address_type &dst_hw_addr, const address_type &src_hw_addr) { memset(&_eth, 0, sizeof(ethhdr)); this->dst_addr(dst_hw_addr); this->src_addr(src_hw_addr); this->_eth.length = 0; } Dot3::Dot3(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(ethhdr)) throw malformed_packet(); memcpy(&_eth, buffer, sizeof(ethhdr)); buffer += sizeof(ethhdr); total_sz -= sizeof(ethhdr); if(total_sz) inner_pdu(new Tins::LLC(buffer, total_sz)); } void Dot3::dst_addr(const address_type &new_dst_mac) { std::copy(new_dst_mac.begin(), new_dst_mac.end(), _eth.dst_mac); } void Dot3::src_addr(const address_type &new_src_mac) { std::copy(new_src_mac.begin(), new_src_mac.end(), _eth.src_mac); } void Dot3::length(uint16_t new_length) { this->_eth.length = Endian::host_to_be(new_length); } uint32_t Dot3::header_size() const { return sizeof(ethhdr); } #ifndef WIN32 void Dot3::send(PacketSender &sender, const NetworkInterface &iface) { if(!iface) throw invalid_interface(); #if !defined(BSD) && !defined(__FreeBSD_kernel__) struct sockaddr_ll addr; memset(&addr, 0, sizeof(struct sockaddr_ll)); addr.sll_family = Endian::host_to_be(PF_PACKET); addr.sll_protocol = Endian::host_to_be(ETH_P_ALL); addr.sll_halen = address_type::address_size; addr.sll_ifindex = iface.id(); memcpy(&(addr.sll_addr), _eth.dst_mac, sizeof(_eth.dst_mac)); sender.send_l2(*this, (struct sockaddr*)&addr, (uint32_t)sizeof(addr)); #else sender.send_l2(*this, 0, 0, iface); #endif } #endif // WIN32 bool Dot3::matches_response(const uint8_t *ptr, uint32_t total_sz) const { if(total_sz < sizeof(ethhdr)) return false; const size_t addr_sz = address_type::address_size; const ethhdr *eth_ptr = (const ethhdr*)ptr; if(std::equal(_eth.src_mac, _eth.src_mac + addr_sz, eth_ptr->dst_mac)) { if(std::equal(_eth.src_mac, _eth.src_mac + addr_sz, eth_ptr->dst_mac) || dst_addr() == BROADCAST) { ptr += sizeof(ethhdr); total_sz -= sizeof(ethhdr); return inner_pdu() ? inner_pdu()->matches_response(ptr, total_sz) : true; } } return false; } void Dot3::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) { bool set_length = _eth.length == 0; #ifdef TINS_DEBUG assert(total_sz >= header_size()); #endif if (set_length) _eth.length = Endian::host_to_be(size() - sizeof(_eth)); memcpy(buffer, &_eth, sizeof(ethhdr)); if (set_length) _eth.length = 0; } #ifndef WIN32 PDU *Dot3::recv_response(PacketSender &sender, const NetworkInterface &iface) { if(!iface) throw invalid_interface(); #if !defined(BSD) && !defined(__FreeBSD_kernel__) struct sockaddr_ll addr; memset(&addr, 0, sizeof(struct sockaddr_ll)); addr.sll_family = Endian::host_to_be(PF_PACKET); addr.sll_protocol = Endian::host_to_be(ETH_P_802_3); addr.sll_halen = address_type::address_size; addr.sll_ifindex = iface.id(); memcpy(&(addr.sll_addr), _eth.dst_mac, sizeof(_eth.dst_mac)); return sender.recv_l2(*this, (struct sockaddr*)&addr, (uint32_t)sizeof(addr)); #else return sender.recv_l2(*this, 0, 0, iface); #endif } #endif // WIN32 } libtins-1.1/src/dot1q.cpp0000664000175000017500000001017612154360113014663 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include #include "dot1q.h" #include "internals.h" #include "exceptions.h" namespace Tins { Dot1Q::Dot1Q(small_uint<12> tag_id, bool append_pad) : _header(), _append_padding(append_pad) { id(tag_id); } Dot1Q::Dot1Q(const uint8_t *buffer, uint32_t total_sz) : _append_padding() { if(total_sz < sizeof(_header)) throw malformed_packet(); std::memcpy(&_header, buffer, sizeof(_header)); buffer += sizeof(_header); total_sz -= sizeof(_header); if(total_sz) { inner_pdu( Internals::pdu_from_flag( (Constants::Ethernet::e)payload_type(), buffer, total_sz ) ); } } void Dot1Q::priority(small_uint<3> new_priority) { _header.priority = new_priority; } void Dot1Q::cfi(small_uint<1> new_cfi) { _header.cfi = new_cfi; } void Dot1Q::id(small_uint<12> new_id) { #if TINS_IS_LITTLE_ENDIAN _header.idL = new_id & 0xff; _header.idH = new_id >> 8; #else _header.id = new_id; #endif } void Dot1Q::payload_type(uint16_t new_type) { _header.type = Endian::host_to_be(new_type); } uint32_t Dot1Q::header_size() const { return sizeof(_header); } uint32_t Dot1Q::trailer_size() const { if(_append_padding) { uint32_t total_size = sizeof(_header); if(inner_pdu()) total_size += inner_pdu()->size(); return (total_size > 50) ? 0 : (50 - total_size); } else return 0; } void Dot1Q::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) { uint32_t trailer = trailer_size(); #ifdef TINS_DEBUG assert(total_sz >= sizeof(_header) + trailer); #endif if ((payload_type() == 0) && inner_pdu()) { Constants::Ethernet::e flag = Internals::pdu_flag_to_ether_type( inner_pdu()->pdu_type() ); payload_type(static_cast(flag)); } std::memcpy(buffer, &_header, sizeof(_header)); buffer += sizeof(_header) + inner_pdu()->size(); std::fill(buffer, buffer + trailer, 0); } #if TINS_IS_LITTLE_ENDIAN uint16_t Dot1Q::get_id(const dot1q_hdr *hdr) { return hdr->idL | (hdr->idH << 8); } #else uint16_t Dot1Q::get_id(const dot1q_hdr *hdr) { return hdr->id; } #endif void Dot1Q::append_padding(bool value) { _append_padding = value; } bool Dot1Q::matches_response(const uint8_t *ptr, uint32_t total_sz) const { if(total_sz < sizeof(_header)) return false; const dot1q_hdr *dot1q_ptr = (const dot1q_hdr*)ptr; if(get_id(dot1q_ptr) == get_id(&_header)) { ptr += sizeof(_header); total_sz -= sizeof(_header); return inner_pdu() ? inner_pdu()->matches_response(ptr, total_sz) : true; } return false; } } libtins-1.1/src/dot11/0000775000175000017500000000000012154360113014052 5ustar matiasmatiaslibtins-1.1/src/dot11/dot11_probe.cpp0000664000175000017500000000631112154360113016676 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include "dot11/dot11_probe.h" namespace Tins { /* Probe Request */ Dot11ProbeRequest::Dot11ProbeRequest(const address_type &dst_hw_addr, const address_type &src_hw_addr) : Dot11ManagementFrame(dst_hw_addr, src_hw_addr) { this->subtype(Dot11::PROBE_REQ); } Dot11ProbeRequest::Dot11ProbeRequest(const uint8_t *buffer, uint32_t total_sz) : Dot11ManagementFrame(buffer, total_sz) { uint32_t sz = management_frame_size(); buffer += sz; total_sz -= sz; parse_tagged_parameters(buffer, total_sz); } /* Probe Response */ Dot11ProbeResponse::Dot11ProbeResponse(const address_type &dst_hw_addr, const address_type &src_hw_addr) : Dot11ManagementFrame(dst_hw_addr, src_hw_addr) { this->subtype(Dot11::PROBE_RESP); memset(&_body, 0, sizeof(_body)); } Dot11ProbeResponse::Dot11ProbeResponse(const uint8_t *buffer, uint32_t total_sz) : Dot11ManagementFrame(buffer, total_sz) { uint32_t sz = management_frame_size(); buffer += sz; total_sz -= sz; if(total_sz < sizeof(_body)) throw malformed_packet(); memcpy(&_body, buffer, sizeof(_body)); buffer += sizeof(_body); total_sz -= sizeof(_body); parse_tagged_parameters(buffer, total_sz); } void Dot11ProbeResponse::timestamp(uint64_t new_timestamp) { this->_body.timestamp = Endian::host_to_le(new_timestamp); } void Dot11ProbeResponse::interval(uint16_t new_interval) { this->_body.interval = Endian::host_to_le(new_interval); } uint32_t Dot11ProbeResponse::header_size() const { return Dot11ManagementFrame::header_size() + sizeof(this->_body); } uint32_t Dot11ProbeResponse::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) { uint32_t sz = sizeof(this->_body); #ifdef TINS_DEBUG assert(sz <= total_sz); #endif memcpy(buffer, &this->_body, sz); return sz; } } // namespace Tinslibtins-1.1/src/dot11/dot11_mgmt.cpp0000664000175000017500000005321012154360113016533 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include "dot11/dot11_mgmt.h" #include "rsn_information.h" namespace Tins { /* Dot11ManagementFrame */ Dot11ManagementFrame::Dot11ManagementFrame(const uint8_t *buffer, uint32_t total_sz) : Dot11(buffer, total_sz) { buffer += sizeof(ieee80211_header); total_sz -= sizeof(ieee80211_header); if(total_sz < sizeof(_ext_header)) throw malformed_packet(); std::memcpy(&_ext_header, buffer, sizeof(_ext_header)); total_sz -= sizeof(_ext_header); if(from_ds() && to_ds()) { if(total_sz >= _addr4.size()) _addr4 = buffer + sizeof(_ext_header); else throw malformed_packet(); } } Dot11ManagementFrame::Dot11ManagementFrame(const address_type &dst_hw_addr, const address_type &src_hw_addr) : Dot11(dst_hw_addr) { type(Dot11::MANAGEMENT); memset(&_ext_header, 0, sizeof(_ext_header)); addr2(src_hw_addr); } uint32_t Dot11ManagementFrame::header_size() const { uint32_t sz = Dot11::header_size() + sizeof(_ext_header); if (this->from_ds() && this->to_ds()) sz += 6; return sz; } void Dot11ManagementFrame::addr2(const address_type &new_addr2) { std::copy(new_addr2.begin(), new_addr2.end(), _ext_header.addr2); } void Dot11ManagementFrame::addr3(const address_type &new_addr3) { std::copy(new_addr3.begin(), new_addr3.end(), _ext_header.addr3); } void Dot11ManagementFrame::frag_num(small_uint<4> new_frag_num) { #if TINS_IS_LITTLE_ENDIAN _ext_header.frag_seq = new_frag_num | (_ext_header.frag_seq & 0xfff0); #else _ext_header.frag_seq = (new_frag_num << 8) | (_ext_header.frag_seq & 0xf0ff); #endif } void Dot11ManagementFrame::seq_num(small_uint<12> new_seq_num) { #if TINS_IS_LITTLE_ENDIAN _ext_header.frag_seq = (new_seq_num << 4) | (_ext_header.frag_seq & 0xf); #else _ext_header.frag_seq = Endian::host_to_le(new_seq_num << 4) | (_ext_header.frag_seq & 0xf00); #endif } void Dot11ManagementFrame::addr4(const address_type &new_addr4) { _addr4 = new_addr4; } uint32_t Dot11ManagementFrame::write_ext_header(uint8_t *buffer, uint32_t total_sz) { uint32_t written = sizeof(_ext_header); memcpy(buffer, &_ext_header, sizeof(this->_ext_header)); buffer += sizeof(_ext_header); if (from_ds() && to_ds()) { written += 6; std::copy(_addr4.begin(), _addr4.end(), buffer); } return written; } void Dot11ManagementFrame::ssid(const std::string &new_ssid) { add_tagged_option(Dot11::SSID, new_ssid.size(), (const uint8_t*)new_ssid.c_str()); } void Dot11ManagementFrame::rsn_information(const RSNInformation& info) { RSNInformation::serialization_type buffer = info.serialize(); add_tagged_option(RSN, buffer.size(), &buffer[0]); } uint8_t *Dot11ManagementFrame::serialize_rates(const rates_type &rates) { uint8_t *buffer = new uint8_t[rates.size()], *ptr = buffer; for(rates_type::const_iterator it = rates.begin(); it != rates.end(); ++it) { uint8_t result = *it * 2; if(result == 2 || result == 4 || result == 11 || result == 22) result |= 0x80; *(ptr++) = result; } return buffer; } Dot11ManagementFrame::rates_type Dot11ManagementFrame::deserialize_rates(const option *opt) { rates_type output; const uint8_t *ptr = opt->data_ptr(), *end = ptr + opt->data_size(); while(ptr != end) { output.push_back(float(*(ptr++) & 0x7f) / 2); } return output; } void Dot11ManagementFrame::supported_rates(const rates_type &new_rates) { uint8_t *buffer = serialize_rates(new_rates); add_tagged_option(SUPPORTED_RATES, new_rates.size(), buffer); delete[] buffer; } void Dot11ManagementFrame::extended_supported_rates(const rates_type &new_rates) { uint8_t *buffer = serialize_rates(new_rates); add_tagged_option(EXT_SUPPORTED_RATES, new_rates.size(), buffer); delete[] buffer; } void Dot11ManagementFrame::qos_capability(uint8_t new_qos_capability) { add_tagged_option(QOS_CAPABILITY, 1, &new_qos_capability); } void Dot11ManagementFrame::power_capability(uint8_t min_power, uint8_t max_power) { uint8_t buffer[2]; buffer[0] = min_power; buffer[1] = max_power; add_tagged_option(POWER_CAPABILITY, 2, buffer); } void Dot11ManagementFrame::supported_channels(const channels_type &new_channels) { uint8_t* buffer = new uint8_t[new_channels.size() * 2]; uint8_t* ptr = buffer; for(channels_type::const_iterator it = new_channels.begin(); it != new_channels.end(); ++it) { *(ptr++) = it->first; *(ptr++) = it->second; } add_tagged_option(SUPPORTED_CHANNELS, new_channels.size() * 2, buffer); delete[] buffer; } void Dot11ManagementFrame::edca_parameter_set(uint32_t ac_be, uint32_t ac_bk, uint32_t ac_vi, uint32_t ac_vo) { uint8_t buffer[18]; buffer[0] = 0; buffer[1] = 0; uint32_t* ptr = (uint32_t*)(buffer + 2); *(ptr++) = Endian::host_to_le(ac_be); *(ptr++) = Endian::host_to_le(ac_bk); *(ptr++) = Endian::host_to_le(ac_vi); *(ptr++) = Endian::host_to_le(ac_vo); add_tagged_option(EDCA, sizeof(buffer), buffer); } void Dot11ManagementFrame::request_information(const request_info_type elements) { uint8_t *buffer = new uint8_t[elements.size()], *ptr = buffer; for (request_info_type::const_iterator it = elements.begin(); it != elements.end(); ++it) *(ptr++) = *it; add_tagged_option(REQUEST_INFORMATION, elements.size(), buffer); delete[] buffer; } void Dot11ManagementFrame::fh_parameter_set(fh_params_set fh_params) { fh_params.dwell_time = Endian::host_to_le(fh_params.dwell_time); fh_params.hop_set = fh_params.hop_set; fh_params.hop_pattern = fh_params.hop_pattern; fh_params.hop_index = fh_params.hop_index; add_tagged_option(FH_SET, sizeof(fh_params_set), (uint8_t*)&fh_params); } void Dot11ManagementFrame::ds_parameter_set(uint8_t current_channel) { add_tagged_option(DS_SET, 1, ¤t_channel); } void Dot11ManagementFrame::cf_parameter_set(cf_params_set params) { params.cfp_count = params.cfp_count; params.cfp_period = params.cfp_period; params.cfp_max_duration = Endian::host_to_le(params.cfp_max_duration); params.cfp_dur_remaining = Endian::host_to_le(params.cfp_dur_remaining); add_tagged_option(CF_SET, sizeof(params), (uint8_t*)¶ms); } void Dot11ManagementFrame::ibss_parameter_set(uint16_t atim_window) { atim_window = Endian::host_to_le(atim_window); add_tagged_option(IBSS_SET, 2, (uint8_t*)&atim_window); } void Dot11ManagementFrame::ibss_dfs(const ibss_dfs_params ¶ms) { uint8_t sz = address_type::address_size + sizeof(uint8_t) + sizeof(uint8_t) * 2 * params.channel_map.size(); uint8_t* buffer = new uint8_t[sz]; uint8_t* ptr_buffer = buffer; ptr_buffer = params.dfs_owner.copy(ptr_buffer); *(ptr_buffer++) = params.recovery_interval; for (channels_type::const_iterator it = params.channel_map.begin(); it != params.channel_map.end(); ++it) { *(ptr_buffer++) = it->first; *(ptr_buffer++) = it->second; } add_tagged_option(IBSS_DFS, sz, buffer); delete[] buffer; } void Dot11ManagementFrame::country(const country_params ¶ms) { if ((params.first_channel.size() != params.number_channels.size()) || (params.number_channels.size() != params.max_transmit_power.size())) throw std::runtime_error("The length of the lists are distinct"); if(params.country.size() != 3) throw std::runtime_error("Invalid country identifier length"); size_t sz = sizeof(uint8_t) * 3 * params.first_channel.size() + params.country.size(); // Use 1 byte padding at the end if the length is odd. if((sz & 1) == 1) sz++; std::vector buffer(sz); uint8_t *ptr = std::copy(params.country.begin(), params.country.end(), &buffer[0]); for(size_t i(0); i < params.first_channel.size(); ++i) { *(ptr++) = params.first_channel[i]; *(ptr++) = params.number_channels[i]; *(ptr++) = params.max_transmit_power[i]; } add_tagged_option(COUNTRY, sz, &buffer[0]); } void Dot11ManagementFrame::fh_parameters(uint8_t prime_radix, uint8_t number_channels) { uint8_t buffer[2]; buffer[0] = prime_radix; buffer[1] = number_channels; add_tagged_option(HOPPING_PATTERN_PARAMS, 2, buffer); } void Dot11ManagementFrame::fh_pattern_table(const fh_pattern_type ¶ms) { std::vector data(sizeof(uint8_t) * 4 + params.random_table.size()); uint8_t *ptr = &data[0]; *(ptr++) = params.flag; *(ptr++) = params.number_of_sets; *(ptr++) = params.modulus; *(ptr++) = params.offset; fh_pattern_type::container_type::const_iterator it(params.random_table.begin()); for(; it != params.random_table.end(); ++it) *(ptr++) = *it; add_tagged_option(HOPPING_PATTERN_TABLE, data.size(), &data[0]); } void Dot11ManagementFrame::power_constraint(uint8_t local_power_constraint) { add_tagged_option(POWER_CONSTRAINT, 1, &local_power_constraint); } void Dot11ManagementFrame::channel_switch(const channel_switch_type &data) { uint8_t buffer[3]; buffer[0] = data.switch_mode; buffer[1] = data.new_channel; buffer[2] = data.switch_count; add_tagged_option(CHANNEL_SWITCH, 3, buffer); } void Dot11ManagementFrame::quiet(const quiet_type &data) { uint8_t buffer[6]; uint16_t* ptr_buffer = (uint16_t*)(buffer + 2); buffer[0] = data.quiet_count; buffer[1] = data.quiet_period; ptr_buffer[0] = Endian::host_to_le(data.quiet_duration); ptr_buffer[1] = Endian::host_to_le(data.quiet_offset); add_tagged_option(QUIET, sizeof(buffer), buffer); } void Dot11ManagementFrame::tpc_report(uint8_t transmit_power, uint8_t link_margin) { uint8_t buffer[2]; buffer[0] = transmit_power; buffer[1] = link_margin; add_tagged_option(TPC_REPORT, 2, buffer); } void Dot11ManagementFrame::erp_information(uint8_t value) { add_tagged_option(ERP_INFORMATION, 1, &value); } void Dot11ManagementFrame::bss_load(const bss_load_type &data) { uint8_t buffer[5]; uint16_t dummy = Endian::host_to_le(data.station_count); //*(uint16_t*)buffer = Endian::host_to_le(data.station_count); #if TINS_IS_LITTLE_ENDIAN buffer[0] = dummy & 0xff; buffer[1] = (dummy >> 8) & 0xff; #else buffer[0] = (dummy >> 8) & 0xff; buffer[1] = dummy & 0xff; #endif buffer[2] = data.channel_utilization; dummy = Endian::host_to_le(data.available_capacity); #if TINS_IS_LITTLE_ENDIAN buffer[3] = dummy & 0xff; buffer[4] = (dummy >> 8) & 0xff; #else buffer[3] = (dummy >> 8) & 0xff; buffer[4] = dummy & 0xff; #endif //*(uint16_t*)(buffer + 3) = Endian::host_to_le(data.available_capacity); add_tagged_option(BSS_LOAD, sizeof(buffer), buffer); } void Dot11ManagementFrame::tim(const tim_type &data) { std::vector buffer(sizeof(uint8_t) * 3 + data.partial_virtual_bitmap.size()); buffer[0] = data.dtim_count; buffer[1] = data.dtim_period; buffer[2] = data.bitmap_control; std::copy( data.partial_virtual_bitmap.begin(), data.partial_virtual_bitmap.end(), &buffer[3] ); add_tagged_option(TIM, buffer.size(), &buffer[0]); } void Dot11ManagementFrame::challenge_text(const std::string &text) { add_tagged_option( CHALLENGE_TEXT, text.size(), (const uint8_t*)text.c_str() ); } // Getters RSNInformation Dot11ManagementFrame::rsn_information() { const Dot11::option *option = search_option(RSN); if(!option || option->data_size() < (sizeof(uint16_t) << 1) + sizeof(uint32_t)) throw option_not_found(); return RSNInformation(option->data_ptr(), option->data_size()); } std::string Dot11ManagementFrame::ssid() const { const Dot11::option *option = search_option(SSID); if(!option) throw option_not_found(); if(option->data_size() == 0 && this->subtype() == Dot11::PROBE_REQ) return "BROADCAST"; else return std::string((const char*)option->data_ptr(), option->data_size()); } Dot11ManagementFrame::rates_type Dot11ManagementFrame::supported_rates() const { const Dot11::option *option = search_option(SUPPORTED_RATES); if(!option || option->data_size() == 0) throw option_not_found(); return deserialize_rates(option); } Dot11ManagementFrame::rates_type Dot11ManagementFrame::extended_supported_rates() const { const Dot11::option *option = search_option(EXT_SUPPORTED_RATES); if(!option || option->data_size() == 0) throw option_not_found(); return deserialize_rates(option); } uint8_t Dot11ManagementFrame::qos_capability() const { const Dot11::option *option = search_option(QOS_CAPABILITY); if(!option || option->data_size() != 1) throw option_not_found(); return *option->data_ptr(); } std::pair Dot11ManagementFrame::power_capability() const { const Dot11::option *option = search_option(POWER_CAPABILITY); if(!option || option->data_size() != 2) throw option_not_found(); return std::make_pair(*option->data_ptr(), *(option->data_ptr() + 1)); } Dot11ManagementFrame::channels_type Dot11ManagementFrame::supported_channels() const { const Dot11::option *option = search_option(SUPPORTED_CHANNELS); // We need a multiple of two if(!option || ((option->data_size() & 0x1) == 1)) throw option_not_found(); channels_type output; const uint8_t *ptr = option->data_ptr(), *end = ptr + option->data_size(); while(ptr != end) { uint8_t first = *(ptr++); output.push_back(std::make_pair(first, *(ptr++))); } return output; } Dot11ManagementFrame::request_info_type Dot11ManagementFrame::request_information() const { const Dot11::option *option = search_option(REQUEST_INFORMATION); if(!option || option->data_size() == 0) throw option_not_found(); request_info_type output; const uint8_t *ptr = option->data_ptr(), *end = ptr + option->data_size(); output.assign(ptr, end); return output; } Dot11ManagementFrame::fh_params_set Dot11ManagementFrame::fh_parameter_set() const { const Dot11::option *option = search_option(FH_SET); if(!option || option->data_size() != sizeof(fh_params_set)) throw option_not_found(); fh_params_set output = *reinterpret_cast(option->data_ptr()); output.dwell_time = Endian::le_to_host(output.dwell_time); output.hop_set = output.hop_set; output.hop_pattern = output.hop_pattern; output.hop_index = output.hop_index; return output; } uint8_t Dot11ManagementFrame::ds_parameter_set() const { const Dot11::option *option = search_option(DS_SET); if(!option || option->data_size() != sizeof(uint8_t)) throw option_not_found(); return *option->data_ptr(); } uint16_t Dot11ManagementFrame::ibss_parameter_set() const { const Dot11::option *option = search_option(IBSS_SET); if(!option || option->data_size() != sizeof(uint16_t)) throw option_not_found(); return Endian::le_to_host(*reinterpret_cast(option->data_ptr())); } Dot11ManagementFrame::ibss_dfs_params Dot11ManagementFrame::ibss_dfs() const { const Dot11::option *option = search_option(IBSS_DFS); if(!option || option->data_size() < ibss_dfs_params::minimum_size) throw option_not_found(); ibss_dfs_params output; const uint8_t *ptr = option->data_ptr(), *end = ptr + option->data_size(); output.dfs_owner = ptr; ptr += output.dfs_owner.size(); output.recovery_interval = *(ptr++); while(ptr != end) { uint8_t first = *(ptr++); if(ptr == end) throw option_not_found(); output.channel_map.push_back(std::make_pair(first, *(ptr++))); } return output; } Dot11ManagementFrame::country_params Dot11ManagementFrame::country() const { const Dot11::option *option = search_option(COUNTRY); if(!option || option->data_size() < country_params::minimum_size) throw option_not_found(); country_params output; const uint8_t *ptr = option->data_ptr(), *end = ptr + option->data_size(); std::copy(ptr, ptr + 3, std::back_inserter(output.country)); ptr += output.country.size(); while(end - ptr >= 3) { output.first_channel.push_back(*(ptr++)); output.number_channels.push_back(*(ptr++)); output.max_transmit_power.push_back(*(ptr++)); } if(ptr != end) throw option_not_found(); return output; } std::pair Dot11ManagementFrame::fh_parameters() const { const Dot11::option *option = search_option(HOPPING_PATTERN_PARAMS); if(!option || option->data_size() != sizeof(uint8_t) * 2) throw option_not_found(); const uint8_t *ptr = option->data_ptr(); uint8_t first = *(ptr++); return std::make_pair(first, *ptr); } Dot11ManagementFrame::fh_pattern_type Dot11ManagementFrame::fh_pattern_table() const { const Dot11::option *option = search_option(HOPPING_PATTERN_TABLE); if(!option || option->data_size() < fh_pattern_type::minimum_size) throw option_not_found(); fh_pattern_type output; const uint8_t *ptr = option->data_ptr(), *end = ptr + option->data_size(); output.flag = *(ptr++); output.number_of_sets = *(ptr++); output.modulus = *(ptr++); output.offset = *(ptr++); output.random_table.assign(ptr, end); return output; } uint8_t Dot11ManagementFrame::power_constraint() const { const Dot11::option *option = search_option(POWER_CONSTRAINT); if(!option || option->data_size() != 1) throw option_not_found(); return *option->data_ptr(); } Dot11ManagementFrame::channel_switch_type Dot11ManagementFrame::channel_switch() const { const Dot11::option *option = search_option(CHANNEL_SWITCH); if(!option || option->data_size() != sizeof(uint8_t) * 3) throw option_not_found(); const uint8_t *ptr = option->data_ptr(); channel_switch_type output; output.switch_mode = *(ptr++); output.new_channel = *(ptr++); output.switch_count = *(ptr++); return output; } Dot11ManagementFrame::quiet_type Dot11ManagementFrame::quiet() const { const Dot11::option *option = search_option(QUIET); if(!option || option->data_size() != (sizeof(uint8_t) * 2 + sizeof(uint16_t) * 2)) throw option_not_found(); const uint8_t *ptr = option->data_ptr(); quiet_type output; output.quiet_count = *(ptr++); output.quiet_period = *(ptr++); const uint16_t *ptr_16 = (const uint16_t*)ptr; output.quiet_duration = Endian::le_to_host(*(ptr_16++)); output.quiet_offset = Endian::le_to_host(*ptr_16); return output; } std::pair Dot11ManagementFrame::tpc_report() const { const Dot11::option *option = search_option(TPC_REPORT); if(!option || option->data_size() != sizeof(uint8_t) * 2) throw option_not_found(); const uint8_t *ptr = option->data_ptr(); uint8_t first = *(ptr++); return std::make_pair(first, *ptr); } uint8_t Dot11ManagementFrame::erp_information() const { const Dot11::option *option = search_option(ERP_INFORMATION); if(!option || option->data_size() != sizeof(uint8_t)) throw option_not_found(); return *option->data_ptr(); } Dot11ManagementFrame::bss_load_type Dot11ManagementFrame::bss_load() const { const Dot11::option *option = search_option(BSS_LOAD); if(!option || option->data_size() != sizeof(uint8_t) + 2 * sizeof(uint16_t)) throw option_not_found(); bss_load_type output; const uint8_t *ptr = option->data_ptr(); output.station_count = Endian::le_to_host(*(uint16_t*)ptr); output.channel_utilization = ptr[2]; output.available_capacity = Endian::le_to_host(*(uint16_t*)(ptr + 3)); return output; } Dot11ManagementFrame::tim_type Dot11ManagementFrame::tim() const { const Dot11::option *option = search_option(TIM); if(!option || option->data_size() < 4 * sizeof(uint8_t)) throw option_not_found(); const uint8_t *ptr = option->data_ptr(), *end = ptr + option->data_size(); tim_type output; output.dtim_count = *(ptr++); output.dtim_period = *(ptr++); output.bitmap_control = *(ptr++); output.partial_virtual_bitmap.assign(ptr, end); return output; } std::string Dot11ManagementFrame::challenge_text() const { const Dot11::option *option = search_option(CHALLENGE_TEXT); if(!option || option->data_size() == 0) throw option_not_found(); return std::string(option->data_ptr(), option->data_ptr() + option->data_size()); } } // namespace Tinslibtins-1.1/src/dot11/dot11_data.cpp0000664000175000017500000001310512154360113016477 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include "dot11/dot11_data.h" #include "rawpdu.h" #include "snap.h" namespace Tins { /* Dot11Data */ Dot11Data::Dot11Data(const uint8_t *buffer, uint32_t total_sz) : Dot11(buffer, total_sz) { const uint32_t offset = init(buffer, total_sz); buffer += offset; total_sz -= offset; if(total_sz) { // If the wep bit is on, then just use a RawPDU if(wep()) inner_pdu(new Tins::RawPDU(buffer, total_sz)); else inner_pdu(new Tins::SNAP(buffer, total_sz)); } } Dot11Data::Dot11Data(const uint8_t *buffer, uint32_t total_sz, no_inner_pdu) : Dot11(buffer, total_sz) { init(buffer, total_sz); } uint32_t Dot11Data::init(const uint8_t *buffer, uint32_t total_sz) { const uint8_t *start_ptr = buffer; uint32_t sz = Dot11::header_size(); buffer += sz; total_sz -= sz; if(total_sz < sizeof(_ext_header)) throw malformed_packet(); std::memcpy(&_ext_header, buffer, sizeof(_ext_header)); buffer += sizeof(_ext_header); total_sz -= sizeof(_ext_header); if(from_ds() && to_ds()) { if(total_sz < _addr4.size()) throw malformed_packet(); _addr4 = buffer; buffer += _addr4.size(); total_sz -= _addr4.size(); } return buffer - start_ptr; } Dot11Data::Dot11Data(const address_type &dst_hw_addr, const address_type &src_hw_addr) : Dot11(dst_hw_addr) { type(Dot11::DATA); memset(&_ext_header, 0, sizeof(_ext_header)); addr2(src_hw_addr); } uint32_t Dot11Data::header_size() const { uint32_t sz = Dot11::header_size() + sizeof(_ext_header); if (this->from_ds() && this->to_ds()) sz += 6; return sz; } void Dot11Data::addr2(const address_type &new_addr2) { std::copy(new_addr2.begin(), new_addr2.end(), _ext_header.addr2); } void Dot11Data::addr3(const address_type &new_addr3) { std::copy(new_addr3.begin(), new_addr3.end(), _ext_header.addr3); } void Dot11Data::frag_num(small_uint<4> new_frag_num) { #if TINS_IS_LITTLE_ENDIAN _ext_header.frag_seq = new_frag_num | (_ext_header.frag_seq & 0xfff0); #else _ext_header.frag_seq = (new_frag_num << 8) | (_ext_header.frag_seq & 0xf0ff); #endif } void Dot11Data::seq_num(small_uint<12> new_seq_num) { #if TINS_IS_LITTLE_ENDIAN _ext_header.frag_seq = (new_seq_num << 4) | (_ext_header.frag_seq & 0xf); #else _ext_header.frag_seq = Endian::host_to_le(new_seq_num << 4) | (_ext_header.frag_seq & 0xf00); #endif } void Dot11Data::addr4(const address_type &new_addr4) { _addr4 = new_addr4; } uint32_t Dot11Data::write_ext_header(uint8_t *buffer, uint32_t total_sz) { uint32_t written = sizeof(_ext_header); memcpy(buffer, &_ext_header, sizeof(_ext_header)); buffer += sizeof(_ext_header); if (from_ds() && to_ds()) { written += _addr4.size(); _addr4.copy(buffer); } return written; } /* QoS data. */ Dot11QoSData::Dot11QoSData(const address_type &dst_hw_addr, const address_type &src_hw_addr) : Dot11Data(dst_hw_addr, src_hw_addr) { subtype(Dot11::QOS_DATA_DATA); _qos_control = 0; } Dot11QoSData::Dot11QoSData(const uint8_t *buffer, uint32_t total_sz) // Am I breaking something? :S : Dot11Data(buffer, total_sz, no_inner_pdu()) { uint32_t sz = data_frame_size(); buffer += sz; total_sz -= sz; if(total_sz < sizeof(_qos_control)) throw malformed_packet(); _qos_control = *(uint16_t*)buffer; total_sz -= sizeof(uint16_t); buffer += sizeof(uint16_t); if(total_sz) { // If the wep bit is on, then just use a RawPDU if(wep()) inner_pdu(new Tins::RawPDU(buffer, total_sz)); else inner_pdu(new Tins::SNAP(buffer, total_sz)); } } void Dot11QoSData::qos_control(uint16_t new_qos_control) { this->_qos_control = Endian::host_to_le(new_qos_control); } uint32_t Dot11QoSData::header_size() const { return Dot11Data::header_size() + sizeof(this->_qos_control); } uint32_t Dot11QoSData::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) { uint32_t sz = sizeof(this->_qos_control); #ifdef TINS_DEBUG assert(sz <= total_sz); #endif *(uint16_t*)buffer = this->_qos_control; return sz; } } // namespace Tins libtins-1.1/src/dot11/dot11_control.cpp0000664000175000017500000002103112154360113017243 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include "dot11/dot11_control.h" namespace Tins { /* Dot11Control */ Dot11Control::Dot11Control(const address_type &dst_addr) : Dot11(dst_addr) { type(CONTROL); } Dot11Control::Dot11Control(const uint8_t *buffer, uint32_t total_sz) : Dot11(buffer, total_sz) { } /* Dot11ControlTA */ Dot11ControlTA::Dot11ControlTA(const address_type &dst_addr, const address_type &target_address) : Dot11Control(dst_addr) { target_addr(target_address); } Dot11ControlTA::Dot11ControlTA(const uint8_t *buffer, uint32_t total_sz) : Dot11Control(buffer, total_sz) { buffer += sizeof(ieee80211_header); total_sz -= sizeof(ieee80211_header); if(total_sz < sizeof(_taddr)) throw std::runtime_error("Not enough size for an IEEE 802.11 RTS frame in the buffer."); //std::memcpy(_taddr, buffer, sizeof(_taddr)); _taddr = buffer; } uint32_t Dot11ControlTA::header_size() const { return Dot11::header_size() + sizeof(_taddr); } uint32_t Dot11ControlTA::write_ext_header(uint8_t *buffer, uint32_t total_sz) { #ifdef TINS_DEBUG assert(total_sz >= sizeof(_taddr)); #endif //std::memcpy(buffer, _taddr, sizeof(_taddr)); _taddr.copy(buffer); return sizeof(_taddr); } void Dot11ControlTA::target_addr(const address_type &addr) { _taddr = addr; } /* Dot11RTS */ Dot11RTS::Dot11RTS(const address_type &dst_addr, const address_type &target_addr) : Dot11ControlTA(dst_addr, target_addr) { subtype(RTS); } Dot11RTS::Dot11RTS(const uint8_t *buffer, uint32_t total_sz) : Dot11ControlTA(buffer, total_sz) { } /* Dot11PSPoll */ Dot11PSPoll::Dot11PSPoll(const address_type &dst_addr, const address_type &target_addr) : Dot11ControlTA(dst_addr, target_addr) { subtype(PS); } Dot11PSPoll::Dot11PSPoll(const uint8_t *buffer, uint32_t total_sz) : Dot11ControlTA(buffer, total_sz) { } /* Dot11CFEnd */ Dot11CFEnd::Dot11CFEnd(const address_type &dst_addr, const address_type &target_addr) : Dot11ControlTA(dst_addr, target_addr) { subtype(CF_END); } Dot11CFEnd::Dot11CFEnd(const uint8_t *buffer, uint32_t total_sz) : Dot11ControlTA(buffer, total_sz) { } /* Dot11EndCFAck */ Dot11EndCFAck::Dot11EndCFAck(const address_type &dst_addr, const address_type &target_addr) : Dot11ControlTA(dst_addr, target_addr) { subtype(CF_END_ACK); } Dot11EndCFAck::Dot11EndCFAck(const uint8_t *buffer, uint32_t total_sz) : Dot11ControlTA(buffer, total_sz) { } /* Dot11Ack */ Dot11Ack::Dot11Ack(const address_type &dst_addr) : Dot11Control(dst_addr) { subtype(ACK); } Dot11Ack::Dot11Ack(const uint8_t *buffer, uint32_t total_sz) : Dot11Control(buffer, total_sz) { } /* Dot11BlockAck */ Dot11BlockAckRequest::Dot11BlockAckRequest(const address_type &dst_addr, const address_type &target_addr) : Dot11ControlTA(dst_addr, target_addr) { init_block_ack(); } Dot11BlockAckRequest::Dot11BlockAckRequest(const uint8_t *buffer, uint32_t total_sz) : Dot11ControlTA(buffer, total_sz) { uint32_t padding = controlta_size(); buffer += padding; total_sz -= padding; if(total_sz < sizeof(_bar_control) + sizeof(_start_sequence)) throw std::runtime_error("Not enough size for an IEEE 802.11 Block Ack frame in the buffer."); std::memcpy(&_bar_control, buffer, sizeof(_bar_control)); buffer += sizeof(_bar_control); std::memcpy(&_start_sequence, buffer, sizeof(_start_sequence)); } void Dot11BlockAckRequest::init_block_ack() { subtype(BLOCK_ACK_REQ); std::memset(&_bar_control, 0, sizeof(_bar_control)); std::memset(&_start_sequence, 0, sizeof(_start_sequence)); } uint32_t Dot11BlockAckRequest::write_ext_header(uint8_t *buffer, uint32_t total_sz) { uint32_t parent_size = Dot11ControlTA::write_ext_header(buffer, total_sz); buffer += parent_size; std::memcpy(buffer, &_bar_control, sizeof(_bar_control)); buffer += sizeof(_bar_control); std::memcpy(buffer, &_start_sequence, sizeof(_start_sequence)); return parent_size + sizeof(_start_sequence) + sizeof(_bar_control); } void Dot11BlockAckRequest::bar_control(small_uint<4> bar) { #if TINS_IS_LITTLE_ENDIAN _bar_control = bar | (_bar_control & 0xfff0); #else _bar_control = (bar << 8) | (_bar_control & 0xf0ff); #endif } void Dot11BlockAckRequest::start_sequence(small_uint<12> seq) { #if TINS_IS_LITTLE_ENDIAN _start_sequence = (seq << 4) | (_start_sequence & 0xf); #else _start_sequence = Endian::host_to_le(seq << 4) | (_start_sequence & 0xf00); #endif } void Dot11BlockAckRequest::fragment_number(small_uint<4> frag) { #if TINS_IS_LITTLE_ENDIAN _start_sequence = frag | (_start_sequence & 0xfff0); #else _start_sequence = (frag << 8) | (_start_sequence & 0xf0ff); #endif } uint32_t Dot11BlockAckRequest::header_size() const { return Dot11ControlTA::header_size() + sizeof(_start_sequence) + sizeof(_start_sequence); } /* Dot11BlockAck */ Dot11BlockAck::Dot11BlockAck(const address_type &dst_addr, const address_type &target_addr) : Dot11ControlTA(dst_addr, target_addr) { subtype(BLOCK_ACK); std::memset(_bitmap, 0, sizeof(_bitmap)); } Dot11BlockAck::Dot11BlockAck(const uint8_t *buffer, uint32_t total_sz) : Dot11ControlTA(buffer, total_sz) { uint32_t padding = controlta_size(); buffer += padding; total_sz -= padding; if(total_sz < sizeof(_bitmap) + sizeof(_bar_control) + sizeof(_start_sequence)) throw std::runtime_error("Not enough size for an IEEE 802.11 Block Ack frame in the buffer."); std::memcpy(&_bar_control, buffer, sizeof(_bar_control)); buffer += sizeof(_bar_control); std::memcpy(&_start_sequence, buffer, sizeof(_start_sequence)); buffer += sizeof(_start_sequence); std::memcpy(&_bitmap, buffer, sizeof(_bitmap)); } void Dot11BlockAck::bar_control(small_uint<4> bar) { #if TINS_IS_LITTLE_ENDIAN _bar_control = bar | (_bar_control & 0xfff0); #else _bar_control = (bar << 8) | (_bar_control & 0xf0ff); #endif } void Dot11BlockAck::start_sequence(small_uint<12> seq) { #if TINS_IS_LITTLE_ENDIAN _start_sequence = (seq << 4) | (_start_sequence & 0xf); #else _start_sequence = Endian::host_to_le(seq << 4) | (_start_sequence & 0xf00); #endif } void Dot11BlockAck::fragment_number(small_uint<4> frag) { #if TINS_IS_LITTLE_ENDIAN _start_sequence = frag | (_start_sequence & 0xfff0); #else _start_sequence = (frag << 8) | (_start_sequence & 0xf0ff); #endif } void Dot11BlockAck::bitmap(const uint8_t *bit) { std::memcpy(_bitmap, bit, sizeof(_bitmap)); } uint32_t Dot11BlockAck::write_ext_header(uint8_t *buffer, uint32_t total_sz) { uint32_t parent_size = Dot11ControlTA::write_ext_header(buffer, total_sz); buffer += parent_size; std::memcpy(buffer, &_bar_control, sizeof(_bar_control)); buffer += sizeof(_bar_control); std::memcpy(buffer, &_start_sequence, sizeof(_start_sequence)); buffer += sizeof(_start_sequence); std::memcpy(buffer, _bitmap, sizeof(_bitmap)); return parent_size + sizeof(_bitmap) + sizeof(_bar_control) + sizeof(_start_sequence); } uint32_t Dot11BlockAck::header_size() const { return Dot11ControlTA::header_size() + sizeof(_start_sequence) + sizeof(_start_sequence) + sizeof(_bitmap); } } // namespace Tinslibtins-1.1/src/dot11/dot11_beacon.cpp0000664000175000017500000000525512154360113017024 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include "dot11/dot11_beacon.h" namespace Tins { /* Dot11Beacon */ Dot11Beacon::Dot11Beacon(const address_type &dst_hw_addr, const address_type &src_hw_addr) : Dot11ManagementFrame(dst_hw_addr, src_hw_addr) { subtype(Dot11::BEACON); std::memset(&_body, 0, sizeof(_body)); } Dot11Beacon::Dot11Beacon(const uint8_t *buffer, uint32_t total_sz) : Dot11ManagementFrame(buffer, total_sz) { uint32_t sz = management_frame_size(); buffer += sz; total_sz -= sz; if(total_sz < sizeof(_body)) throw malformed_packet(); std::memcpy(&_body, buffer, sizeof(_body)); buffer += sizeof(_body); total_sz -= sizeof(_body); parse_tagged_parameters(buffer, total_sz); } void Dot11Beacon::timestamp(uint64_t new_timestamp) { this->_body.timestamp = Endian::host_to_le(new_timestamp); } void Dot11Beacon::interval(uint16_t new_interval) { this->_body.interval = Endian::host_to_le(new_interval); } uint32_t Dot11Beacon::header_size() const { return Dot11ManagementFrame::header_size() + sizeof(_body); } uint32_t Dot11Beacon::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) { uint32_t sz = sizeof(_body); #ifdef TINS_DEBUG assert(sz <= total_sz); #endif std::memcpy(buffer, &this->_body, sz); return sz; } } // namespace Tinslibtins-1.1/src/dot11/dot11_base.cpp0000664000175000017500000002174012154360113016504 0ustar matiasmatias/* * Copyright (c) 2012, Matias Fontanini * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include #include #include #include #include #include "macros.h" #include "exceptions.h" #include "dot11/dot11_base.h" #ifndef WIN32 #if defined(__FreeBSD_kernel__) || defined(BSD) || defined(__APPLE__) #include #include #else #include #endif #include #include #endif #include "dot11.h" #include "rawpdu.h" #include "rsn_information.h" #include "packet_sender.h" #include "snap.h" namespace Tins { const Dot11::address_type Dot11::BROADCAST = "ff:ff:ff:ff:ff:ff"; Dot11::Dot11(const address_type &dst_hw_addr) : _options_size(0) { memset(&_header, 0, sizeof(ieee80211_header)); addr1(dst_hw_addr); } Dot11::Dot11(const ieee80211_header *header_ptr) { } Dot11::Dot11(const uint8_t *buffer, uint32_t total_sz) : _options_size(0) { if(total_sz < sizeof(_header)) throw malformed_packet(); std::memcpy(&_header, buffer, sizeof(_header)); } void Dot11::parse_tagged_parameters(const uint8_t *buffer, uint32_t total_sz) { if(total_sz > 0) { uint8_t opcode, length; while(total_sz >= 2) { opcode = buffer[0]; length = buffer[1]; buffer += 2; total_sz -= 2; if(length > total_sz) { throw malformed_packet(); } add_tagged_option((OptionTypes)opcode, length, buffer); buffer += length; total_sz -= length; } } } void Dot11::add_tagged_option(OptionTypes opt, uint8_t len, const uint8_t *val) { uint32_t opt_size = len + sizeof(uint8_t) * 2; _options.push_back(option((uint8_t)opt, len, val)); _options_size += opt_size; } void Dot11::internal_add_option(const option &opt) { _options_size += opt.data_size() + sizeof(uint8_t) * 2; } void Dot11::add_option(const option &opt) { internal_add_option(opt); _options.push_back(opt); } const Dot11::option *Dot11::search_option(OptionTypes opt) const { for(std::list