Changeset 202
- Timestamp:
- 12/27/07 11:43:52
(9 months ago)
- Author:
- sip
- Message:
Check for golay and check PDU length in demuxer.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r201 |
r202 |
|
| 124 | 124 | } |
|---|
| 125 | 125 | |
|---|
| 126 | | //If the flag is the complement |
|---|
| 127 | | if (flag.complement) |
|---|
| | 126 | //If the flag is the complement and valid |
|---|
| | 127 | if (flag.IsValid() && flag.complement) |
|---|
| 128 | 128 | { |
|---|
| 129 | 129 | //Log |
|---|
| … | … | |
| 197 | 197 | //Reset state |
|---|
| 198 | 198 | state = NONE; |
|---|
| | 199 | //Exit |
|---|
| | 200 | return; |
|---|
| 199 | 201 | } |
|---|
| 200 | 202 | |
|---|
| … | … | |
| 205 | 207 | |
|---|
| 206 | 208 | //We have a good header go for the pdu |
|---|
| 207 | | state = PDU; |
|---|
| | 209 | state = PDU; |
|---|
| 208 | 210 | |
|---|
| 209 | 211 | break; |
|---|
| … | … | |
| 219 | 221 | Send(a); |
|---|
| 220 | 222 | |
|---|
| 221 | | //If we have a good flag |
|---|
| 222 | | if (!flag.IsValid()) |
|---|
| | 223 | //While we are in the PDU |
|---|
| | 224 | if (counter<header.mpl) |
|---|
| 223 | 225 | //And return |
|---|
| 224 | 226 | return; |
|---|
| 225 | | |
|---|
| 226 | | |
|---|
| | 227 | |
|---|
| 227 | 228 | //Set end PDU if not stuffing |
|---|
| 228 | 229 | if(header.mpl) |
|---|
| 229 | 230 | EndPDU(flag); |
|---|
| 230 | 231 | |
|---|
| 231 | | //Start the next PDU |
|---|
| 232 | | StartPDU(flag); |
|---|
| 233 | | |
|---|
| 234 | | //Clear flag |
|---|
| 235 | | flag.Clear(); |
|---|
| 236 | | |
|---|
| 237 | | //Clear the header |
|---|
| 238 | | header.Clear(); |
|---|
| 239 | | |
|---|
| 240 | | //Change state |
|---|
| 241 | | state = HEAD; |
|---|
| | 232 | //If the flag is valid |
|---|
| | 233 | if (flag.IsValid()) |
|---|
| | 234 | { |
|---|
| | 235 | //Start the next PDU |
|---|
| | 236 | StartPDU(flag); |
|---|
| | 237 | |
|---|
| | 238 | //Clear flag |
|---|
| | 239 | flag.Clear(); |
|---|
| | 240 | |
|---|
| | 241 | //Clear the header |
|---|
| | 242 | header.Clear(); |
|---|
| | 243 | |
|---|
| | 244 | //Change state |
|---|
| | 245 | state = HEAD; |
|---|
| | 246 | } else |
|---|
| | 247 | //No header found |
|---|
| | 248 | state = NONE; |
|---|
| | 249 | |
|---|
| 242 | 250 | break; |
|---|
| 243 | 251 | } |
|---|
| r196 |
r202 |
|
| 21 | 21 | */ |
|---|
| 22 | 22 | #include "H223Header.h" |
|---|
| | 23 | extern "C" { |
|---|
| | 24 | #include "golay.h" |
|---|
| | 25 | } |
|---|
| 23 | 26 | |
|---|
| 24 | 27 | int H223Header::IsComplete() |
|---|
| … | … | |
| 29 | 32 | int H223Header::IsValid() |
|---|
| 30 | 33 | { |
|---|
| 31 | | /* |
|---|
| 32 | | mc = (header.buffer[0] & 0x1E) >> 1; |
|---|
| 33 | | pm = (header.buffer[0] & 0x01); |
|---|
| 34 | | */ |
|---|
| 35 | | |
|---|
| 36 | 34 | //Get the values |
|---|
| 37 | 35 | mc = buffer[0] & 0x0F; |
|---|
| … | … | |
| 39 | 37 | pm = (buffer[1] >> 4) | (buffer[2] << 4); |
|---|
| 40 | 38 | |
|---|
| 41 | | //Calculate the golay codez |
|---|
| | 39 | //Calculate the golay code |
|---|
| | 40 | DWORD golay = buffer[2] << 16 | buffer[1] << 8 | buffer[0]; |
|---|
| | 41 | |
|---|
| | 42 | //Decode it |
|---|
| | 43 | int code = golay_decode(golay); |
|---|
| | 44 | |
|---|
| | 45 | //Chek it |
|---|
| | 46 | if (code==-1) |
|---|
| | 47 | //Bad header |
|---|
| | 48 | return 0; |
|---|
| | 49 | |
|---|
| | 50 | //Get the values |
|---|
| | 51 | mc = code & 0x0F; |
|---|
| | 52 | mpl = code >> 4; |
|---|
| | 53 | |
|---|
| | 54 | //Good header |
|---|
| 42 | 55 | return 1; |
|---|
| 43 | 56 | |
|---|
| r198 |
r202 |
|
| 147 | 147 | table.BuildPDU(entrySend); |
|---|
| 148 | 148 | |
|---|
| 149 | | cout << "Check \n" << pdux << "\n"; |
|---|
| 150 | | |
|---|
| 151 | 149 | //Depending on the state |
|---|
| 152 | 150 | switch(inState) |
|---|
| r13 |
r202 |
|
| 23 | 23 | return 1; |
|---|
| 24 | 24 | } |
|---|
| | 25 | |
|---|
| | 26 | //Set login high |
|---|
| | 27 | Logger::SetLevel(9); |
|---|
| 25 | 28 | |
|---|
| 26 | 29 | //Open file |
|---|
| … | … | |
| 53 | 56 | //Until end of file |
|---|
| 54 | 57 | while ((len=read(f,buffer,160))>0) |
|---|
| 55 | | { |
|---|
| 56 | | //For each byte |
|---|
| 57 | | for (int i=0;i<len;i++) |
|---|
| 58 | | //Demux |
|---|
| 59 | | demuxer.Demultiplex(buffer[i]); |
|---|
| 60 | | } |
|---|
| | 58 | //Demux |
|---|
| | 59 | demuxer.Demultiplex(buffer,len); |
|---|
| 61 | 60 | |
|---|
| 62 | 61 | //Close demuxer |
|---|
Download in other formats:
|
|