Ethereal-dev: Re: [ethereal-dev] Wiretap module to interpret pppd trace file

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Paul Ionescu <paul@xxxxxxxx>
Date: Tue, 05 Sep 2000 23:44:23 +0300
Gilbert,

I have attached to this e-mail a sample trace file named "trace" an
output of "pppdump -h" of the same file named "trace.hex", and also I
have attached the source and help file of pppdump.

More information about the pppdump program is in the pppd package, and
you can get it from

ftp://ftp.linuxcare.com.au/pub/ppp/ppp-2.4.0.tar.gz

Maybe we don't need to guess the format of the trace file, because it
must be somewhere in pppd :)

> If you send me a sample file and and output of pppdump of that same file,
> I'll attempt to make a wiretap module for it.


Thanks a lot,
Paul.

Attachment: trace
Description: Binary data

start Tue Sep  5 21:12:34 2000
time  1.6s
sent   0d 0d 0d 0d 0d                                   .....
rcvd   0d 0d 0d 0d 0d                                   .....
time  0.3s
sent   41 54 5a 0d                                      ATZ.
rcvd   41 54 5a 0d                                      ATZ.
time  0.9s
rcvd   0d 0a 4f 4b 0d 0a                                ..OK..
time  0.1s
sent   41 54 51 30 20 56 31 20 45 31 20 53 30 3d 30 20  ATQ0 V1 E1 S0=0 
       26 43 31 20 26 44 32 20 53 31 31 3d 35 35 20 2b  &C1 &D2 S11=55 +
       46 43 4c 41 53 53 3d 30 0d                       FCLASS=0.
rcvd   41 54 51 30 20 56 31 20 45 31 20 53 30 3d 30 20  ATQ0 V1 E1 S0=0 
       26 43 31 20 26 44 32 20 53 31 31 3d 35 35 20 2b  &C1 &D2 S11=55 +
       46 43 4c 41 53 53 3d 30 0d 0d 0a 4f 4b 0d 0a     FCLASS=0...OK..
time  0.1s
sent   41 54 4d 31 4c 33 0d                             ATM1L3.
rcvd   41 54 4d 31 4c 33 0d 0d 0a 4f 4b 0d 0a           ATM1L3...OK..
time  0.1s
sent   41 54 44 50 20 32 32 31 30 30 31 30 0d           ATDP 2210010.
rcvd   41 54 44 50 20 32 32 31 30 30 31 30 0d           ATDP 2210010.
time  33.0s
rcvd   0d 0a 43 4f 4e 4e 45 43 54 20 31 31 35 32 30 30  ..CONNECT 115200
       0d 0a                                            ..
time  1.0s
rcvd   0d 0a 0d 52 65 64 20 48 61 74 20 4c 69 6e 75 78  ...Red Hat Linux
rcvd   20 72 65 6c 65 61 73 65 20 36 2e 30 20 28 48 65   release 6.0 (He
       64 77 69 67 29 0a 0d 4b 65 72 6e 65 6c 20 32 2e  dwig)..Kernel 2.
       32 2e 31 30 20 6f 6e 20 61 6e 20 69 36 38 36 0a  2.10 on an i686.
       0d 0a 0d 0d 0a 69 73 70 31 31 2e 61 63 6f 72 70  .....isp11.acorp
       2e 72 6f 20 6c 6f 67 69 6e 3a 20                 .ro login: 
time  0.1s
sent   7e ff 7d 23 c0 21 7d 21 7d 21 7d 20 7d 34 7d 22  ~.}#.!}!}!} }4}"
       7d 26 7d 20 7d 20 7d 20 7d 20 7d 25 7d 26 ce 7d  }&} } } } }%}&.}
       22 a7 96 7d 27 7d 22 7d 28 7d 22 7d 34 21 7e     "..}'}"}(}"}4!~
time  0.2s
rcvd   7e 08 20 08 7d 23 40 0d 0a                       ~. .}#@..
time  0.1s
rcvd   7e ff 7d 23 c0 21 7d 21 7d 21 7d 20 7d 38 7d 22  ~.}#.!}!}!} }8}"
       7d 26 7d 20 7d 20 7d 20 7d 20 7d 23 7d 24        }&} } } } }#}$
rcvd   c0 23 7d 25 7d 26 7a 9c 95 e8 7d 27 7d 22 7d 28  .#}%}&z...}'}"}(
       7d 22 6f 35 7e                                   }"o5~
sent   7e ff 7d 23 c0 21 7d 22 7d 21 7d 20 7d 38 7d 22  ~.}#.!}"}!} }8}"
       7d 26 7d 20 7d 20 7d 20 7d 20 7d 23 7d 24 c0 23  }&} } } } }#}$.#
       7d 25 7d 26 7a 9c 95 e8 7d 27 7d 22 7d 28 7d 22  }%}&z...}'}"}(}"
       a3 d8 7e                                         ..~
time  2.8s
sent   7e ff 7d 23 c0 21 7d 21 7d 21 7d 20 7d 34 7d 22  ~.}#.!}!}!} }4}"
       7d 26 7d 20 7d 20 7d 20 7d 20 7d 25 7d 26 ce 7d  }&} } } } }%}&.}
       22 a7 96 7d 27 7d 22 7d 28 7d 22 7d 34 21 7e     "..}'}"}(}"}4!~
time  0.1s
rcvd   7e ff 7d 23 c0 21 7d 22 7d 21 7d 20 7d 34 7d 22  ~.}#.!}"}!} }4}"
rcvd   7d 26 7d 20 7d 20 7d 20 7d 20 7d 25 7d 26 ce 7d  }&} } } } }%}&.}
       22 a7 96 7d 27 7d 22 7d 28 7d 22 ff 48 7e        "..}'}"}(}".H~
sent   7e c0 23 01 01 00 0f 04 70 61 75 6c 05 69 63 65  ~.#.....paul.ice
       67 65 12 9c 7e                                   ge..~
time  0.1s
rcvd   7e c0 23 02 01 00 0d 08                          ~.#.....
rcvd   4c 6f 67 69 6e 20 6f 6b 1c 3d 7e                 Login ok.=~
sent   7e 80 21 01 01 00 1c 03 06 c0 a8 0b 01 02 06 00  ~.!.............
       2d 0f 01 81 06 00 00 00 00 83 06 00 00 00 00 52  -..............R
       1f 7e                                            .~
time  0.1s
rcvd   7e 80 21 01 01 00 10 03 06 d4 5d 85 76 02 06 00  ~.!.......].v...
       2d 0f 01 43 84 7e                                -..C.~
sent   7e 80 21 02 01 00 10 03 06 d4 5d 85 76 02 06 00  ~.!.......].v...
       2d 0f 01 62 1e 7e                                -..b.~
rcvd   7e 80 21 03 01 00 16 03 06 c1 e7 e8 cc 81 06 d4  ~.!.............
       5d 85 75 83 06 c1 e7 ec                          ].u.....
time  0.1s
rcvd   0a 96 50 7e                                      ..P~
sent   7e 80 21 01 02 00 1c 03 06 c1 e7 e8 cc 02 06 00  ~.!.............
       2d 0f 01 81 06 d4 5d 85 75 83 06 c1 e7 ec 0a 27  -.....].u......'
       34 7e                                            4~
time  0.1s
rcvd   7e 80 21 02 02 00 1c 03 06 c1 e7 e8 cc 02 06 00  ~.!.............
       2d 0f 01 81 06 d4 5d 85 75 83 06 c1 e7 ec 0a 14  -.....].u.......
       6e 7e                                            n~
time  1.2s
sent   7e 21 45 00 00 3b 05 55 00 00 40 11 70 d6 c1 e7  ~!E..;.U..@.p...
       e8 cc d4 5d 85 75 04 00 00 35 00 27 e8 63 86 5b  ...].u...5.'.c.[
       01 00 00 01 00 00 00 00 00 00 04 6d 61 69 6c 05  ...........mail.
       61 63 6f 72 70 02 72 6f 00 00 01 00 01 1a e6 7e  acorp.ro.......~
time  0.2s
rcvd   7e 21 45 00 00 71 68 1f 00 00 3f 11 0e d6 d4 5d  ~!E..qh...?....]
       85 75 c1 e7 e8 cc 00 35 04 00 00 5d 08 3f 86 5b  .u.....5...].?.[
       85 80 00 01 00 01 00 01 00 01 04 6d 61 69 6c 05  ...........mail.
       61 63 6f 72 70 02 72 6f 00 00 01 00 01 c0 0c 00  acorp.ro........
rcvd   01 00 01 00 01 51 80 00 04 d4 5d 85 75 05 61 63  .....Q....].u.ac
       6f 72 70 02 72 6f 00 00 02 00 01 00 01 51 80 00  orp.ro.......Q..
       02 c0 2f c0 2f 00 01 00 01 00 01 51 80 00 04 d4  .././......Q....
       5d 85 75 ac bf 7e                                ].u..~
sent   21 45 00 00 3c 05 56 40 00 40 06 30 df c1 e7 e8  !E..<.V@.@.0....
       cc d4 5d 85 75 04 6b 00 19 e2 d1 26 5c 00 00 00  ..].u.k....&\...
       00 a0 02 7d 5d 78 83 d0 00 00 02 04 05 b4 04 02  ...}]x..........
       08 0a 00 05 34 80 00 00 00 00 01 03 03 00 5b 71  ....4.........[q
       7e                                               ~
time  0.1s
rcvd   21 45 00 00 3c 68 20 40                          !E..<h @
rcvd   00 3f 06 cf 14 d4 5d 85 75 c1 e7 e8 cc 00 19 04  .?....].u.......
       6b de d4 ee df e2 d1 26 5d a0 12 7d 5d 78 d8 96  k......&]..}]x..
       00 00 02 04 05 b4 04 02 08 0a 05 47 d8 2c 00 05  ...........G.,..
       34 80 01 03 03 00 59 ce 7e                       4.....Y.~
sent   2f 45 00 00 34 05 57 40 00 40 00 30 e6 c1 e7 e8  /E..4.W@.@.0....
       cc d4 5d 85 75 04 6b 00 19 e2 d1 26 5d de d4 ee  ..].u.k....&]...
       e0 80 10 7d 5d 78 07 4c 00 00 01 01 08 0a 00 05  ...}]x.L........
       34 90 05 47 d8 2c 93 50 7e                       4..G.,.P~
time  0.2s
rcvd   21 45 00 00 3c 68 25 40 00 3f 06 cf 0f d4 5d 85  !E..<h%@.?....].
       75 c1 e7 e8 cc 04 62 00                          u.....b.
rcvd   71 de b1 cb e9 00 00 00 00 a0 02 7d 5d 78 39 15  q..........}]x9.
       00 00 02 04 05 b4 04 02 08 0a 05 47 d8 3c 00 00  ...........G.<..
       00 00 01 03 03 00 06 b4 7e                       ........~
sent   21 45 00 00 3c 05 58 40 00 40 06 30 dd c1 e7 e8  !E..<.X@.@.0....
       cc d4 5d 85 75 00 71 04 62 e3 01 84 59 de b1 cb  ..].u.q.b...Y...
       ea a0 12 77 c4 a2 b8 00 00 02 04 05 b4 04 02 08  ...w............
       0a 00 05 34 9f 05 47 d8 3c 01 03 03 00 5f 02 7e  ...4..G.<...._.~
time  0.1s
rcvd   2f 45 00 00 34 68 26 40 00 3f 00 cf 16 d4 5d 85  /E..4h&@.?....].
       75 c1 e7 e8 cc 04 62 00                          u.....b.
rcvd   71 de b1 cb ea e3 01 84 5a 80 10 7d 5d 78 cb bc  q.......Z..}]x..
       00 00 01 01 08 0a 05 47 d8 49 00 05 34 9f 1d 96  .......G.I..4...
       7e 2d 10 fc 09 31 31 33 31 2c 32 35 0d 0a 6e 6c  ~-...1131,25..nl
       7e                                               ~
sent   2f 45 00 00 34 05 59 40 00 40 01 30 e4 c1 e7 e8  /E..4.Y@.@.0....
       cc d4 5d 85 75 00 71 04 62 e3 01 84 5a de b1 cb  ..].u.q.b...Z...
       f3 80 10 77 c4 d1 59 00 00 01 01 08 0a 00 05 34  ...w..Y........4
       ad 05 47 d8 49 e3 7c 7e                          ..G.I.|~
sent   2d 12 eb 4c 00 04 ac 31 31 33 31 20 2c 20 32 35  -..L...1131 , 25
       20 3a 20 55 53 45 52 49 44 20 3a 20 4f 54 48 45   : USERID : OTHE
       52 20 3a 72 6f 6f 74 0d 0a cc b2 7e              R :root....~
time  0.2s
rcvd   2f 45 00 00 34 68 28 40 00 3f 00 cf 14 d4 5d 85  /E..4h(@.?....].
       75 c1 e7 e8 cc 04 62 00 71 de b1 cb f3 e3 01 84  u.....b.q.......
       7c 80 10 7d 5d 78 cb 73 00 00 01 01 08 0a 05 47  |..}]x.s.......G
       d8 59 00 05 34 ad e6 2c 7e 21 45 00 00 34 68 29  .Y..4..,~!E..4h)
       40 00 3f 06 cf 13 d4 5d 85 75 c1 e7 e8 cc 04 62  @.?....].u.....b
rcvd   00 71 de b1 cb f3 e3 01 84 7c 80 11 7d 5d 78 cb  .q.......|..}]x.
       72 00 00 01 01 08 0a 05 47 d8 59 00 05 34 ad b3  r.......G.Y..4..
       c3 7e 2f 45 00 00 83 68 2a 40 00 3f 01 ce c3 d4  .~/E...h*@.?....
       5d 85 75 c1 e7 e8 cc 00 19 04 6b de d4 ee e0 e2  ].u.......k.....
       d1 26 5d 80 18 7d 5d 78 98 20 00 00 01 01 08 0a  .&]..}]x. ......
       05 47 d8 5a 00 05 34 90 32 32 30 20 69 73 70 2e  .G.Z..4.220 isp.
       61 63 6f 72 70 2e 72 6f                          acorp.ro
sent   2f 45 00 00 34 05 5b 40 00 40 01 30 e2 c1 e7 e8  /E..4.[@.@.0....
       cc d4 5d 85 75 00 71 04 62 e3 01 84 7c de b1 cb  ..].u.q.b...|...
       f4 80 10 7c 70 cc 66 00 00 01 01 08 0a 00 05 34  ...|p.f........4
       c1 05 47 d8 59 f6 02 7e                          ..G.Y..~
sent   21 45 00 00 34 05 5c 40 00 40 06 30 e1 c1 e7 e8  !E..4.\@.@.0....
       cc d4 5d 85 75 00 71 04 62 e3 01 84 7c de b1 cb  ..].u.q.b...|...
       f4 80 11 7c 70 cc 65 00 00 01 01 08 0a 00 05 34  ...|p.e........4
       c1 05 47 d8 59 cf 6e 7e                          ..G.Y.n~
rcvd   20 45 53 4d 54 50 20 53 65 6e 64 6d 61 69 6c 20   ESMTP Sendmail 
       38 2e 31 31 2e 30 2f 38 2e 31 30 2e 32 3b 20 54  8.11.0/8.10.2; T
       75                                               u
rcvd   65 2c 20 35 20 53 65 70 20 32 30 30 30 20 32 31  e, 5 Sep 2000 21
       3a 31 31 3a 35 36 20 2b 30 33 30 30 0d 0a 60 c2  :11:56 +0300..`.
       7e                                               ~
sent   2f 45 00 00 34 05 5d 40 00 40 00 30 e0 c1 e7 e8  /E..4.]@.@.0....
       cc d4 5d 85 75 04 6b 00 19 e2 d1 26 5d de d4 ef  ..].u.k....&]...
       2f 80 10 7d 5d 29 06 eb 00 00 01 01 08 0a 00 05  /..}])..........
       34 c3 05 47 d8 5a 84 3d 7e                       4..G.Z.=~
sent   2d 12 d7 2c 4f 45 48 4c 4f 20 61 63 6f 72 70 2e  -..,OEHLO acorp.
       72 6f 0d 0a fc 83 7e                             ro....~
time  0.2s
rcvd   2f 45 00 00 34 68 2b 40 00 3f 00 cf 11 d4 5d 85  /E..4h+@.?....].
       75 c1 e7 e8 cc 04 62 00 71 de b1 cb f4 e3 01 84  u.....b.q.......
       7d 5d 80 10 7d 5d 78 cb                          }]..}]x.
rcvd   49 00 00 01 01 08 0a 05 47 d8 6d 00 05 34 c1 33  I.......G.m..4.3
rcvd   86 7e 2f 45 00 00 34 68 2c 40 00 3f 01 cf 10 d4  .~/E..4h,@.?....
rcvd   5d 85 75 c1 e7 e8 cc 00 19 04 6b de d4 ef 2f e2  ].u.......k.../.
       d1 26 6c 80 10 7d 5d 78 06 79 00 00 01 01 08 0a  .&l..}]x.y......
       05 47 d8 6e 00 05 34 c3 63 00 7e 2d 10 58 2b 32  .G.n..4.c.~-.X+2
       35 30 2d 69 73 70 2e 61 63 6f 72 70 2e 72 6f 20  50-isp.acorp.ro 
       48 65 6c 6c 6f 20 49 44 45 4e 54 3a 72 6f 6f 74  Hello IDENT:root
       40 63 30 39 2e 61 63 6f 72 70 2e 72 6f 20 5b 31  @c09.acorp.ro [1
rcvd   39 33 2e 32 33 31 2e 32 33 32 2e 32 30 34 5d 2c  93.231.232.204],
       20 70 6c 65 61 73 65 64 20 74 6f 20 6d 65 65 74   pleased to meet
       20 79 6f 75 0d 0a 32 35 30 2d 45 4e 48 41 4e 43   you..250-ENHANC
       45 44 53 54 41 54 55 53                          EDSTATUS
rcvd   43 4f 44 45 53 0d 0a 32 35 30 2d 45 58 50 4e 0d  CODES..250-EXPN.
       0a 32 35 30 2d 56 45 52                          .250-VER
rcvd   42 0d 0a 32 35 30 2d 38 42 49 54 4d 49 4d 45 0d  B..250-8BITMIME.
       0a 32 35 30 2d 53 49 5a 45 20 34 30 30 30 30 30  .250-SIZE 400000
       30 0d 0a 32 35 30 2d 44 53 4e 0d 0a 32 35 30 2d  0..250-DSN..250-
       4f 4e 45 58 0d 0a 32 35 30 2d 45 54 52 4e 0d 0a  ONEX..250-ETRN..
       32 35 30 2d 58 55 53 52 0d 0a 32 35 30 20 48 45  250-XUSR..250 HE
       4c 50 0d 0a 76 75 7e                             LP..vu~
sent   2f 45 00 00 4f 05 5f 40 00 40 00 30 c3 c1 e7 e8  /E..O._@.@.0....
       cc d4 5d 85 75 04 6b 00 19 e2 d1 26 6c de d4 f0  ..].u.k....&l...
       04 80 18 7d 5d 78 a9 67 00 00 01 01 08 0a 00 05  ...}]x.g........
       34 d8 05 47 d8 6e 4d 41 49 4c 20 46 52 4f 4d 3a  4..G.nMAIL FROM:
       3c 70 61 75 6c 40 61 63 6f 72 70 2e 72 6f 3e 0d  <paul@xxxxxxxx>.
       0a 7c dd 7e                                      .|.~
time  0.2s
rcvd   2f 45 00 00 5c 68 30 40 00 3f 01 ce e4 d4 5d 85  /E..\h0@.?....].
       75 c1 e7 e8 cc 00 19 04 6b de d4 f0 04 e2 d1 26  u.......k......&
rcvd   87 80 18 7d 5d 78 0c a9 00 00 01 01 08 0a 05 47  ...}]x.........G
       d8 84 00 05 34 d8 32 35 30 20 32 2e 31 2e 30 20  ....4.250 2.1.0 
       3c 70 61 75 6c 40 61 63 6f 72 70 2e 72 6f 3e 2e  <paul@xxxxxxxx>.
       2e 2e 20 53 65 6e 64 65 72 20 6f 6b 0d 0a d9 16  .. Sender ok....
       7e                                               ~
sent   2f 45 00 00 4f 05 60 40 00 40 00 30 c2 c1 e7 e8  /E..O.`@.@.0....
       cc d4 5d 85 75 04 6b 00 19 e2 d1 26 87 de d4 f0  ..].u.k....&....
       2c 80 18 7d 5d 78 71 03 00 00 01 01 08 0a 00 05  ,..}]xq.........
       34 e8 05 47 d8 84 52 43 50 54 20 54 4f 3a 3c 6a  4..G..RCPT TO:<j
       6f 63 68 65 6e 40 73 63 72 61 6d 2e 64 65 3e 0d  ochen@xxxxxxxx>.
       0a 4b 9e 7e                                      .K.~
time  0.2s
rcvd   2f 45 00 00 34 68 33 40 00 3f 01 cf 09 d4 5d 85  /E..4h3@.?....].
       75 c1 e7 e8 cc 00 19 04 6b de d4 f0 2c e2 d1 26  u.......k...,..&
       a2 80 10 7d 5d 78 04 f9 00 00 01 01 08 0a 05 47  ...}]x.........G
rcvd   d8 96 00 05 34 e8 dd 9e 7e                       ....4...~
time  5.3s
rcvd   7e 2f 45 00 00 61 68 45 40 00 3f 01 ce ca d4 5d  ~/E..ahE@.?....]
       85 75 c1 e7 e8 cc 00 19 04 6b de d4 f0 2c e2 d1  .u.......k...,..
       26 a2 80 18 7d 5d 78 05                          &...}]x.
rcvd   38 00 00 01 01 08 0a 05 47 da ab 00 05 34 e8 32  8.......G....4.2
       35 30 20 32 2e 31 2e 35 20 3c 6a 6f 63 68 65 6e  50 2.1.5 <jochen
       40 73 63 72 61 6d 2e 64 65 3e 2e 2e 2e 20 52 65  @scram.de>... Re
       63 69 70 69 65 6e 74 20 6f 6b 0d 0a 7c 31 7e     cipient ok..|1~
sent   7e 2f 45 00 00 55 05 61 40 00 40 00 30 bb c1 e7  ~/E..U.a@.@.0...
       e8 cc d4 5d 85 75 04 6b 00 19 e2 d1 26 a2 de d4  ...].u.k....&...
       f0 59 80 18 7d 5d 78 5a 17 00 00 01 01 08 0a 00  .Y..}]xZ........
       05 37 0f 05 47 da ab 52 43 50 54 20 54 4f 3a 3c  .7..G..RCPT TO:<
       65 74 68 65 72 65 61 6c 2d 64 65 76 40 7a 69 6e  ethereal-dev@zin
       67 2e 6f 72 67 3e 0d 0a 8e 50 7e                 g.org>...P~
time  0.2s
rcvd   2f 45 00 00 34 68 4c 40 00 3f 01 ce f0 d4 5d 85  /E..4hL@.?....].
       75 c1 e7 e8 cc 00 19 04 6b de d4 f0 59 e2 d1 26  u.......k...Y..&
       c3 80 10 7d 5d 78 00 5d 00 00 01 01 08 0a 05 47  ...}]x.].......G
       da bd 00 05 37 0f ab 5b 7e                       ....7..[~
time  0.4s
rcvd   2f 45 00 00 67 68 52 40 00 3f 01 ce b7 d4 5d 85  /E..ghR@.?....].
       75 c1 e7 e8 cc 00 19 04 6b de d4 f0 59 e2 d1 26  u.......k...Y..&
       c3 80 18 7d 5d 78 f0 31 00 00 01 01 08 0a 05 47  ...}]x.1.......G
       da e6 00 05 37 0f 32 35 30 20 32 2e 31 2e 35 20  ....7.250 2.1.5 
       3c 65 74 68 65 72 65 61 6c 2d 64 65 76 40 7a 69  <ethereal-dev@zi
       6e 67 2e 6f 72 67 3e 2e                          ng.org>.
rcvd   2e 2e 20 52 65 63 69 70 69 65 6e 74 20 6f 6b 0d  .. Recipient ok.
       0a aa 65 7e                                      ..e~
sent   2f 45 00 00 3a 05 62 40 00 40 00 30 d5 c1 e7 e8  /E..:.b@.@.0....
       cc d4 5d 85 75 04 6b 00 19 e2 d1 26 c3 de d4 f0  ..].u.k....&....
       8c 80 18 7d 5d 78 5a 2a 00 00 01 01 08 0a 00 05  ...}]xZ*........
       37 4b 05 47 da e6 44 41 54 41 0d 0a b3 b2 7e     7K.G..DATA....~
time  0.2s
rcvd   2f 45 00 00 66 68 53 40 00 3f 01 ce b7 d4 5d 85  /E..fhS@.?....].
       75 c1 e7 e8 cc 00 19 04 6b de d4 f0 8c e2 d1 26  u.......k......&
       c9 80 18 7d 5d 78 ab 4b 00 00 01 01 08 0a 05 47  ...}]x.K.......G
       da f7 00 05 37 4b 33 35                          ....7K35
rcvd   34 20 45 6e 74 65 72 20 6d 61 69 6c 2c 20 65 6e  4 Enter mail, en
       64 20 77 69 74 68 20 22 2e 22 20 6f 6e 20 61 20  d with "." on a 
       6c 69 6e 65 20 62 79 20 69 74 73 65 6c 66 0d 0a  line by itself..
       bb 70 7e                                         .p~
sent   2f 45 00 00 42 05 63 40 00 40 00 30 cc c1 e7 e8  /E..B.c@.@.0....
       cc d4 5d 85 75 04 6b 00 19 e2 d1 26 c9 de d4 f0  ..].u.k....&....
       be 80 18 7d 5d 78 af 0b 00 00 01 01 08 0a 00 05  ...}]x..........
       37 5b 05 47 da f7 53 65 6e 64 65 72 3a 20 72 6f  7[.G..Sender: ro
       6f 74 0d 0a e0 1d 7e                             ot....~
sent   2d 1f bf 24 4d 65 73 73 61 67 65 2d 49 44 3a 20  -..$Message-ID: 
       3c 33 39 42 35 33 37 42 42 2e 35 34 33 34 35 38  <39B537BB.543458
       36 46 40 61 63 6f 72 70 2e 72 6f 3e 0d 0a 44 61  6F@xxxxxxxx>..Da
       74 65 3a 20 54 75 65 2c 20 30 35 20 53 65 70 20  te: Tue, 05 Sep 
       32 30 30 30 20 32 31 3a 31 33 3a 31 35 20 2b 30  2000 21:13:15 +0
       33 30 30 0d 0a 46 72 6f 6d 3a 20 50 61 75 6c 20  300..From: Paul 
       49 6f 6e 65 73 63 75 20 3c 70 61 75 6c 40 61 63  Ionescu <paul@ac
       6f 72 70 2e 72 6f 3e 0d 0a 58 2d 4d 61 69 6c 65  orp.ro>..X-Maile
       72 3a 20 4d 6f 7a 69 6c 6c 61 20 34 2e 37 20 5b  r: Mozilla 4.7 [
       65 6e 5d 20 28 58 31 31 3b 20 49 3b 20 4c 69 6e  en] (X11; I; Lin
       75 78 20 32 2e 32 2e 31 32 2d 32 30 20 69 35 38  ux 2.2.12-20 i58
       36 29 0d 0a 58 2d 41 63 63 65 70 74 2d 4c 61 6e  6)..X-Accept-Lan
       67 75 61 67 65 3a 20 65 6e 0d 0a 4d 49 4d 45 2d  guage: en..MIME-
       56 65 72 73 69 6f 6e 3a 20 31 2e 30 0d 0a 54 6f  Version: 1.0..To
       3a 20 4a 6f 63 68 65 6e 20 46 72 69 65 64 72 69  : Jochen Friedri
       63 68 20 3c 6a 6f 63 68 65 6e 40 73 63 72 61 6d  ch <jochen@scram
       2e 64 65 3e 0d 0a 43 43 3a 20 65 74 68 20 3c 65  .de>..CC: eth <e
       74 68 65 72 65 61 6c 2d 64 65 76 40 7a 69 6e 67  thereal-dev@zing
       2e 6f 72 67 3e 0d 0a 53 75 62 6a 65 63 74 3a 20  .org>..Subject: 
       52 65 3a 20 5b 65 74 68 65 72 65 61 6c 2d 64 65  Re: [ethereal-de
       76 5d 20 43 61 70 74 75 72 69 6e 67 20 66 72 6f  v] Capturing fro
       6d 20 61 20 73 79 6e 63 68 72 6f 6e 6f 75 73 20  m a synchronous 
       61 64 61 70 74 65 72 20 63 61 72 64 20 69 6e 6c  adapter card inl
       69 6e 75 78 0d 0a 52 65 66 65 72 65 6e 63 65 73  inux..References
       3a 20 3c 50 69 6e 65 2e 4c 4e 58 2e 34 2e 32 31  : <Pine.LNX.4.21
       2e 30 30 30 39 30 32 32 33 35 31 35 33 30 2e 33  .0009022351530.3
       31 31 36 2d 31 30 30 30 30 30 40 67 66 77 31 30  116-100000@gfw10
       30 34 34 2e 67 65 6e 6f 72 7a 2e 64 65 3e 0d 0a  044.genorz.de>..
       43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 74 65  Content-Type: te
       78 74 2f 70 6c 61 69 6e 3b 20 63 68 61 72 73 65  xt/plain; charse
       74 3d 69 73 6f 2d 38 38 35 39 2d 32 0d 0a 43 6f  t=iso-8859-2..Co
       6e 74 65 6e 74 2d 54 72 61 6e 73 66 65 72 2d 45  ntent-Transfer-E
       6e 63 6f 64 69 6e 67 3a 20 37 62 69 74 0d 0a 0d  ncoding: 7bit...
       0a 48 65 6c 6c 6f 20 4a 6f 63 68 65 6e 2c 0d 0a  .Hello Jochen,..
       0d 0a 59 6f 75 20 73 61 69 64 20 74 68 61 74 3a  ..You said that:
       0d 0a 3e 20 4e 6f 72 6d 61 6c 6c 79 2c 20 79 6f  ..> Normally, yo
       75 20 6f 6e 6c 79 20 68 61 76 65 20 74 68 65 20  u only have the 
       69 70 70 70 30 20 64 65 76 69 63 65 2e 20 48 6f  ippp0 device. Ho
       77 65 76 65 72 2c 20 66 6f 72 20 70 61 73 73 69  wever, for passi
       76 65 20 49 53 44 4e 20 63 61 72 64 73 0d 0a 3e  ve ISDN cards..>
       20 28 68 69 73 61 78 20 64 72 69 76 65 72 29 2c   (hisax driver),
       20 79 6f 75 20 63 61 6e 20 73 77 69 74 63 68 20   you can switch 
       6f 6e 20 66 75 6c 6c 20 74 72 61 63 65 20 6f 66  on full trace of
       20 62 6f 74 68 20 42 20 61 6e 64 20 44 20 63 68   both B and D ch
       61 6e 6e 65 6c 73 20 61 6e 64 0d 0a 3e 20 67 65  annels and..> ge
       74 20 74 68 65 20 64 61 74 61 20 61 73 20 68 65  t the data as he
       78 20 64 75 6d 70 20 66 72 6f 6d 20 2f 64 65 76  x dump from /dev
       2f 69 73 64 6e 63 74 72 6c 3c 78 3e 2e 0d 0a 0d  /isdnctrl<x>....
       0a 54 68 69 73 20 68 65 78 20 64 75 6d 70 20 66  .This hex dump f
       72 6f 6d 20 2f 64 65 76 2f 69 73 64 6e 63 74 72  rom /dev/isdnctr
       6c 3c 78 3e 20 69 73 20 64 69 72 65 63 74 6c 79  l<x> is directly
       20 69 6e 74 65 72 70 72 65 74 61 62 6c 65 20 62   interpretable b
       79 0d 0a 65 74 68 65 72 65 61 6c 20 3f 20 0d 0a  y..ethereal ? ..
       41 6e 64 20 69 66 20 6e 6f 74 2c 20 69 73 20 74  And if not, is t
       68 65 72 65 20 61 6e 79 20 70 72 6f 67 72 61 6d  here any program
       20 74 68 61 74 20 63 61 6e 20 63 6f 6e 76 65 72   that can conver
       74 20 66 72 6f 6d 20 74 68 69 73 20 68 65 78 20  t from this hex 
       64 75 6d 70 20 74 6f 0d 0a 61 20 66 6f 72 6d 61  dump to..a forma
       74 20 69 6e 74 65 72 70 72 65 74 61 62 6c 65 20  t interpretable 
       62 79 20 65 74 68 65 72 65 61 6c 20 3f 0d 0a 0d  by ethereal ?...
       0a 0d 0a 54 68 61 6e 6b 73 2c 0d 0a 50 61 75 6c  ...Thanks,..Paul
       58 ae 7e                                         X.~
time  0.1s
rcvd   2f 45 00 00 34 68 54 40 00 3f 01 ce e8 d4 5d 85  /E..4hT@.?....].
       75 c1 e7 e8 cc 00 19 04 6b de d4 f0 be e2 d1 26  u.......k......&
       d7 80 10 7d 5d 78 ff 4a 00 00 01 01 08 0a 05 47  ...}]x.J.......G
       db 0a 00 05 37 5b 6f fa 7e                       ....7[o.~
time  0.4s
sent   2f 45 00 04 00 05 65 40 00 40 00 2d 0c c1 e7 e8  /E....e@.@.-....
       cc d4 5d 85 75 04 6b 00 19 e2 d1 26 d7 de d4 f0  ..].u.k....&....
       be 80 18 7d 5d 78 be e1 00 00 01 01 08 0a 00 05  ...}]x..........
       37 8b 05 47 db 0a 4d 65 73 73 61 67 65 2d 49 44  7..G..Message-ID
       3a 20 3c 33 39 42 35 33 37 42 42 2e 35 34 33 34  : <39B537BB.5434
       35 38 36 46 40 61 63 6f 72 70 2e 72 6f 3e 0d 0a  586F@xxxxxxxx>..
       44 61 74 65 3a 20 54 75 65 2c 20 30 35 20 53 65  Date: Tue, 05 Se
       70 20 32 30 30 30 20 32 31 3a 31 33 3a 31 35 20  p 2000 21:13:15 
       2b 30 33 30 30 0d 0a 46 72 6f 6d 3a 20 50 61 75  +0300..From: Pau
       6c 20 49 6f 6e 65 73 63 75 20 3c 70 61 75 6c 40  l Ionescu <paul@
       61 63 6f 72 70 2e 72 6f 3e 0d 0a 58 2d 4d 61 69  acorp.ro>..X-Mai
       6c 65 72 3a 20 4d 6f 7a 69 6c 6c 61 20 34 2e 37  ler: Mozilla 4.7
       20 5b 65 6e 5d 20 28 58 31 31 3b 20 49 3b 20 4c   [en] (X11; I; L
       69 6e 75 78 20 32 2e 32 2e 31 32 2d 32 30 20 69  inux 2.2.12-20 i
       35 38 36 29 0d 0a 58 2d 41 63 63 65 70 74 2d 4c  586)..X-Accept-L
       61 6e 67 75 61 67 65 3a 20 65 6e 0d 0a 4d 49 4d  anguage: en..MIM
       45 2d 56 65 72 73 69 6f 6e 3a 20 31 2e 30 0d 0a  E-Version: 1.0..
       54 6f 3a 20 4a 6f 63 68 65 6e 20 46 72 69 65 64  To: Jochen Fried
       72 69 63 68 20 3c 6a 6f 63 68 65 6e 40 73 63 72  rich <jochen@scr
       61 6d 2e 64 65 3e 0d 0a 43 43 3a 20 65 74 68 20  am.de>..CC: eth 
       3c 65 74 68 65 72 65 61 6c 2d 64 65 76 40 7a 69  <ethereal-dev@zi
       6e 67 2e 6f 72 67 3e 0d 0a 53 75 62 6a 65 63 74  ng.org>..Subject
       3a 20 52 65 3a 20 5b 65 74 68 65 72 65 61 6c 2d  : Re: [ethereal-
       64 65 76 5d 20 43 61 70 74 75 72 69 6e 67 20 66  dev] Capturing f
       72 6f 6d 20 61 20 73 79 6e 63 68 72 6f 6e 6f 75  rom a synchronou
       73 20 61 64 61 70 74 65 72 20 63 61 72 64 20 69  s adapter card i
       6e 6c 69 6e 75 78 0d 0a 52 65 66 65 72 65 6e 63  nlinux..Referenc
       65 73 3a 20 3c 50 69 6e 65 2e 4c 4e 58 2e 34 2e  es: <Pine.LNX.4.
       32 31 2e 30 30 30 39 30 32 32 33 35 31 35 33 30  21.0009022351530
       2e 33 31 31 36 2d 31 30 30 30 30 30 40 67 66 77  .3116-100000@gfw
       31 30 30 34 34 2e 67 65 6e 6f 72 7a 2e 64 65 3e  10044.genorz.de>
       0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20  ..Content-Type: 
       74 65 78 74 2f 70 6c 61 69 6e 3b 20 63 68 61 72  text/plain; char
       73 65 74 3d 69 73 6f 2d 38 38 35 39 2d 32 0d 0a  set=iso-8859-2..
       43 6f 6e 74 65 6e 74 2d 54 72 61 6e 73 66 65 72  Content-Transfer
       2d 45 6e 63 6f 64 69 6e 67 3a 20 37 62 69 74 0d  -Encoding: 7bit.
       0a 0d 0a 48 65 6c 6c 6f 20 4a 6f 63 68 65 6e 2c  ...Hello Jochen,
       0d 0a 0d 0a 59 6f 75 20 73 61 69 64 20 74 68 61  ....You said tha
       74 3a 0d 0a 3e 20 4e 6f 72 6d 61 6c 6c 79 2c 20  t:..> Normally, 
       79 6f 75 20 6f 6e 6c 79 20 68 61 76 65 20 74 68  you only have th
       65 20 69 70 70 70 30 20 64 65 76 69 63 65 2e 20  e ippp0 device. 
       48 6f 77 65 76 65 72 2c 20 66 6f 72 20 70
EOF
/*
 * pppdump - print out the contents of a record file generated by
 * pppd in readable form.
 *
 * Copyright (C) 1999  Paul Mackerras.  All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version
 *  2 of the License, or (at your option) any later version.
 */
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include "ppp_defs.h"
#include "ppp-comp.h"

int hexmode;
int pppmode;
int reverse;
int decompress;
int mru = 1500;
int abs_times;
time_t start_time;
int start_time_tenths;
int tot_sent, tot_rcvd;

extern int optind;
extern char *optarg;

main(ac, av)
    int ac;
    char **av;
{
    int i;
    char *p;
    FILE *f;

    while ((i = getopt(ac, av, "hprdm:a")) != -1) {
	switch (i) {
	case 'h':
	    hexmode = 1;
	    break;
	case 'p':
	    pppmode = 1;
	    break;
	case 'r':
	    reverse = 1;
	    break;
	case 'd':
	    decompress = 1;
	    break;
	case 'm':
	    mru = atoi(optarg);
	    break;
	case 'a':
	    abs_times = 1;
	    break;
	default:
	    fprintf(stderr, "Usage: %s [-h | -p[d]] [-r] [-m mru] [-a] [file ...]\n", av[0]);
	    exit(1);
	}
    }
    if (optind >= ac)
	dumplog(stdin);
    else {
	for (i = optind; i < ac; ++i) {
	    p = av[i];
	    if ((f = fopen(p, "r")) == NULL) {
		perror(p);
		exit(1);
	    }
	    if (pppmode)
		dumpppp(f);
	    else
		dumplog(f);
	    fclose(f);
	}
    }
    exit(0);
}

dumplog(f)
    FILE *f;
{
    int c, n, k, col;
    int nb, c2;
    unsigned char buf[16];

    while ((c = getc(f)) != EOF) {
	switch (c) {
	case 1:
	case 2:
	    if (reverse)
		c = 3 - c;
	    printf("%s %c", c==1? "sent": "rcvd", hexmode? ' ': '"');
	    col = 6;
	    n = getc(f);
	    n = (n << 8) + getc(f);
	    *(c==1? &tot_sent: &tot_rcvd) += n;
	    nb = 0;
	    for (; n > 0; --n) {
		c = getc(f);
		if (c == EOF) {
		    printf("\nEOF\n");
		    exit(0);
		}
		if (hexmode) {
		    if (nb >= 16) {
			printf("  ");
			for (k = 0; k < nb; ++k) {
			    c2 = buf[k];
			    putchar((' ' <= c2 && c2 <= '~')? c2: '.');
			}
			printf("\n      ");
			nb = 0;
		    }
		    buf[nb++] = c;
		    printf(" %.2x", c);
		} else {
		    k = (' ' <= c && c <= '~')? (c != '\\' && c != '"')? 1: 2: 3;
		    if ((col += k) >= 78) {
			printf("\n      ");
			col = 6 + k;
		    }
		    switch (k) {
		    case 1:
			putchar(c);
			break;
		    case 2:
			printf("\\%c", c);
			break;
		    case 3:
			printf("\\%.2x", c);
			break;
		    }
		}
	    }
	    if (hexmode) {
		for (k = nb; k < 16; ++k)
		    printf("   ");
		printf("  ");
		for (k = 0; k < nb; ++k) {
		    c2 = buf[k];
		    putchar((' ' <= c2 && c2 <= '~')? c2: '.');
		}
	    } else
		putchar('"');
	    printf("\n");
	    break;
	case 3:
	case 4:
	    printf("end %s\n", c==3? "send": "recv");
	    break;
	case 5:
	case 6:
	case 7:
	    show_time(f, c);
	    break;
	default:
	    printf("?%.2x\n");
	}
    }
}

/*
 * FCS lookup table as calculated by genfcstab.
 */
static u_short fcstab[256] = {
	0x0000,	0x1189,	0x2312,	0x329b,	0x4624,	0x57ad,	0x6536,	0x74bf,
	0x8c48,	0x9dc1,	0xaf5a,	0xbed3,	0xca6c,	0xdbe5,	0xe97e,	0xf8f7,
	0x1081,	0x0108,	0x3393,	0x221a,	0x56a5,	0x472c,	0x75b7,	0x643e,
	0x9cc9,	0x8d40,	0xbfdb,	0xae52,	0xdaed,	0xcb64,	0xf9ff,	0xe876,
	0x2102,	0x308b,	0x0210,	0x1399,	0x6726,	0x76af,	0x4434,	0x55bd,
	0xad4a,	0xbcc3,	0x8e58,	0x9fd1,	0xeb6e,	0xfae7,	0xc87c,	0xd9f5,
	0x3183,	0x200a,	0x1291,	0x0318,	0x77a7,	0x662e,	0x54b5,	0x453c,
	0xbdcb,	0xac42,	0x9ed9,	0x8f50,	0xfbef,	0xea66,	0xd8fd,	0xc974,
	0x4204,	0x538d,	0x6116,	0x709f,	0x0420,	0x15a9,	0x2732,	0x36bb,
	0xce4c,	0xdfc5,	0xed5e,	0xfcd7,	0x8868,	0x99e1,	0xab7a,	0xbaf3,
	0x5285,	0x430c,	0x7197,	0x601e,	0x14a1,	0x0528,	0x37b3,	0x263a,
	0xdecd,	0xcf44,	0xfddf,	0xec56,	0x98e9,	0x8960,	0xbbfb,	0xaa72,
	0x6306,	0x728f,	0x4014,	0x519d,	0x2522,	0x34ab,	0x0630,	0x17b9,
	0xef4e,	0xfec7,	0xcc5c,	0xddd5,	0xa96a,	0xb8e3,	0x8a78,	0x9bf1,
	0x7387,	0x620e,	0x5095,	0x411c,	0x35a3,	0x242a,	0x16b1,	0x0738,
	0xffcf,	0xee46,	0xdcdd,	0xcd54,	0xb9eb,	0xa862,	0x9af9,	0x8b70,
	0x8408,	0x9581,	0xa71a,	0xb693,	0xc22c,	0xd3a5,	0xe13e,	0xf0b7,
	0x0840,	0x19c9,	0x2b52,	0x3adb,	0x4e64,	0x5fed,	0x6d76,	0x7cff,
	0x9489,	0x8500,	0xb79b,	0xa612,	0xd2ad,	0xc324,	0xf1bf,	0xe036,
	0x18c1,	0x0948,	0x3bd3,	0x2a5a,	0x5ee5,	0x4f6c,	0x7df7,	0x6c7e,
	0xa50a,	0xb483,	0x8618,	0x9791,	0xe32e,	0xf2a7,	0xc03c,	0xd1b5,
	0x2942,	0x38cb,	0x0a50,	0x1bd9,	0x6f66,	0x7eef,	0x4c74,	0x5dfd,
	0xb58b,	0xa402,	0x9699,	0x8710,	0xf3af,	0xe226,	0xd0bd,	0xc134,
	0x39c3,	0x284a,	0x1ad1,	0x0b58,	0x7fe7,	0x6e6e,	0x5cf5,	0x4d7c,
	0xc60c,	0xd785,	0xe51e,	0xf497,	0x8028,	0x91a1,	0xa33a,	0xb2b3,
	0x4a44,	0x5bcd,	0x6956,	0x78df,	0x0c60,	0x1de9,	0x2f72,	0x3efb,
	0xd68d,	0xc704,	0xf59f,	0xe416,	0x90a9,	0x8120,	0xb3bb,	0xa232,
	0x5ac5,	0x4b4c,	0x79d7,	0x685e,	0x1ce1,	0x0d68,	0x3ff3,	0x2e7a,
	0xe70e,	0xf687,	0xc41c,	0xd595,	0xa12a,	0xb0a3,	0x8238,	0x93b1,
	0x6b46,	0x7acf,	0x4854,	0x59dd,	0x2d62,	0x3ceb,	0x0e70,	0x1ff9,
	0xf78f,	0xe606,	0xd49d,	0xc514,	0xb1ab,	0xa022,	0x92b9,	0x8330,
	0x7bc7,	0x6a4e,	0x58d5,	0x495c,	0x3de3,	0x2c6a,	0x1ef1,	0x0f78
};

struct pkt {
    int	cnt;
    int	esc;
    int	flags;
    struct compressor *comp;
    void *state;
    unsigned char buf[8192];
} spkt, rpkt;

/* Values for flags */
#define CCP_ISUP	1
#define CCP_ERROR	2
#define CCP_FATALERROR	4
#define CCP_ERR		(CCP_ERROR | CCP_FATALERROR)
#define CCP_DECOMP_RUN	8

unsigned char dbuf[8192];

dumpppp(f)
    FILE *f;
{
    int c, n, k;
    int nb, nl, dn, proto, rv;
    char *dir, *q;
    unsigned char *p, *r, *endp;
    unsigned char *d;
    unsigned short fcs;
    struct pkt *pkt;

    spkt.cnt = rpkt.cnt = 0;
    spkt.esc = rpkt.esc = 0;
    while ((c = getc(f)) != EOF) {
	switch (c) {
	case 1:
	case 2:
	    if (reverse)
		c = 3 - c;
	    dir = c==1? "sent": "rcvd";
	    pkt = c==1? &spkt: &rpkt;
	    n = getc(f);
	    n = (n << 8) + getc(f);
	    *(c==1? &tot_sent: &tot_rcvd) += n;
	    for (; n > 0; --n) {
		c = getc(f);
		switch (c) {
		case EOF:
		    printf("\nEOF\n");
		    if (spkt.cnt > 0)
			printf("[%d bytes in incomplete send packet]\n",
			       spkt.cnt);
		    if (rpkt.cnt > 0)
			printf("[%d bytes in incomplete recv packet]\n",
			       rpkt.cnt);
		    exit(0);
		case '~':
		    if (pkt->cnt > 0) {
			q = dir;
			if (pkt->esc) {
			    printf("%s aborted packet:\n     ", dir);
			    q = "    ";
			}
			nb = pkt->cnt;
			p = pkt->buf;
			pkt->cnt = 0;
			pkt->esc = 0;
			if (nb <= 2) {
			    printf("%s short packet [%d bytes]:", q, nb);
			    for (k = 0; k < nb; ++k)
				printf(" %.2x", p[k]);
			    printf("\n");
			    break;
			}
			fcs = PPP_INITFCS;
			for (k = 0; k < nb; ++k)
			    fcs = PPP_FCS(fcs, p[k]);
			fcs &= 0xFFFF;
			nb -= 2;
			endp = p + nb;
			r = p;
			if (r[0] == 0xff && r[1] == 3)
			    r += 2;
			if ((r[0] & 1) == 0)
			    ++r;
			++r;
			if (endp - r > mru)
			    printf("     ERROR: length (%d) > MRU (%d)\n",
				   endp - r, mru);
			if (decompress && fcs == PPP_GOODFCS) {
			    /* See if this is a CCP or compressed packet */
			    d = dbuf;
			    r = p;
			    if (r[0] == 0xff && r[1] == 3) {
				*d++ = *r++;
				*d++ = *r++;
			    }
			    proto = r[0];
			    if ((proto & 1) == 0)
				proto = (proto << 8) + r[1];
			    if (proto == PPP_CCP) {
				handle_ccp(pkt, r + 2, endp - r - 2);
			    } else if (proto == PPP_COMP) {
				if ((pkt->flags & CCP_ISUP)
				    && (pkt->flags & CCP_DECOMP_RUN)
				    && pkt->state
				    && (pkt->flags & CCP_ERR) == 0) {
				    rv = pkt->comp->decompress(pkt->state, r,
							endp - r, d, &dn);
				    switch (rv) {
				    case DECOMP_OK:
					p = dbuf;
					nb = d + dn - p;
					if ((d[0] & 1) == 0)
					    --dn;
					--dn;
					if (dn > mru)
					    printf("     ERROR: decompressed length (%d) > MRU (%d)\n", dn, mru);
					break;
				    case DECOMP_ERROR:
					printf("     DECOMPRESSION ERROR\n");
					pkt->flags |= CCP_ERROR;
					break;
				    case DECOMP_FATALERROR:
					printf("     FATAL DECOMPRESSION ERROR\n");
					pkt->flags |= CCP_FATALERROR;
					break;
				    }
				}
			    } else if (pkt->state
				       && (pkt->flags & CCP_DECOMP_RUN)) {
				pkt->comp->incomp(pkt->state, r, endp - r);
			    }
			}
			do {
			    nl = nb < 16? nb: 16;
			    printf("%s ", q);
			    for (k = 0; k < nl; ++k)
				printf(" %.2x", p[k]);
			    for (; k < 16; ++k)
				printf("   ");
			    printf("  ");
			    for (k = 0; k < nl; ++k) {
				c = p[k];
				putchar((' ' <= c && c <= '~')? c: '.');
			    }
			    printf("\n");
			    q = "    ";
			    p += nl;
			    nb -= nl;
			} while (nb > 0);
			if (fcs != PPP_GOODFCS)
			    printf("     BAD FCS: (residue = %x)\n", fcs);
		    }
		    break;
		case '}':
		    if (!pkt->esc) {
			pkt->esc = 1;
			break;
		    }
		    /* else fall through */
		default:
		    if (pkt->esc) {
			c ^= 0x20;
			pkt->esc = 0;
		    }
		    pkt->buf[pkt->cnt++] = c;
		    break;
		}
	    }
	    break;
	case 3:
	case 4:
	    if (reverse)
		c = 7 - c;
	    dir = c==3? "send": "recv";
	    pkt = c==3? &spkt: &rpkt;
	    printf("end %s", dir);
	    if (pkt->cnt > 0)
		printf("  [%d bytes in incomplete packet]", pkt->cnt);
	    printf("\n");
	    break;
	case 5:
	case 6:
	case 7:
	    show_time(f, c);
	    break;
	default:
	    printf("?%.2x\n");
	}
    }
}

extern struct compressor ppp_bsd_compress, ppp_deflate;

struct compressor *compressors[] = {
#if DO_BSD_COMPRESS
    &ppp_bsd_compress,
#endif
#if DO_DEFLATE
    &ppp_deflate,
#endif
    NULL
};

handle_ccp(cp, dp, len)
    struct pkt *cp;
    u_char *dp;
    int len;
{
    int clen;
    struct compressor **comp;

    if (len < CCP_HDRLEN)
	return;
    clen = CCP_LENGTH(dp);
    if (clen > len)
	return;

    switch (CCP_CODE(dp)) {
    case CCP_CONFACK:
	cp->flags &= ~(CCP_DECOMP_RUN | CCP_ISUP);
	if (clen < CCP_HDRLEN + CCP_OPT_MINLEN
	    || clen < CCP_HDRLEN + CCP_OPT_LENGTH(dp + CCP_HDRLEN))
	    break;
	dp += CCP_HDRLEN;
	clen -= CCP_HDRLEN;
	for (comp = compressors; *comp != NULL; ++comp) {
	    if ((*comp)->compress_proto == dp[0]) {
		if (cp->state != NULL) {
		    (*cp->comp->decomp_free)(cp->state);
		    cp->state = NULL;
		}
		cp->comp = *comp;
		cp->state = (*comp)->decomp_alloc(dp, CCP_OPT_LENGTH(dp));
		cp->flags |= CCP_ISUP;
		if (cp->state != NULL
		    && (*cp->comp->decomp_init)
		        (cp->state, dp, clen, 0, 0, 8192, 1))
		    cp->flags = (cp->flags & ~CCP_ERR) | CCP_DECOMP_RUN;
		break;
	    }
	}
	break;

    case CCP_CONFNAK:
    case CCP_CONFREJ:
	cp->flags &= ~(CCP_DECOMP_RUN | CCP_ISUP);
	break;

    case CCP_RESETACK:
	if (cp->flags & CCP_ISUP) {
	    if (cp->state && (cp->flags & CCP_DECOMP_RUN)) {
		(*cp->comp->decomp_reset)(cp->state);
		cp->flags &= ~CCP_ERROR;
	    }
	}
	break;
    }
}

show_time(f, c)
    FILE *f;
    int c;
{
    time_t t;
    int n;
    struct tm *tm;

    if (c == 7) {
	t = getc(f);
	t = (t << 8) + getc(f);
	t = (t << 8) + getc(f);
	t = (t << 8) + getc(f);
	printf("start %s", ctime(&t));
	start_time = t;
	start_time_tenths = 0;
	tot_sent = tot_rcvd = 0;
    } else {
	n = getc(f);
	if (c == 5) {
	    for (c = 3; c > 0; --c)
		n = (n << 8) + getc(f);
	}
	if (abs_times) {
	    n += start_time_tenths;
	    start_time += n / 10;
	    start_time_tenths = n % 10;
	    tm = localtime(&start_time);
	    printf("time  %.2d:%.2d:%.2d.%d", tm->tm_hour, tm->tm_min,
		   tm->tm_sec, start_time_tenths);
	    printf("  (sent %d, rcvd %d)\n", tot_sent, tot_rcvd);
	} else
	    printf("time  %.1fs\n", (double) n / 10);
    }
}
.\"	@(#) $Id: pppdump.8,v 1.1 1999/04/01 11:44:55 paulus Exp $
.TH PPPDUMP 8 "1 April 1999"
.SH NAME
pppdump \- convert PPP record file to readable format
.SH SYNOPSIS
.B pppdump
[
.B -h
|
.B -p
[
.B -d
]] [
.B -r
] [
.B -m \fImru
] [
.I file \fR...
]
.ti 12
.SH DESCRIPTION
The
.B pppdump
utility converts the files written using the \fIrecord\fR option of
.B pppd
into a human-readable format.  If one or more filenames are specified,
.B pppdump
will read each in turn; otherwise it will read its standard input.  In
each case the result is written to standard output.
.PP
The options are as follows:
.TP
.B -h
Prints the bytes sent and received in hexadecimal.  If neither this
option nor the \fB-p\fR option is specified, the bytes are printed as
the characters themselves, with non-printing and non-ASCII characters
printed as escape sequences.
.TP
.B -p
Collects the bytes sent and received into PPP packets, interpreting
the async HDLC framing and escape characters and checking the FCS
(frame check sequence) of each packet.  The packets are printed as hex
values and as characters (non-printable characters are printed as
`.').
.TP
.B -d
With the \fB-p\fR option, this option causes
.B pppdump
to decompress packets which have been compressed with the BSD-Compress
or Deflate methods.
.TP
.B -r
Reverses the direction indicators, so that `sent' is printed for
bytes or packets received, and `rcvd' is printed for bytes or packets
sent.
.TP
.B -m \fImru
Use \fImru\fR as the MRU (maximum receive unit) for both directions of
the link when checking for over-length PPP packets (with the \fB-p\fR
option).
.SH SEE ALSO
pppd(8)