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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [ppp/] [current/] [include/] [fsm.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      include/fsm.h
4
//
5
//==========================================================================
6
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
7
// -------------------------------------------                              
8
// This file is part of eCos, the Embedded Configurable Operating System.   
9
// Copyright (C) 2003 Free Software Foundation, Inc.                        
10
//
11
// eCos is free software; you can redistribute it and/or modify it under    
12
// the terms of the GNU General Public License as published by the Free     
13
// Software Foundation; either version 2 or (at your option) any later      
14
// version.                                                                 
15
//
16
// eCos is distributed in the hope that it will be useful, but WITHOUT      
17
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
18
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
19
// for more details.                                                        
20
//
21
// You should have received a copy of the GNU General Public License        
22
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
23
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
24
//
25
// As a special exception, if other files instantiate templates or use      
26
// macros or inline functions from this file, or you compile this file      
27
// and link it with other works to produce a work based on this file,       
28
// this file does not by itself cause the resulting work to be covered by   
29
// the GNU General Public License. However the source code for this file    
30
// must still be made available in accordance with section (3) of the GNU   
31
// General Public License v2.                                               
32
//
33
// This exception does not invalidate any other reasons why a work based    
34
// on this file might be covered by the GNU General Public License.         
35
// -------------------------------------------                              
36
// ####ECOSGPLCOPYRIGHTEND####                                              
37
// ####BSDALTCOPYRIGHTBEGIN####                                             
38
// -------------------------------------------                              
39
// Portions of this software may have been derived from FreeBSD, OpenBSD,   
40
// or other sources, and if so are covered by the appropriate copyright     
41
// and license included herein.                                             
42
// -------------------------------------------                              
43
// ####BSDALTCOPYRIGHTEND####                                               
44
//==========================================================================
45
 
46
/*
47
 * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
48
 *
49
 * Copyright (c) 1989 Carnegie Mellon University.
50
 * All rights reserved.
51
 *
52
 * Redistribution and use in source and binary forms are permitted
53
 * provided that the above copyright notice and this paragraph are
54
 * duplicated in all such forms and that any documentation,
55
 * advertising materials, and other materials related to such
56
 * distribution and use acknowledge that the software was developed
57
 * by Carnegie Mellon University.  The name of the
58
 * University may not be used to endorse or promote products derived
59
 * from this software without specific prior written permission.
60
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
61
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
62
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63
 *
64
 * $FreeBSD: src/usr.sbin/pppd/fsm.h,v 1.7 1999/08/28 01:19:03 peter Exp $
65
 */
66
 
67
/*
68
 * Packet header = Code, id, length.
69
 */
70
#define HEADERLEN       (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
71
 
72
 
73
/*
74
 *  CP (LCP, IPCP, etc.) codes.
75
 */
76
#define CONFREQ         1       /* Configuration Request */
77
#define CONFACK         2       /* Configuration Ack */
78
#define CONFNAK         3       /* Configuration Nak */
79
#define CONFREJ         4       /* Configuration Reject */
80
#define TERMREQ         5       /* Termination Request */
81
#define TERMACK         6       /* Termination Ack */
82
#define CODEREJ         7       /* Code Reject */
83
 
84
 
85
/*
86
 * Each FSM is described by an fsm structure and fsm callbacks.
87
 */
88
typedef struct fsm {
89
    int unit;                   /* Interface unit number */
90
    int protocol;               /* Data Link Layer Protocol field value */
91
    int state;                  /* State */
92
    int flags;                  /* Contains option bits */
93
    u_char id;                  /* Current id */
94
    u_char reqid;               /* Current request id */
95
    u_char seen_ack;            /* Have received valid Ack/Nak/Rej to Req */
96
    int timeouttime;            /* Timeout time in milliseconds */
97
    int maxconfreqtransmits;    /* Maximum Configure-Request transmissions */
98
    int retransmits;            /* Number of retransmissions left */
99
    int maxtermtransmits;       /* Maximum Terminate-Request transmissions */
100
    int nakloops;               /* Number of nak loops since last ack */
101
    int maxnakloops;            /* Maximum number of nak loops tolerated */
102
    struct fsm_callbacks *callbacks;    /* Callback routines */
103
    char *term_reason;          /* Reason for closing protocol */
104
    int term_reason_len;        /* Length of term_reason */
105
} fsm;
106
 
107
 
108
typedef struct fsm_callbacks {
109
    void (*resetci)             /* Reset our Configuration Information */
110
                __P((fsm *));
111
    int  (*cilen)               /* Length of our Configuration Information */
112
                __P((fsm *));
113
    void (*addci)               /* Add our Configuration Information */
114
                __P((fsm *, u_char *, int *));
115
    int  (*ackci)               /* ACK our Configuration Information */
116
                __P((fsm *, u_char *, int));
117
    int  (*nakci)               /* NAK our Configuration Information */
118
                __P((fsm *, u_char *, int));
119
    int  (*rejci)               /* Reject our Configuration Information */
120
                __P((fsm *, u_char *, int));
121
    int  (*reqci)               /* Request peer's Configuration Information */
122
                __P((fsm *, u_char *, int *, int));
123
    void (*up)                  /* Called when fsm reaches OPENED state */
124
                __P((fsm *));
125
    void (*down)                /* Called when fsm leaves OPENED state */
126
                __P((fsm *));
127
    void (*starting)            /* Called when we want the lower layer */
128
                __P((fsm *));
129
    void (*finished)            /* Called when we don't want the lower layer */
130
                __P((fsm *));
131
    void (*protreject)          /* Called when Protocol-Reject received */
132
                __P((int));
133
    void (*retransmit)          /* Retransmission is necessary */
134
                __P((fsm *));
135
    int  (*extcode)             /* Called when unknown code received */
136
                __P((fsm *, int, int, u_char *, int));
137
    char *proto_name;           /* String name for protocol (for messages) */
138
} fsm_callbacks;
139
 
140
 
141
/*
142
 * Link states.
143
 */
144
#define INITIAL         0        /* Down, hasn't been opened */
145
#define STARTING        1       /* Down, been opened */
146
#define CLOSED          2       /* Up, hasn't been opened */
147
#define STOPPED         3       /* Open, waiting for down event */
148
#define CLOSING         4       /* Terminating the connection, not open */
149
#define STOPPING        5       /* Terminating, but open */
150
#define REQSENT         6       /* We've sent a Config Request */
151
#define ACKRCVD         7       /* We've received a Config Ack */
152
#define ACKSENT         8       /* We've sent a Config Ack */
153
#define OPENED          9       /* Connection available */
154
 
155
 
156
/*
157
 * Flags - indicate options controlling FSM operation
158
 */
159
#define OPT_PASSIVE     1       /* Don't die if we don't get a response */
160
#define OPT_RESTART     2       /* Treat 2nd OPEN as DOWN, UP */
161
#define OPT_SILENT      4       /* Wait for peer to speak first */
162
 
163
 
164
/*
165
 * Timeouts.
166
 */
167
#define DEFTIMEOUT      3       /* Timeout time in seconds */
168
#define DEFMAXTERMREQS  2       /* Maximum Terminate-Request transmissions */
169
#define DEFMAXCONFREQS  10      /* Maximum Configure-Request transmissions */
170
#define DEFMAXNAKLOOPS  5       /* Maximum number of nak loops */
171
 
172
 
173
/*
174
 * Prototypes
175
 */
176
void fsm_init __P((fsm *));
177
void fsm_lowerup __P((fsm *));
178
void fsm_lowerdown __P((fsm *));
179
void fsm_open __P((fsm *));
180
void fsm_close __P((fsm *, char *));
181
void fsm_input __P((fsm *, u_char *, int));
182
void fsm_protreject __P((fsm *));
183
void fsm_sdata __P((fsm *, int, int, u_char *, int));
184
 
185
 
186
/*
187
 * Variables
188
 */
189
extern int peer_mru[];          /* currently negotiated peer MRU (per unit) */

powered by: WebSVN 2.1.0

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