| 1 | #include <stdio.h> |
| 2 | #include "vera_directc.h" |
| 3 | #include "include/pg.h" |
| 4 | |
| 5 | extern void uChartoVec32( char *in, int size, vec32** s); |
| 6 | extern void genCPacket ( int index, vec32** flow_vars, vec32** s ) ; |
| 7 | |
| 8 | #define TOTAL_NUMBER 100 |
| 9 | |
| 10 | |
| 11 | static pgInterface pgInt[TOTAL_NUMBER]; |
| 12 | |
| 13 | int pgWrap( char** s) { |
| 14 | |
| 15 | char * data; |
| 16 | // data = libnet_call(); |
| 17 | // int len = toStr(s, data,84); |
| 18 | return(0); |
| 19 | } |
| 20 | |
| 21 | int pgWrap1( vec32** s) { |
| 22 | // char * data; |
| 23 | // data = libnet_call(); |
| 24 | |
| 25 | // toVec32(data ,84,s); |
| 26 | |
| 27 | } |
| 28 | |
| 29 | |
| 30 | void init_packgen( int index) { |
| 31 | int i; |
| 32 | /* |
| 33 | if(!pgInt[index]) { |
| 34 | pgInt[index] = (pgInterface *) malloc(sizeof(pgInterface)); |
| 35 | } |
| 36 | case(type) |
| 37 | // get correct syntax |
| 38 | FRAME_TYPE: pgInt[index]->frame_type = ???; |
| 39 | IP_DST_ADDR: pgInt[index]->ip_dest_addr = ?? |
| 40 | */ |
| 41 | // for(i=0;i<10;i++) { |
| 42 | // printf(" i - %d s - %x \n",i,*s[0]); |
| 43 | // } |
| 44 | } |
| 45 | void SetPktGenFields ( int type, vec32** s) { |
| 46 | /* |
| 47 | * case(type) |
| 48 | * FRAME_TYPE: pgInt[index]->frame_type = ???; |
| 49 | * IP_DST_ADDR: pgInt[index]->ip_dest_addr = ?? |
| 50 | */ |
| 51 | |
| 52 | } |
| 53 | void SetPktLength ( int index, int l2_len, int l3_len, int l4_len) { |
| 54 | pgInt[index].l2_length = l2_len; |
| 55 | pgInt[index].l3_length = l3_len; |
| 56 | pgInt[index].l4_length = l4_len; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | unsigned int concat( char a, char b,char c, char d) { |
| 61 | unsigned int retval; |
| 62 | retval = 0; |
| 63 | retval = d; |
| 64 | retval = (retval<<8) | c; |
| 65 | retval = (retval<<8) | b; |
| 66 | retval = (retval<<8) | a; |
| 67 | return(retval); |
| 68 | } |
| 69 | void uChartoVec32( char *in, int size, vec32 **s) { |
| 70 | int len,i,j; |
| 71 | len = (size%4) ? size/4: ( size/4 +1 ); |
| 72 | j=0; |
| 73 | |
| 74 | for(i =0;i<size;i++ ) { |
| 75 | s[j]->d = in[i]; |
| 76 | // printf(" j - %d - %x \n",j,s[j]->d); |
| 77 | s[j]->c = 0; |
| 78 | j++; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void Vec32touChar ( char *in, int size, vec32 **s) { |
| 83 | int len,i,j; |
| 84 | for(i =0;i<size;i++ ) { |
| 85 | in[i] = s[i]->d & 0xff; |
| 86 | } |
| 87 | } |
| 88 | unsigned int Vec32touInt ( vec32 **s) { |
| 89 | return(s[0]->d); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | void uInttoVec32( unsigned int *in, int size, vec32 **s) { |
| 94 | int len,i,j; |
| 95 | for(i =0;i<size;i++ ) { |
| 96 | s[i]->d = in[i]; |
| 97 | s[i]->c = 0; |
| 98 | } |
| 99 | } |
| 100 | |