chat.h revision 50479
177701Sbrian/*-
285964Sbrian * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
377701Sbrian * All rights reserved.
477701Sbrian *
577701Sbrian * Redistribution and use in source and binary forms, with or without
677701Sbrian * modification, are permitted provided that the following conditions
777701Sbrian * are met:
877701Sbrian * 1. Redistributions of source code must retain the above copyright
977701Sbrian *    notice, this list of conditions and the following disclaimer.
1077701Sbrian * 2. Redistributions in binary form must reproduce the above copyright
1177701Sbrian *    notice, this list of conditions and the following disclaimer in the
1277701Sbrian *    documentation and/or other materials provided with the distribution.
1377701Sbrian *
1477701Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1577701Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1677701Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1777701Sbrian * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1877701Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1977701Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2077701Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2177701Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2277701Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2377701Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2477701Sbrian * SUCH DAMAGE.
2577701Sbrian *
2677701Sbrian * $FreeBSD: head/usr.sbin/ppp/chat.h 50479 1999-08-28 01:35:59Z peter $
2784195Sdillon */
2884195Sdillon
2984195Sdillon#define CHAT_EXPECT 0
3026026Sbrian#define CHAT_SEND   1
3126026Sbrian#define CHAT_DONE   2
3226026Sbrian#define CHAT_FAILED 3
3326026Sbrian
3426026Sbrian#define MAXABORTS   50
3526026Sbrian
3626026Sbrianstruct physical;
3726026Sbrian
3826026Sbrianstruct chat {
3926026Sbrian  struct descriptor desc;
4026026Sbrian  struct physical *physical;
4126026Sbrian
4226026Sbrian  int state;				/* Our CHAT_* status */
4326026Sbrian
44131612Sdes  char script[LINE_LEN];		/* Our arg buffer */
45131612Sdes  char *argv[MAXARGS];			/* Our arguments (pointing to script) */
46131612Sdes  int argc;				/* Number of argv's */
47131612Sdes
4826026Sbrian  int arg;				/* Our current arg number */
4926026Sbrian  char exp[LINE_LEN];			/* Our translated current argument */
5026026Sbrian  char *argptr;				/* Our current arg pointer */
51145921Sglebius  int arglen;				/* The length of argptr */
52145921Sglebius  char *nargptr;			/* Our next for expect-send-expect */
53145921Sglebius
54145921Sglebius  char buf[LINE_LEN*2];			/* Our input */
55162674Spiso  char *bufstart;			/* start of relevent data */
56162674Spiso  char *bufend;				/* end of relevent data */
57162674Spiso
58145921Sglebius  int TimeoutSec;			/* Expect timeout value */
59187304Spiso  int TimedOut;				/* We timed out */
60162674Spiso
61145921Sglebius  const char *phone;			/* Our phone number */
6299207Sbrian
63177323Spiso  struct {
64168346Skan    struct {
65145921Sglebius      char *data;			/* Abort the dial if we get one */
66145921Sglebius      int len;
67145921Sglebius    } string[MAXABORTS];
6826026Sbrian    int num;				/* How many AbortStrings */
6926026Sbrian  } abort;
7026026Sbrian
7126026Sbrian  struct pppTimer pause;		/* Inactivity timer */
7226026Sbrian  struct pppTimer timeout;		/* TimeoutSec timer */
73145921Sglebius};
74145932Sglebius
75145921Sglebius#define descriptor2chat(d) \
76162674Spiso  ((d)->type == CHAT_DESCRIPTOR ? (struct chat *)(d) : NULL)
77145921Sglebius#define	VECSIZE(v)	(sizeof(v) / sizeof(v[0]))
7826026Sbrian
79162674Spisoextern void chat_Init(struct chat *, struct physical *, const char *, int,
80145921Sglebius                      const char *);
8126026Sbrianextern void chat_Destroy(struct chat *);
82162674Spiso