-
Notifications
You must be signed in to change notification settings - Fork 11
/
bypass.c
133 lines (132 loc) · 5.21 KB
/
bypass.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include "packet_decode.h"
int bypass(unsigned char *p,int NQ,float* IE,float* IO ,float* QE,float* QO) // bypass
{int NW=(10*NQ)/16*2;
short res;
int pos=0,sign,index=0;
printf("\nNQ=%d -> NW=%d\n",NQ,NW);
while (index<(NQ)) // 8*5=40 : 4 10=bit values for 5 bytes
{// printf("%02hhx %02hhx %02hhx %02hhx %02hhx = ",p[pos+0],p[pos+1],p[pos+2],p[pos+3],p[pos+4]);
if (index<NQ)
{res=(short)(p[pos+0]&0xff)*4+(short)(p[pos+1]>>6); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
IE[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+1]&0x3f)*4*4+(short)(p[pos+2]>>4); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
IE[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+2]&0x0f)*4*4*4+(short)(p[pos+3]>>2); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
IE[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+3]&0x03)*4*4*4*4+(short)(p[pos+4]); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
IE[index]=(float)res;
index++;
}
if (index<NQ) pos+=5;
}
index=0;
pos=NW+2; // next short
while (index<(NQ)) // 8*5=40 : 4 10=bit values for 5 bytes
{// printf("%02hhx %02hhx %02hhx %02hhx %02hhx = ",p[pos+0],p[pos+1],p[pos+2],p[pos+3],p[pos+4]);
if (index<NQ)
{res=(short)(p[pos+0]&0xff)*4+(short)(p[pos+1]>>6); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
IO[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+1]&0x3f)*4*4+(short)(p[pos+2]>>4); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
IO[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+2]&0x0f)*4*4*4+(short)(p[pos+3]>>2); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
IO[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+3]&0x03)*4*4*4*4+(short)(p[pos+4]); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
IO[index]=(float)res;
index++;
}
if (index<NQ) pos+=5;
}
printf("\npos=%d index=%d nw=%d\n",pos,index,(2*NW+2));
index=0;
pos=2*(NW+2); // next short
while (index<(NQ)) // 8*5=40 : 4 10=bit values for 5 bytes
{// printf("%02hhx %02hhx %02hhx %02hhx %02hhx = ",p[pos+0],p[pos+1],p[pos+2],p[pos+3],p[pos+4]);
if (index<NQ)
{res=(short)(p[pos+0]&0xff)*4+(short)(p[pos+1]>>6); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
QE[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+1]&0x3f)*4*4+(short)(p[pos+2]>>4); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
QE[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+2]&0x0f)*4*4*4+(short)(p[pos+3]>>2); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
QE[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+3]&0x03)*4*4*4*4+(short)(p[pos+4]); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
QE[index]=(float)res;
index++;
}
if (index<NQ) pos+=5;
}
index=0;
pos=3*(NW+2); // next short
while (index<(NQ)) // 8*5=40 : 4 10=bit values for 5 bytes
{// printf("%02hhx %02hhx %02hhx %02hhx %02hhx = ",p[pos+0],p[pos+1],p[pos+2],p[pos+3],p[pos+4]);
if (index<NQ)
{res=(short)(p[pos+0]&0xff)*4+(short)(p[pos+1]>>6); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
QO[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+1]&0x3f)*4*4+(short)(p[pos+2]>>4); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
QO[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+2]&0x0f)*4*4*4+(short)(p[pos+3]>>2); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
QO[index]=(float)res;
index++;
}
if (index<NQ)
{res=(short)(p[pos+3]&0x03)*4*4*4*4+(short)(p[pos+4]); // printf("%hx=",res);
sign=(res&0x200); res=res&(0x1ff); if (sign>0) res=-res; // printf("%03d\t",res);
QO[index]=(float)res;
index++;
}
if (index<NQ) pos+=5;
}
printf("\npos=%d index=%d\n",pos,index);
pos=4*(NW+2); // next short
return(pos);
}