00001 #include <iostream>
00002 #include <string>
00003
00004
00005 using namespace std;
00006
00007 void usage(void) {
00008 cout << "helper for 353 camera" << endl;
00009 cout << "\t--serno_to_mcast ABCDEFGHIJKL - accept SERNO and return multicast address for camera in form 232.GH.IJ.KL - with conversion from 16 to 10 base" << endl << endl;
00010 }
00011
00012 int main(int argc, char *argv[]) {
00013 bool flag = true;
00014
00015 if(argc == 3) {
00016 string command = argv[1];
00017 if(command == "--serno_to_mcast") {
00018 string serno = argv[2];
00019
00020 if(serno.length() == 12) {
00021 flag = false;
00022 char buf[] = {0x00, 0x00, 0x00};
00023 const char *in = serno.c_str();
00024 char *endptr;
00025 in += 6;
00026 int ip_1, ip_2, ip_3;
00027 buf[0] = in[0]; buf[1] = in[1];
00028 ip_1 = strtol(buf, &endptr, 16);
00029 buf[0] = in[2]; buf[1] = in[3];
00030 ip_2 = strtol(buf, &endptr, 16);
00031 buf[0] = in[4]; buf[1] = in[5];
00032 ip_3 = strtol(buf, &endptr, 16);
00033 printf("232.%d.%d.%d", ip_1, ip_2, ip_3);
00034 }
00035 }
00036 }
00037 if(flag)
00038 usage();
00039 return 0;
00040 }