OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [lwip_tcpip/] [current/] [src/] [netif/] [ppp/] [record.c] - Blame information for rev 865

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
/*****************************************************************************
2
* record.c - PPP recording program file.
3
*
4
* Copyright (c) 2009 by Simon Kallweit, intefo AG
5
*
6
* The authors hereby grant permission to use, copy, modify, distribute,
7
* and license this software and its documentation for any purpose, provided
8
* that existing copyright notices are retained in all copies and that this
9
* notice and the following disclaimer are included verbatim in any
10
* distributions. No written agreement, license, or royalty fee is required
11
* for any of the authorized uses.
12
*
13
* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
14
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16
* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
17
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
*
24
******************************************************************************
25
* REVISION HISTORY
26
*
27
* 09-02-03 Simon Kallweit <simon.kallweit@intefo.ch>
28
*   First implementation.
29
*****************************************************************************/
30
 
31
#include "lwip/opt.h"
32
 
33
#if PPP_SUPPORT
34
 
35
#if RECORD_SUPPORT
36
 
37
#include "netif/ppp/ppp.h"
38
#include "record.h"
39
 
40
/***********************************/
41
/*** PUBLIC FUNCTION DEFINITIONS ***/
42
/***********************************/
43
 
44
static u32_t now;
45
static u8_t buf[1024];
46
 
47
extern void ppp_dump_record(void *data, int len);
48
 
49
/*
50
 * write_record - Writes a single record.
51
 */
52
static void write_record(u8_t code, u8_t *data, int len)
53
{
54
    static u32_t last;
55
    u32_t diff;
56
    u8_t *b = buf;
57
 
58
    diff = now - last;
59
    if (diff > 0) {
60
        if (diff > 255) {
61
            /* Absolute timestamp */
62
            *b++ = 0x05;
63
            *b++ = (diff >> 24);
64
            *b++ = (diff >> 16);
65
            *b++ = (diff >> 8);
66
            *b++ = diff;
67
        } else {
68
            /* Relative timestamp */
69
            *b++ = 0x06;
70
            *b++ = diff;
71
        }
72
        last = now;
73
    }
74
 
75
    *b++ = code;
76
    *b++ = (len >> 8);
77
    *b++ = len;
78
    while (len-- && b < (buf + sizeof(buf)))
79
        *b++ = *data++;
80
 
81
    ppp_dump_record(buf, b - buf);
82
}
83
 
84
/*
85
 * record_init - Initialize the recording module.
86
 */
87
void record_init()
88
{
89
    u8_t *b = buf;
90
 
91
    /* Write start marker */
92
    *b++ = 0x07;
93
    *b++ = 0;
94
    *b++ = 0;
95
    *b++ = 0;
96
    *b++ = 0;
97
    ppp_dump_record(buf, b - buf);
98
}
99
 
100
/*
101
 * record_update - Updates the current time.
102
 */
103
void record_update(int ms)
104
{
105
    /* Recording timer resolution is 0.1 s */
106
    now += ms / 10;
107
}
108
 
109
/*
110
 * record_in - Dumps incoming data.
111
 */
112
void record_in(void *data, int len)
113
{
114
    write_record(2, data, len);
115
}
116
 
117
/*
118
 * record_out - Dumps outgoing data.
119
 */
120
void record_out(void *data, int len)
121
{
122
    write_record(1, data, len);
123
}
124
 
125
#endif /* RECORD_SUPPORT */
126
 
127
#endif /* PPP_SUPPORT */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.