summaryrefslogtreecommitdiffstats
path: root/shared/opensource/include/bcm963xx/wan_det.h
blob: d8a5645901bcc75e66e45b218a398215f48cf271 (plain)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/***************************************************************************
***
***    Copyright 2008  Hon Hai Precision Ind. Co. Ltd.
***    All Rights Reserved.
***    No portions of this material shall be reproduced in any form without the
***    written permission of Hon Hai Precision Ind. Co. Ltd.
***
***    All information contained in this document is Hon Hai Precision Ind.  
***    Co. Ltd. company private, proprietary, and trade secret property and 
***    are protected by international intellectual property laws and treaties.
***
****************************************************************************/

#ifndef __WAN_DET_H__
#define __WAN_DET_H__

/* Foxconn added start Bob, 01/22/2010 */

#define MAX_SCAN_SERVICE    8

typedef struct _vpivcitable
{
    int portId;
	int vpi;
	int vci;
}_VpiVciTable;


typedef struct scanResult
{
    _VpiVciTable service[MAX_SCAN_SERVICE];
    _VpiVciTable oam;
    _VpiVciTable BPDU;
}SCAN_RESULT;
/* Foxconn added end Bob, 01/22/2010 */

typedef unsigned short  U16;
typedef unsigned int    U32;
typedef unsigned char   U8;

#define PATTERN_ROUTED      0
#define PATTERN_BRIDGED     1

#define ETHER_TYPE_OFFSET               12
#define ETHERTYPE_IP              		0x0800
#define ETHERTYPE_ARP             		0x0806
#define ETHERTYPE_PPPOE_DISCOVERY 		0x8863
#define ETHERHEADER_LEN                 14

typedef struct _PacketContent
{
    U32 length;
    U8 *data;
}PacketContent;

typedef struct _Pattern
{
    const char *name;
    const  PacketContent *payload;
    int protoType;
    U16 ethertype;
    const PacketContent *header;
    const PacketContent *expected_payload;
    
}Pattern;


static U8 dhcp_request_bytes[] = {

  // IP header
  0x45, 0x00, 0x01, 0x48, // version, IHL, TOS, Total Length
  0x00, 0x04, 0x00, 0x00, // ident, flags, frag off
  0x9b, 0x11, 0x1e, 0xa2, // TTL, proto, hdr checksum
  0x00, 0x00, 0x00, 0x00, // source addr
  0xff, 0xff, 0xff, 0xff, // destination addr

  // UDP header
  0x00, 0x44, 0x00, 0x43, 0x01, 0x34, 0xe6, 0x9a, 0x01, 0x01, 0x06, 0x00,
  0xb3, 0x05, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x2b, 0x00, 0x74, 0xb1, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x35, 0x01, 0x01, 0x33,
  0x04, 0x00, 0x00, 0x1c, 0x20, 0x37, 0x07, 0x01, 0x1c, 0x02, 0x03, 0x0f, 0x06, 0x0c, 0xff, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

};

static PacketContent dhcp_request = { sizeof(dhcp_request_bytes), dhcp_request_bytes 
};
    
static U8 pppoe_padi_bytes[] = {
  0x11, 0x09, 0x00, 0x00, 0x00, 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static PacketContent pppoe_padi = { sizeof(pppoe_padi_bytes), pppoe_padi_bytes };

/** Sequence of bytes for a PPP LCP Configure-Request (RFC1661). */
static U8 ppp_lcp_confreq_bytes[] = {
    0xc0, 0x21, // LCP
    0x01,       // Configure Request
    0x99,       // randomish identifier
    0x00, 0x04, // length 
};
static PacketContent ppp_lcp_confreq = { sizeof(ppp_lcp_confreq_bytes), ppp_lcp_confreq_bytes };

/** Expected response from NULL (aka VcMux) encapsulated PPP/LCP */
static U8 ppp_lcp_response_bytes[] = { 0xc0, 0x21 };
static PacketContent ppp_lcp_response = { sizeof(ppp_lcp_response_bytes), ppp_lcp_response_bytes };

/** SNAP/LLC routed */
static U8 snap_llc_routed_bytes[] = { 0xaa, 0xaa, 3, 0, 0, 0, 8, 0 };
static PacketContent snap_llc_routed = { sizeof(snap_llc_routed_bytes), snap_llc_routed_bytes };

/** SNAP/LLC bridged, no fcs */
static U8 snap_llc_bridged_bytes[] = {
    0xaa, 0xaa, 0x3,       // LLC 
    0x0,  0x80, 0xc2,      // OUI
    0x00, 0x07,            // PID
    0x00, 0x00             // PAD
 };
static PacketContent snap_llc_bridged = { sizeof(snap_llc_bridged_bytes), snap_llc_bridged_bytes };

/* foxconn added start Bob, 12/07/2009, ignore BPDU frame */
/** SNAP/LLC bridged BPDU */
static U8 snap_llc_bridged_BPDU_bytes[] = {
    0xaa, 0xaa, 0x3,       // LLC 
    0x0,  0x80, 0xc2,      // OUI
    0x00, 0x0e,            // PID
 };
 /* foxconn added end Bob, 12/07/2009, ignore BPDU frame */

/** LLC for PPPoA. See RFC2364 section 6. */
static U8 llc_pppoa_bytes[] = { 0xfe, 0xfe, 0x03, 0xcf };
static PacketContent llc_pppoa = {
    sizeof(llc_pppoa_bytes), llc_pppoa_bytes
};

static U8 vcmux_bridged_bytes[] = { 0, 0 };
static PacketContent vcmux_bridged = { sizeof(vcmux_bridged_bytes), vcmux_bridged_bytes };

/**
Patterns to be sent to CO side
1. PPPoE LLC Bridged
2. VcMux encapsulated PPPoA
3. LLC encapsulated PPPoA
4. RFC1483 SNAP/LLC Routed
5. RFC1483 VcMux Bridged
6. PPPoE VCMux Bridged
7. RFC1483 SNAP/LLC Bridged
8. RFC1483 VcMux Routed
*/
static Pattern patterns[] = 
{
    { 
        "PPPoE LLC Bridged",
        &pppoe_padi,
        PATTERN_BRIDGED,
        ETHERTYPE_PPPOE_DISCOVERY, 
        &snap_llc_bridged, 
        NULL
    },
    { 
        "VcMux encapsulated PPPoA",
        &ppp_lcp_confreq,
        PATTERN_ROUTED, 
        0, // no need for etherheader!
        NULL,
        &ppp_lcp_response
    },

    { 
        "LLC encapsulated PPPoA",
        &ppp_lcp_confreq,
        PATTERN_ROUTED, 
        0, // no need for etherheader!
        &llc_pppoa,  // encapsulated with PPPoA LLC header
        NULL
    },

    /* RFC1483 SNAP/LLC routed */
    { 
        "RFC1483 SNAP/LLC Routed",
        &dhcp_request,
        PATTERN_ROUTED, 
        0, 
        &snap_llc_routed, 
        NULL
    },

    /* RFC1483 VC mux bridged */
    { 
        "RFC1483 VcMux Bridged",
        &dhcp_request,
        PATTERN_BRIDGED, 
        ETHERTYPE_IP,
        &vcmux_bridged, 
        NULL
    },

    /* PPPOE VCMux Bridged*/
    {
        "PPPoE VCMux Bridged",
        &pppoe_padi,
        PATTERN_BRIDGED,
        ETHERTYPE_PPPOE_DISCOVERY,
        &vcmux_bridged,
        NULL
    },

    /* RFC1483 SNAP/LLC bridged */
    { 
        "RFC1483 SNAP/LLC Bridged",
        &dhcp_request,
        PATTERN_BRIDGED, 
        ETHERTYPE_IP, 
        &snap_llc_bridged, 
        NULL      
    },

    /* RFC1483 VC mux routed */
    { 
        "RFC1483 VcMux Routed",
        &dhcp_request,
        PATTERN_ROUTED, 
        0,
        NULL, 
        NULL
    },
};

#endif  /* __WAN_DET_H__ */