- Timestamp:
- 11/14/06 13:56:01 (16 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 2595c4d
- Parents:
- 35e0869
- Location:
- tools
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/traceanon/ipenc.c
r4e65f42 ra7282fb 33 33 static uint32_t prefix; 34 34 static uint32_t netmask; 35 static void init_prefix( char*key)35 static void init_prefix(uint8_t *key) 36 36 { 37 37 int a,b,c,d; … … 49 49 } 50 50 51 void enc_init(enum enc_type_t type, char*key)51 void enc_init(enum enc_type_t type, uint8_t *key) 52 52 { 53 charcryptopan_key[32];53 uint8_t cryptopan_key[32]; 54 54 memset(cryptopan_key,0,sizeof(cryptopan_key)); 55 55 enc_type = type; -
tools/traceanon/ipenc.h
r49f147b ra7282fb 9 9 ENC_CRYPTOPAN /**< Prefix preserving encryption */ 10 10 }; 11 void enc_init(enum enc_type_t type, char*key);11 void enc_init(enum enc_type_t type, uint8_t *key); 12 12 uint32_t enc_ip(uint32_t orig_addr); 13 13 #endif -
tools/traceanon/panon.h
r49f147b ra7282fb 2 2 #define _PANON_H_ 3 3 4 / / $Id$4 /* $Id$ */ 5 5 6 6 #include "rijndael.h" … … 13 13 void panon_init(const uint8_t * key); 14 14 void panon_init_cache(); 15 #endif // _PANON_H_15 #endif -
tools/traceanon/rijndael.c
rc631f0f ra7282fb 1 / / $Id$2 3 / /1 /* $Id$ */ 2 3 /* 4 4 // File : rijndael.cpp 5 5 // Creation date : Sun Nov 5 2000 03:22:10 CEST … … 10 10 // This code is public domain. 11 11 // Based on the Vincent Rijmen and K.U.Leuven implementation 2.4. 12 //13 14 / /12 */ 13 14 /* 15 15 // Original Copyright notice: 16 16 // … … 28 28 // 29 29 // This code is placed in the public domain. 30 //31 32 / /30 */ 31 32 /* 33 33 // This implementation works on 128 , 192 , 256 bit keys 34 34 // and on 128 bit blocks 35 //35 */ 36 36 37 37 #define _RIJNDAEL_CPP_ … … 971 971 972 972 973 / /////////////////////////////////////////////////////////////////////////////////////////////////////////////////973 /*//////////////////////////////////////////////////////////////////////////////////////////////////////////////// 974 974 // API 975 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// //975 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// */ 976 976 977 977 int rijndael_init(Mode mode,Direction dir,const UINT8 * key,KeyLength keyLen,UINT8 * initVector) … … 982 982 UINT32 j; 983 983 984 / / Not initialized yet984 /* Not initialized yet */ 985 985 m_state = Invalid; 986 986 987 / / Check the mode987 /* Check the mode */ 988 988 if((mode != CBC) && (mode != ECB) && (mode != CFB1))return RIJNDAEL_UNSUPPORTED_MODE; 989 989 m_mode = mode; 990 990 991 / / And the direction991 /* And the direction */ 992 992 if((dir != Encrypt) && (dir != Decrypt))return RIJNDAEL_UNSUPPORTED_DIRECTION; 993 993 m_direction = dir; 994 994 995 / / Allow to set an init vector995 /* Allow to set an init vector */ 996 996 if(initVector) 997 997 { 998 / / specified init vector998 /* specified init vector */ 999 999 for(i = 0;i < MAX_IV_SIZE;i++) 1000 1000 { … … 1002 1002 } 1003 1003 } else { 1004 / / zero init vector1004 /* zero init vector */ 1005 1005 for(i = 0;i < MAX_IV_SIZE;i++) 1006 1006 { … … 1010 1010 1011 1011 1012 / / And check the key length1012 /* And check the key length */ 1013 1013 switch(keyLen) 1014 1014 { … … 1029 1029 break; 1030 1030 } 1031 / /The number of rounds is calculated as1031 /* The number of rounds is calculated as 1032 1032 // m_uRounds = (m_uKeyLenInBits / 32) + 6; 1033 */ 1033 1034 1034 1035 if(!key)return RIJNDAEL_BAD_KEY; … … 1154 1155 } 1155 1156 padLen = 16 - (inputOctets - 16*numBlocks); 1156 // assert(padLen > 0 && padLen <= 16);1157 1157 memcpy(block, input, 16 - padLen); 1158 1158 memset(block + 16 - padLen, padLen, padLen); … … 1173 1173 } 1174 1174 padLen = 16 - (inputOctets - 16*numBlocks); 1175 // assert(padLen > 0 && padLen <= 16); // DO SOMETHING HERE ?1176 1175 for (i = 0; i < 16 - padLen; i++) { 1177 1176 block[i] = input[i] ^ iv[i]; … … 1358 1357 } 1359 1358 1360 / /////////////////////////////////////////////////////////////////////////////////////////////////////////////////1359 /*//////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1361 1360 // ALGORITHM 1362 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1361 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */ 1363 1362 1364 1363 … … 1369 1368 int t = 0; 1370 1369 1371 / / Calculate the necessary round keys1372 / / The number of calculations depends on keyBits and blockBits1370 /* Calculate the necessary round keys */ 1371 /* The number of calculations depends on keyBits and blockBits */ 1373 1372 int uKeyColumns = m_uRounds - 6; 1374 1373 1375 1374 UINT8 tempKey[_MAX_KEY_COLUMNS][4]; 1376 1375 1377 / / Copy the input key to the temporary key matrix1376 /* Copy the input key to the temporary key matrix */ 1378 1377 1379 1378 for(j = 0;j < uKeyColumns;j++) … … 1383 1382 1384 1383 1385 / / copy values into round key array1384 /* copy values into round key array */ 1386 1385 for(j = 0;(j < uKeyColumns) && (r <= m_uRounds); ) 1387 1386 { … … 1540 1539 UINT8 temp[4][4]; 1541 1540 1542 *((UINT32*)temp[0]) = *(( UINT32*)(a )) ^ *((UINT32*)m_expandedKey[m_uRounds][0]);1543 *((UINT32*)temp[1]) = *(( UINT32*)(a+ 4)) ^ *((UINT32*)m_expandedKey[m_uRounds][1]);1544 *((UINT32*)temp[2]) = *(( UINT32*)(a+ 8)) ^ *((UINT32*)m_expandedKey[m_uRounds][2]);1545 *((UINT32*)temp[3]) = *(( UINT32*)(a+12)) ^ *((UINT32*)m_expandedKey[m_uRounds][3]);1546 1547 *((UINT32*)(b )) = *(( UINT32*)T5[temp[0][0]])1548 ^ *(( UINT32*)T6[temp[3][1]])1549 ^ *(( UINT32*)T7[temp[2][2]])1550 ^ *(( UINT32*)T8[temp[1][3]]);1551 *((UINT32*)(b+ 4)) = *(( UINT32*)T5[temp[1][0]])1552 ^ *(( UINT32*)T6[temp[0][1]])1553 ^ *(( UINT32*)T7[temp[3][2]])1554 ^ *(( UINT32*)T8[temp[2][3]]);1541 *((UINT32*)temp[0]) = *((const UINT32*)(a )) ^ *((const UINT32*)m_expandedKey[m_uRounds][0]); 1542 *((UINT32*)temp[1]) = *((const UINT32*)(a+ 4)) ^ *((const UINT32*)m_expandedKey[m_uRounds][1]); 1543 *((UINT32*)temp[2]) = *((const UINT32*)(a+ 8)) ^ *((const UINT32*)m_expandedKey[m_uRounds][2]); 1544 *((UINT32*)temp[3]) = *((const UINT32*)(a+12)) ^ *((const UINT32*)m_expandedKey[m_uRounds][3]); 1545 1546 *((UINT32*)(b )) = *((const UINT32*)T5[temp[0][0]]) 1547 ^ *((const UINT32*)T6[temp[3][1]]) 1548 ^ *((const UINT32*)T7[temp[2][2]]) 1549 ^ *((const UINT32*)T8[temp[1][3]]); 1550 *((UINT32*)(b+ 4)) = *((const UINT32*)T5[temp[1][0]]) 1551 ^ *((const UINT32*)T6[temp[0][1]]) 1552 ^ *((const UINT32*)T7[temp[3][2]]) 1553 ^ *((const UINT32*)T8[temp[2][3]]); 1555 1554 *((UINT32*)(b+ 8)) = *((UINT32*)T5[temp[2][0]]) 1556 ^ *(( UINT32*)T6[temp[1][1]])1557 ^ *(( UINT32*)T7[temp[0][2]])1558 ^ *(( UINT32*)T8[temp[3][3]]);1555 ^ *((const UINT32*)T6[temp[1][1]]) 1556 ^ *((const UINT32*)T7[temp[0][2]]) 1557 ^ *((const UINT32*)T8[temp[3][3]]); 1559 1558 *((UINT32*)(b+12)) = *((UINT32*)T5[temp[3][0]]) 1560 ^ *(( UINT32*)T6[temp[2][1]])1561 ^ *(( UINT32*)T7[temp[1][2]])1562 ^ *(( UINT32*)T8[temp[0][3]]);1559 ^ *((const UINT32*)T6[temp[2][1]]) 1560 ^ *((const UINT32*)T7[temp[1][2]]) 1561 ^ *((const UINT32*)T8[temp[0][3]]); 1563 1562 for(r = m_uRounds-1; r > 1; r--) 1564 1563 { -
tools/traceanon/traceanon.c
r66caf4b ra7282fb 12 12 13 13 14 void usage(char *argv0)14 static void usage(char *argv0) 15 15 { 16 16 fprintf(stderr,"Usage:\n" … … 27 27 28 28 /* Incrementally update a checksum */ 29 void update_in_cksum(uint16_t *csum, uint16_t old, uint16_t new)29 static void update_in_cksum(uint16_t *csum, uint16_t old, uint16_t new) 30 30 { 31 31 uint32_t sum = (~htons(*csum) & 0xFFFF) … … 36 36 } 37 37 38 void update_in_cksum32(uint16_t *csum, uint32_t old, uint32_t new)39 { 40 update_in_cksum(csum, old>>16,new>>16);41 update_in_cksum(csum, old&0xFFFF,new&0xFFFF);38 static void update_in_cksum32(uint16_t *csum, uint32_t old, uint32_t new) 39 { 40 update_in_cksum(csum,(uint16_t)(old>>16),(uint16_t)(new>>16)); 41 update_in_cksum(csum,(uint16_t)(old&0xFFFF),(uint16_t)(new&0xFFFF)); 42 42 } 43 43 … … 52 52 * source instead of the source and destination! 53 53 */ 54 void encrypt_ips(struct libtrace_ip *ip,bool enc_source,bool enc_dest)54 static void encrypt_ips(struct libtrace_ip *ip,bool enc_source,bool enc_dest) 55 55 { 56 56 struct libtrace_tcp *tcp; … … 68 68 )); 69 69 update_in_cksum32(&ip->ip_sum,old_ip,new_ip); 70 if (tcp) update_in_cksum (&tcp->check,old_ip,new_ip);71 if (udp) update_in_cksum (&udp->check,old_ip,new_ip);70 if (tcp) update_in_cksum32(&tcp->check,old_ip,new_ip); 71 if (udp) update_in_cksum32(&udp->check,old_ip,new_ip); 72 72 ip->ip_src.s_addr = new_ip; 73 73 } … … 79 79 )); 80 80 update_in_cksum32(&ip->ip_sum,old_ip,new_ip); 81 if (tcp) update_in_cksum (&tcp->check,old_ip,new_ip);82 if (udp) update_in_cksum (&udp->check,old_ip,new_ip);81 if (tcp) update_in_cksum32(&tcp->check,old_ip,new_ip); 82 if (udp) update_in_cksum32(&udp->check,old_ip,new_ip); 83 83 ip->ip_dst.s_addr = new_ip; 84 84 } … … 103 103 { 104 104 enum enc_type_t enc_type = ENC_NONE; 105 char*key = NULL;105 uint8_t *key = NULL; 106 106 struct libtrace_t *trace = 0; 107 107 struct libtrace_packet_t *packet = trace_create_packet(); -
tools/tracemerge/tracemerge.c
ra31b4c7 ra7282fb 6 6 #include <getopt.h> 7 7 8 void usage(char *argv0)8 static void usage(char *argv0) 9 9 { 10 10 fprintf(stderr,"Usage:\n" -
tools/tracereport/dir_report.c
r3b49843 ra7282fb 5 5 #include "libtrace.h" 6 6 #include "tracereport.h" 7 #include "report.h" 7 8 8 9 static uint64_t dir_bytes[8]; -
tools/tracereport/flow_report.c
re3b0188 ra7282fb 7 7 #include "tracereport.h" 8 8 #include "contain.h" 9 #include "report.h" 9 10 10 11 static uint64_t flow_count=0; -
tools/tracereport/port_report.c
r11c4044 ra7282fb 8 8 #include "tracereport.h" 9 9 #include "contain.h" 10 #include "report.h" 10 11 11 12 stat_t ports[256][65536]={{{0,0}}}; … … 31 32 } 32 33 33 void port_port(int i,char *prot, int j)34 static void port_port(int i,char *prot, int j) 34 35 { 35 36 struct servent *ent = getservbyport(htons(j),prot); … … 48 49 } 49 50 50 void port_protocol(int i)51 static void port_protocol(int i) 51 52 { 52 53 int j; -
tools/tracereport/tos_report.c
re3b0188 ra7282fb 5 5 #include "libtrace.h" 6 6 #include "tracereport.h" 7 #include "report.h" 7 8 8 9 static stat_t tos_stat[256] = { {0,0} } ; -
tools/tracereport/tracereport.c
r66caf4b ra7282fb 59 59 60 60 /* Process a trace, counting packets that match filter(s) */ 61 void run_trace(char *uri, libtrace_filter_t *filter, int count)61 static void run_trace(char *uri, libtrace_filter_t *filter, int count) 62 62 { 63 63 struct libtrace_packet_t *packet = trace_create_packet(); … … 101 101 } 102 102 103 void usage(char *argv0)103 static void usage(char *argv0) 104 104 { 105 105 fprintf(stderr,"Usage:\n" -
tools/tracereport/ttl_report.c
re3b0188 ra7282fb 5 5 #include "libtrace.h" 6 6 #include "tracereport.h" 7 #include "report.h" 7 8 8 9 static stat_t ttl_stat[256] = { {0,0} } ; -
tools/tracertstats/tracertstats.c
r66caf4b ra7282fb 80 80 struct output_data_t *output; 81 81 82 void report_results(double ts,uint64_t count,uint64_t bytes)82 static void report_results(double ts,uint64_t count,uint64_t bytes) 83 83 { 84 84 int i=0; … … 95 95 96 96 /* Process a trace, counting packets that match filter(s) */ 97 void run_trace(char *uri)97 static void run_trace(char *uri) 98 98 { 99 99 struct libtrace_packet_t *packet = trace_create_packet(); … … 178 178 } 179 179 180 void usage(char *argv0)180 static void usage(char *argv0) 181 181 { 182 182 fprintf(stderr,"Usage:\n" -
tools/tracesplit/tracesplit.c
r19c6cbe ra7282fb 11 11 #include <assert.h> 12 12 13 char *strdupcat(char *str,char *app)13 static char *strdupcat(char *str,char *app) 14 14 { 15 15 str=realloc(str,strlen(str)+strlen(app)+1); … … 18 18 } 19 19 20 char *strdupcati(char *str,int i)20 static char *strdupcati(char *str,uint64_t i) 21 21 { 22 22 char buffer[64]; 23 snprintf(buffer,sizeof(buffer),"% i",i);23 snprintf(buffer,sizeof(buffer),"%" PRIu64,i); 24 24 return strdupcat(str,buffer); 25 25 } 26 26 27 int usage(char *argv0)27 static int usage(char *argv0) 28 28 { 29 29 printf("Usage:\n" … … 166 166 if (interval!=UINT64_MAX) { 167 167 buffer=strdupcat(buffer,"-"); 168 buffer=strdupcati(buffer, firsttime);168 buffer=strdupcati(buffer,(uint64_t)firsttime); 169 169 } 170 170 if (count!=UINT64_MAX) { 171 171 buffer=strdupcat(buffer,"-"); 172 buffer=strdupcati(buffer, pktcount);172 buffer=strdupcati(buffer,(uint64_t)pktcount); 173 173 } 174 174 if (bytes!=UINT64_MAX) { 175 175 static int filenum=0; 176 176 buffer=strdupcat(buffer,"-"); 177 buffer=strdupcati(buffer, ++filenum);177 buffer=strdupcati(buffer,(uint64_t)++filenum); 178 178 } 179 179 output=trace_create_output(buffer); -
tools/tracesplit/tracesplit_dir.c
rfc0f131 ra7282fb 3 3 4 4 5 st ruct libtrace_out_t *create_output(char *uri) {5 static struct libtrace_out_t *create_output(char *uri) { 6 6 struct libtrace_out_t *output = NULL; 7 7 libtrace_err_t trace_err; … … 18 18 } 19 19 20 void usage() {21 printf(" tracesplit_dir inputuri outputuri_incoming outputuri_outgoing\n");20 static void usage(char*argv0) { 21 printf("%s inputuri outputuri_incoming outputuri_outgoing\n",argv0); 22 22 } 23 23 -
tools/tracestats/tracestats.c
r66caf4b ra7282fb 71 71 72 72 /* Process a trace, counting packets that match filter(s) */ 73 void run_trace(char *uri)73 static void run_trace(char *uri) 74 74 { 75 75 struct libtrace_packet_t *packet = trace_create_packet(); … … 122 122 } 123 123 124 void usage(char *argv0)124 static void usage(char *argv0) 125 125 { 126 126 fprintf(stderr,"Usage: %s [-H|--libtrace-help] [--filter|-f bpf ]... libtraceuri...\n",argv0);
Note: See TracChangeset
for help on using the changeset viewer.