1/*
2 * Copyright (C) 2012, Broadcom Corporation
3 * All Rights Reserved.
4 *
5 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
6 * the contents of this file may not be disclosed to third parties, copied
7 * or duplicated in any form, in whole or in part, without the prior
8 * written permission of Broadcom Corporation.
9 *
10 * Fundamental constants, macros and structures relating to L2TP Protocol
11 *
12 * $Id: bcml2tp.h, Exp $
13 */
14
15#ifndef _bcml2tp_h_
16#define _bcml2tp_h_
17
18#ifndef _TYPEDEFS_H_
19#include <typedefs.h>
20#endif
21
22#define PPP_PROTO(data)	(((data)[0] << 8) + (data)[1])
23
24/* This marks the start of a packed structure section. */
25#ifndef _bcmip_h_
26#include <packed_section_start.h>
27#endif
28
29#define BCML2TP_PORT  1701
30#define BCML2TP_CTBIT(ver) ((ver) & 0x8000)       /* Determines if control or not */
31#define L2TP_CLBIT(ver) ((ver) & 0x4000)       /* Length bit present.  Must be 1
32                                           for control messages */
33
34
35#define BCML2TP_CZBITS(ver) ((ver) &0x37F8)       /* Reserved bits:  We must drop
36                                           anything with these there */
37
38#define BCML2TP_CFBIT(ver) ((ver) & 0x0800)       /* Presence of Ns and Nr fields
39                                           flow bit? */
40
41#define BCML2TP_OFBIT(ver) ((ver) & 0x0200)       /* Presence of Offset size fields */
42
43#define BCML2TP_CVER(ver) ((ver) & 0x0007)        /* Version of encapsulation */
44
45#define BCML2TP_PSBIT(ver) (ver & 0x0200)       /* Offset size bit */
46
47#define BCML2TP_PLBIT(ver) L2TP_CLBIT(ver)   /* Length specified? */
48
49#define BCML2TP_PFBIT(ver) BCML2TP_CFBIT(ver)   /* Flow control specified? */
50
51
52
53
54/* L2TP control header */
55/* These fields are stored in network order */
56BWL_PRE_PACKED_STRUCT struct bcml2tp_control_hdr
57{
58    uint16 ver;                   /* Version and more */
59    uint16 length;                /* Length field */
60    uint16 tid;                   /* Tunnel ID */
61    uint16 cid;                   /* Call ID */
62    uint16 Ns;                    /* Next sent */
63    uint16 Nr;                    /* Next received */
64} BWL_POST_PACKED_STRUCT;
65
66BWL_PRE_PACKED_STRUCT struct bcml2tp_payload_hdr
67{
68    uint16 ver;                   /* Version and friends */
69    uint16 length;                /* Optional Length */
70    uint16 tid;                   /* Tunnel ID */
71    uint16 cid;                   /* Caller ID */
72    uint16 Ns;                    /* Optional next sent */
73    uint16 Nr;                    /* Optional next received */
74    uint16 o_size;                /* Optional offset size */
75    uint16 o_pad;                 /* Optional offset padding */
76} BWL_POST_PACKED_STRUCT;
77
78
79/* This marks the end of a packed structure section. */
80#include <packed_section_end.h>
81
82#endif	/* _bcml2tp_h_ */
83