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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [ethernet/] [lwIP_130/] [src/] [netif/] [ppp/] [ppp.h] - Blame information for rev 606

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 606 jeremybenn
/*****************************************************************************
2
* ppp.h - Network Point to Point Protocol header file.
3
*
4
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5
* portions Copyright (c) 1997 Global Election Systems Inc.
6
*
7
* The authors hereby grant permission to use, copy, modify, distribute,
8
* and license this software and its documentation for any purpose, provided
9
* that existing copyright notices are retained in all copies and that this
10
* notice and the following disclaimer are included verbatim in any
11
* distributions. No written agreement, license, or royalty fee is required
12
* for any of the authorized uses.
13
*
14
* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
15
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
*
25
******************************************************************************
26
* REVISION HISTORY
27
*
28
* 03-01-01 Marc Boucher <marc@mbsi.ca>
29
*   Ported to lwIP.
30
* 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
31
*   Original derived from BSD codes.
32
*****************************************************************************/
33
 
34
#ifndef PPP_H
35
#define PPP_H
36
 
37
#include "lwip/opt.h"
38
 
39
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
40
 
41
#include "lwip/def.h"
42
#include "lwip/sio.h"
43
#include "lwip/api.h"
44
#include "lwip/sockets.h"
45
#include "lwip/stats.h"
46
#include "lwip/mem.h"
47
#include "lwip/tcpip.h"
48
#include "lwip/netif.h"
49
 
50
/*
51
 * pppd.h - PPP daemon global declarations.
52
 *
53
 * Copyright (c) 1989 Carnegie Mellon University.
54
 * All rights reserved.
55
 *
56
 * Redistribution and use in source and binary forms are permitted
57
 * provided that the above copyright notice and this paragraph are
58
 * duplicated in all such forms and that any documentation,
59
 * advertising materials, and other materials related to such
60
 * distribution and use acknowledge that the software was developed
61
 * by Carnegie Mellon University.  The name of the
62
 * University may not be used to endorse or promote products derived
63
 * from this software without specific prior written permission.
64
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
65
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
66
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
67
 *
68
 */
69
/*
70
 * ppp_defs.h - PPP definitions.
71
 *
72
 * Copyright (c) 1994 The Australian National University.
73
 * All rights reserved.
74
 *
75
 * Permission to use, copy, modify, and distribute this software and its
76
 * documentation is hereby granted, provided that the above copyright
77
 * notice appears in all copies.  This software is provided without any
78
 * warranty, express or implied. The Australian National University
79
 * makes no representations about the suitability of this software for
80
 * any purpose.
81
 *
82
 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
83
 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
84
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
85
 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
86
 * OF SUCH DAMAGE.
87
 *
88
 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
89
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
90
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
91
 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
92
 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
93
 * OR MODIFICATIONS.
94
 */
95
 
96
#define TIMEOUT(f, a, t)    sys_untimeout((f), (a)), sys_timeout((t)*1000, (f), (a))
97
#define UNTIMEOUT(f, a)     sys_untimeout((f), (a))
98
 
99
 
100
#ifndef __u_char_defined
101
 
102
/* Type definitions for BSD code. */
103
typedef unsigned long  u_long;
104
typedef unsigned int   u_int;
105
typedef unsigned short u_short;
106
typedef unsigned char  u_char;
107
 
108
#endif
109
 
110
/*
111
 * Constants and structures defined by the internet system,
112
 * Per RFC 790, September 1981, and numerous additions.
113
 */
114
 
115
/*
116
 * The basic PPP frame.
117
 */
118
#define PPP_HDRLEN      4       /* octets for standard ppp header */
119
#define PPP_FCSLEN      2       /* octets for FCS */
120
 
121
 
122
/*
123
 * Significant octet values.
124
 */
125
#define PPP_ALLSTATIONS 0xff    /* All-Stations broadcast address */
126
#define PPP_UI          0x03    /* Unnumbered Information */
127
#define PPP_FLAG        0x7e    /* Flag Sequence */
128
#define PPP_ESCAPE      0x7d    /* Asynchronous Control Escape */
129
#define PPP_TRANS       0x20    /* Asynchronous transparency modifier */
130
 
131
/*
132
 * Protocol field values.
133
 */
134
#define PPP_IP          0x21    /* Internet Protocol */
135
#define PPP_AT          0x29    /* AppleTalk Protocol */
136
#define PPP_VJC_COMP    0x2d    /* VJ compressed TCP */
137
#define PPP_VJC_UNCOMP  0x2f    /* VJ uncompressed TCP */
138
#define PPP_COMP        0xfd    /* compressed packet */
139
#define PPP_IPCP        0x8021  /* IP Control Protocol */
140
#define PPP_ATCP        0x8029  /* AppleTalk Control Protocol */
141
#define PPP_CCP         0x80fd  /* Compression Control Protocol */
142
#define PPP_LCP         0xc021  /* Link Control Protocol */
143
#define PPP_PAP         0xc023  /* Password Authentication Protocol */
144
#define PPP_LQR         0xc025  /* Link Quality Report protocol */
145
#define PPP_CHAP        0xc223  /* Cryptographic Handshake Auth. Protocol */
146
#define PPP_CBCP        0xc029  /* Callback Control Protocol */
147
 
148
/*
149
 * Values for FCS calculations.
150
 */
151
#define PPP_INITFCS     0xffff  /* Initial FCS value */
152
#define PPP_GOODFCS     0xf0b8  /* Good final FCS value */
153
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
154
 
155
/*
156
 * Extended asyncmap - allows any character to be escaped.
157
 */
158
typedef u_char  ext_accm[32];
159
 
160
/*
161
 * What to do with network protocol (NP) packets.
162
 */
163
enum NPmode {
164
  NPMODE_PASS,        /* pass the packet through */
165
  NPMODE_DROP,        /* silently drop the packet */
166
  NPMODE_ERROR,       /* return an error */
167
  NPMODE_QUEUE        /* save it up for later. */
168
};
169
 
170
/*
171
 * Inline versions of get/put char/short/long.
172
 * Pointer is advanced; we assume that both arguments
173
 * are lvalues and will already be in registers.
174
 * cp MUST be u_char *.
175
 */
176
#define GETCHAR(c, cp) { \
177
    (c) = *(cp)++; \
178
}
179
#define PUTCHAR(c, cp) { \
180
    *(cp)++ = (u_char) (c); \
181
}
182
 
183
 
184
#define GETSHORT(s, cp) { \
185
    (s) = *(cp); (cp)++; (s) <<= 8; \
186
    (s) |= *(cp); (cp)++; \
187
}
188
#define PUTSHORT(s, cp) { \
189
    *(cp)++ = (u_char) ((s) >> 8); \
190
    *(cp)++ = (u_char) (s & 0xff); \
191
}
192
 
193
#define GETLONG(l, cp) { \
194
    (l) = *(cp); (cp)++; (l) <<= 8; \
195
    (l) |= *(cp); (cp)++; (l) <<= 8; \
196
    (l) |= *(cp); (cp)++; (l) <<= 8; \
197
    (l) |= *(cp); (cp)++; \
198
}
199
#define PUTLONG(l, cp) { \
200
    *(cp)++ = (u_char) ((l) >> 24); \
201
    *(cp)++ = (u_char) ((l) >> 16); \
202
    *(cp)++ = (u_char) ((l) >> 8); \
203
    *(cp)++ = (u_char) (l); \
204
}
205
 
206
 
207
#define INCPTR(n, cp)   ((cp) += (n))
208
#define DECPTR(n, cp)   ((cp) -= (n))
209
 
210
#define BCMP(s0, s1, l)     memcmp((u_char *)(s0), (u_char *)(s1), (l))
211
#define BCOPY(s, d, l)      MEMCPY((d), (s), (l))
212
#define BZERO(s, n)         memset(s, 0, n)
213
 
214
#if PPP_DEBUG
215
#define PRINTMSG(m, l)  { m[l] = '\0'; ppp_trace(LOG_INFO, "Remote message: %s\n", m); }
216
#else  /* PPP_DEBUG */
217
#define PRINTMSG(m, l)
218
#endif /* PPP_DEBUG */
219
 
220
/*
221
 * MAKEHEADER - Add PPP Header fields to a packet.
222
 */
223
#define MAKEHEADER(p, t) { \
224
    PUTCHAR(PPP_ALLSTATIONS, p); \
225
    PUTCHAR(PPP_UI, p); \
226
    PUTSHORT(t, p); }
227
 
228
/*************************
229
*** PUBLIC DEFINITIONS ***
230
*************************/
231
 
232
/* Error codes. */
233
#define PPPERR_NONE      0 /* No error. */
234
#define PPPERR_PARAM    -1 /* Invalid parameter. */
235
#define PPPERR_OPEN     -2 /* Unable to open PPP session. */
236
#define PPPERR_DEVICE   -3 /* Invalid I/O device for PPP. */
237
#define PPPERR_ALLOC    -4 /* Unable to allocate resources. */
238
#define PPPERR_USER     -5 /* User interrupt. */
239
#define PPPERR_CONNECT  -6 /* Connection lost. */
240
#define PPPERR_AUTHFAIL -7 /* Failed authentication challenge. */
241
#define PPPERR_PROTOCOL -8 /* Failed to meet protocol. */
242
 
243
/*
244
 * PPP IOCTL commands.
245
 */
246
/*
247
 * Get the up status - 0 for down, non-zero for up.  The argument must
248
 * point to an int.
249
 */
250
#define PPPCTLG_UPSTATUS 100 /* Get the up status - 0 down else up */
251
#define PPPCTLS_ERRCODE  101 /* Set the error code */
252
#define PPPCTLG_ERRCODE  102 /* Get the error code */
253
#define PPPCTLG_FD       103 /* Get the fd associated with the ppp */
254
 
255
/************************
256
*** PUBLIC DATA TYPES ***
257
************************/
258
 
259
/*
260
 * The following struct gives the addresses of procedures to call
261
 * for a particular protocol.
262
 */
263
struct protent {
264
    u_short protocol;       /* PPP protocol number */
265
    /* Initialization procedure */
266
    void (*init) (int unit);
267
    /* Process a received packet */
268
    void (*input) (int unit, u_char *pkt, int len);
269
    /* Process a received protocol-reject */
270
    void (*protrej) (int unit);
271
    /* Lower layer has come up */
272
    void (*lowerup) (int unit);
273
    /* Lower layer has gone down */
274
    void (*lowerdown) (int unit);
275
    /* Open the protocol */
276
    void (*open) (int unit);
277
    /* Close the protocol */
278
    void (*close) (int unit, char *reason);
279
#if 0
280
    /* Print a packet in readable form */
281
    int  (*printpkt) (u_char *pkt, int len,
282
              void (*printer) (void *, char *, ...),
283
              void *arg);
284
    /* Process a received data packet */
285
    void (*datainput) (int unit, u_char *pkt, int len);
286
#endif
287
    int  enabled_flag;      /* 0 iff protocol is disabled */
288
    char *name;         /* Text name of protocol */
289
#if 0
290
    /* Check requested options, assign defaults */
291
    void (*check_options) (u_long);
292
    /* Configure interface for demand-dial */
293
    int  (*demand_conf) (int unit);
294
    /* Say whether to bring up link for this pkt */
295
    int  (*active_pkt) (u_char *pkt, int len);
296
#endif
297
};
298
 
299
/*
300
 * The following structure records the time in seconds since
301
 * the last NP packet was sent or received.
302
 */
303
struct ppp_idle {
304
  u_short xmit_idle;      /* seconds since last NP packet sent */
305
  u_short recv_idle;      /* seconds since last NP packet received */
306
};
307
 
308
struct ppp_settings {
309
 
310
  u_int  disable_defaultip : 1;       /* Don't use hostname for default IP addrs */
311
  u_int  auth_required     : 1;       /* Peer is required to authenticate */
312
  u_int  explicit_remote   : 1;       /* remote_name specified with remotename opt */
313
  u_int  refuse_pap        : 1;       /* Don't wanna auth. ourselves with PAP */
314
  u_int  refuse_chap       : 1;       /* Don't wanna auth. ourselves with CHAP */
315
  u_int  usehostname       : 1;       /* Use hostname for our_name */
316
  u_int  usepeerdns        : 1;       /* Ask peer for DNS adds */
317
 
318
  u_short idle_time_limit;            /* Shut down link if idle for this long */
319
  int  maxconnect;                    /* Maximum connect time (seconds) */
320
 
321
  char user       [MAXNAMELEN   + 1]; /* Username for PAP */
322
  char passwd     [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */
323
  char our_name   [MAXNAMELEN   + 1]; /* Our name for authentication purposes */
324
  char remote_name[MAXNAMELEN   + 1]; /* Peer's name for authentication */
325
};
326
 
327
struct ppp_addrs {
328
  struct ip_addr our_ipaddr, his_ipaddr, netmask, dns1, dns2;
329
};
330
 
331
/*****************************
332
*** PUBLIC DATA STRUCTURES ***
333
*****************************/
334
 
335
/* Buffers for outgoing packets. */
336
extern u_char *outpacket_buf[NUM_PPP];
337
 
338
extern struct ppp_settings ppp_settings;
339
 
340
extern struct protent *ppp_protocols[]; /* Table of pointers to supported protocols */
341
 
342
 
343
/***********************
344
*** PUBLIC FUNCTIONS ***
345
***********************/
346
 
347
/* Initialize the PPP subsystem. */
348
err_t pppInit(void);
349
 
350
/* Warning: Using PPPAUTHTYPE_ANY might have security consequences.
351
 * RFC 1994 says:
352
 *
353
 * In practice, within or associated with each PPP server, there is a
354
 * database which associates "user" names with authentication
355
 * information ("secrets").  It is not anticipated that a particular
356
 * named user would be authenticated by multiple methods.  This would
357
 * make the user vulnerable to attacks which negotiate the least secure
358
 * method from among a set (such as PAP rather than CHAP).  If the same
359
 * secret was used, PAP would reveal the secret to be used later with
360
 * CHAP.
361
 *
362
 * Instead, for each user name there should be an indication of exactly
363
 * one method used to authenticate that user name.  If a user needs to
364
 * make use of different authentication methods under different
365
 * circumstances, then distinct user names SHOULD be employed, each of
366
 * which identifies exactly one authentication method.
367
 *
368
 */
369
enum pppAuthType {
370
    PPPAUTHTYPE_NONE,
371
    PPPAUTHTYPE_ANY,
372
    PPPAUTHTYPE_PAP,
373
    PPPAUTHTYPE_CHAP
374
};
375
 
376
void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd);
377
 
378
/*
379
 * Open a new PPP connection using the given serial I/O device.
380
 * This initializes the PPP control block but does not
381
 * attempt to negotiate the LCP session.
382
 * Return a new PPP connection descriptor on success or
383
 * an error code (negative) on failure.
384
 */
385
int pppOverSerialOpen(sio_fd_t fd, void (*linkStatusCB)(void *ctx, int errCode, void *arg), void *linkStatusCtx);
386
 
387
/*
388
 * Open a new PPP Over Ethernet (PPPOE) connection.
389
 */
390
int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name, void (*linkStatusCB)(void *ctx, int errCode, void *arg), void *linkStatusCtx);
391
 
392
/* for source code compatibility */
393
#define pppOpen(fd,cb,ls) pppOverSerialOpen(fd,cb,ls)
394
 
395
/*
396
 * Close a PPP connection and release the descriptor.
397
 * Any outstanding packets in the queues are dropped.
398
 * Return 0 on success, an error code on failure.
399
 */
400
int pppClose(int pd);
401
 
402
/*
403
 * Indicate to the PPP process that the line has disconnected.
404
 */
405
void pppSigHUP(int pd);
406
 
407
/*
408
 * Get and set parameters for the given connection.
409
 * Return 0 on success, an error code on failure.
410
 */
411
int  pppIOCtl(int pd, int cmd, void *arg);
412
 
413
/*
414
 * Return the Maximum Transmission Unit for the given PPP connection.
415
 */
416
u_int pppMTU(int pd);
417
 
418
/*
419
 * Write n characters to a ppp link.
420
 * RETURN: >= 0 Number of characters written, -1 Failed to write to device.
421
 */
422
int pppWrite(int pd, const u_char *s, int n);
423
 
424
void pppInProcOverEthernet(int pd, struct pbuf *pb);
425
 
426
struct pbuf *pppSingleBuf(struct pbuf *p);
427
 
428
void pppLinkTerminated(int pd);
429
 
430
void pppLinkDown(int pd);
431
 
432
void pppMainWakeup(int pd);
433
 
434
/* Configure i/f transmit parameters */
435
void ppp_send_config (int, int, u32_t, int, int);
436
/* Set extended transmit ACCM */
437
void ppp_set_xaccm (int, ext_accm *);
438
/* Configure i/f receive parameters */
439
void ppp_recv_config (int, int, u32_t, int, int);
440
/* Find out how long link has been idle */
441
int  get_idle_time (int, struct ppp_idle *);
442
 
443
/* Configure VJ TCP header compression */
444
int  sifvjcomp (int, int, int, int);
445
/* Configure i/f down (for IP) */
446
int  sifup (int);
447
/* Set mode for handling packets for proto */
448
int  sifnpmode (int u, int proto, enum NPmode mode);
449
/* Configure i/f down (for IP) */
450
int  sifdown (int);
451
/* Configure IP addresses for i/f */
452
int  sifaddr (int, u32_t, u32_t, u32_t, u32_t, u32_t);
453
/* Reset i/f IP addresses */
454
int  cifaddr (int, u32_t, u32_t);
455
/* Create default route through i/f */
456
int  sifdefaultroute (int, u32_t, u32_t);
457
/* Delete default route through i/f */
458
int  cifdefaultroute (int, u32_t, u32_t);
459
 
460
/* Get appropriate netmask for address */
461
u32_t GetMask (u32_t);
462
 
463
#endif /* PPP_SUPPORT */
464
 
465
#endif /* PPP_H */

powered by: WebSVN 2.1.0

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