This commit is contained in:
Matthias Urlichs 1995-11-15 08:13:32 +01:00 committed by Harald Welte
parent 0a9bc8c1b7
commit 346491b223
22 changed files with 309 additions and 437 deletions

15
DOKU
View File

@ -377,8 +377,9 @@ AT/K
Kann nur vom Superuser ausgeführt werden. Kann nur vom Superuser ausgeführt werden.
AT/Kn AT/Kn
Beendet die Verbindung <n>, beendet das betreffende Programm. Beendet die Verbindung <n>, beendet das betreffende Programm.
AT/L AT/L Karte
Listet den momentanen Status aller Verbindungen. Listet den momentanen Status aller Verbindungen für die angegebene
Karte (kann weggelassen werden: alle Karten).
<[minor:]id> <Art> <Partner> <Key> <pid> <Modus/Karte> <UnitNow> <UnitAll> <Status> <[minor:]id> <Art> <Partner> <Key> <pid> <Modus/Karte> <UnitNow> <UnitAll> <Status>
<minor> Nummer der Verbindung, für AT/K o.ä. <minor> Nummer der Verbindung, für AT/K o.ä.
<n> interne Folgenummer der Statusmeldung; Meldungen, die einen <n> interne Folgenummer der Statusmeldung; Meldungen, die einen
@ -401,14 +402,20 @@ AT/L
nicht mehr bekannt ist, der Zustand aber noch eine Zeitlang angezeigt wird. nicht mehr bekannt ist, der Zustand aber noch eine Zeitlang angezeigt wird.
Bis zum nächsten AT-Befehl bleibt der Kanal im Monitormodus und meldet Bis zum nächsten AT-Befehl bleibt der Kanal im Monitormodus und meldet
alle Zustandsänderungen automatisch. alle Zustandsänderungen automatisch. Außerdem kommt jede Minute eine
"Keepalive"-Zeile mit der aktuellen Uhrzeit sowie der Anzahl der
Minuten, die der Masterprozeß diesmal durchgelaufen ist. ;-)
AT/I AT/I
Listet den internen Zustand. In der ersten Zeile stehen die erkannten Listet den internen Zustand. In der ersten Zeile stehen die erkannten
ISDN-Karten, die zweite Zeile enthält den internen Zustand des ISDN- ISDN-Karten, die zweite Zeile enthält den internen Zustand des ISDN-
Systems. Zum Debuggen. Systems. Zum Debuggen.
AT/W karte AT/W Karte
Beobachtet den Traffic auf den D-Kanälen der Karte (kann ein Pattern Beobachtet den Traffic auf den D-Kanälen der Karte (kann ein Pattern
sein: AT/W* auf allen Karten). Dazu muß :de in der DL-Zeile stehen. sein: AT/W* auf allen Karten). Dazu muß :de in der DL-Zeile stehen.
Bei aktiven Karten sind das die Protokolldaten, zB CAPI-Nachrichten.
Die Daten werden _nicht_ interpretiert.
Zusätzlich werden dieselben Daten wie bei AT/L angezeigt.
AT/M foo AT/M foo
Sendet den Systembefehl "foo" nach unten. Gefährlich. Sendet den Systembefehl "foo" nach unten. Gefährlich.
Kann zum Online-Rekonfigurieren von Modulen verwendet werden. Beispiel: Kann zum Online-Rekonfigurieren von Modulen verwendet werden. Beispiel:

View File

@ -19,6 +19,8 @@ include Make.rules
$(MAKE) depend $(MAKE) depend
touch .diddepend touch .diddepend
config/config.data: config
clean:: clean::
rm -f .toldem .diddepend rm -f .toldem .diddepend

18
README
View File

@ -4,6 +4,24 @@ Die Anleitung und der ganze Kram findet sich in der Datei DOKU, oder
README.isdn in den Kernelsourcen. README.isdn in den Kernelsourcen.
*** 1995-11-15
Release 21. Ditto Bugfixes. Callback funktioniert wieder in beide
Richtungen, und nicht nur mit U-ISDN oder mit einer Karte.
Das Teil ist bei mir im aktiven Einsatz als IP-Router. Also meckert nicht
"es funktioniert überhaupt nix", das ist falsch. ;-)
Nein, ich werde nicht dafür bezahlt, dieses ISDN-Tier zu bauen. Folglich
habe ich auch keine Zeit, dieses und jenes Feature in jedem neuen Release
neu zu testen. Sorry, aber das ist so. Insbesondere habe ich hier nur noch
einen Rechner unter 1.2.x laufen, und den fasse ich momentan nicht an; der
Rest ist 1.3.40. Wenn das System nicht unter 1.2 zu kompilieren ist, dann
ist das zwar scheußlich, aber ich erwarte, daß sich jemand aufrafft und mir
einen diff schickt, weil ich es _nicht_ selber mache(n kann). Sorry, aber
so ist es nunmal.
*** 1995-11-1 *** 1995-11-1
Release 20. Bugfixes et al. Release 20. Bugfixes et al.

View File

@ -410,10 +410,6 @@ void deb_kfree(void *fo, const char *deb_file, unsigned int deb_line)
#ifdef MODULE #ifdef MODULE
#if LINUX_VERSION_CODE < 66344
char kernel_version[] = UTS_RELEASE;
#endif
static int do_init_module(void) static int do_init_module(void)
{ {
/* This should _really_ work... */ /* This should _really_ work... */

View File

@ -83,14 +83,15 @@ typedef struct _isdn23_hdr {
struct { /* Attach B/D channel */ struct { /* Attach B/D channel */
SUBDEV minor; /* Device to attach to */ SUBDEV minor; /* Device to attach to */
uchar_t card; /* which card? */ uchar_t card; /* which card? */
uchar_t chan; /* B/D channel to attach. Zero: D chan, else uchar_t chan; /* B/D channel to attach. Zero: D chan, else * B. */
* B. */
uchar_t mode; /* Mode to switch card to */ uchar_t mode; /* Mode to switch card to */
char listen; /* listen-only mode? (Bit 1) Force channel? (bit 2) */ char listen; /* listen-only mode? (Bit 1) Force channel? (bit 2) */
} _hdr_attach; /* Downstream only. */ } _hdr_attach; /* Downstream only. */
struct { /* disconnect B/D channel */ struct { /* disconnect B/D channel */
SUBDEV minor; /* what to disconnect */ SUBDEV minor; /* what to disconnect */
uchar_t card; /* which card? */
uchar_t chan; /* B/D channel to attach. Zero: D chan, else * B. */
uchar_t error; /* force error? */ uchar_t error; /* force error? */
uchar_t perm; /* also take down protocol stack */ uchar_t perm; /* also take down protocol stack */
} _hdr_detach; /* Usually downstream. Upstream if card } _hdr_detach; /* Usually downstream. Upstream if card

View File

@ -1928,6 +1928,8 @@ isdn2_disconnect (isdn2_chan ch, uchar_t error)
hdr->key = HDR_DETACH; hdr->key = HDR_DETACH;
hdr->seqnum = hdrseq; hdrseq += 2; hdr->seqnum = hdrseq; hdrseq += 2;
hdr->hdr_detach.minor = ch->dev; hdr->hdr_detach.minor = ch->dev;
hdr->hdr_detach.card = 0;
hdr->hdr_detach.chan = 0;
hdr->hdr_detach.error = error; hdr->hdr_detach.error = error;
hdr->hdr_detach.perm = 0; hdr->hdr_detach.perm = 0;
if(isdn2_debug & 0x2000) logh_printmsg (NULL, "Up", mb); if(isdn2_debug & 0x2000) logh_printmsg (NULL, "Up", mb);
@ -2802,6 +2804,27 @@ isdn2_wsrv (queue_t *q)
{ {
NOLENHDR (); NOLENHDR ();
xMINOR (detach); xMINOR (detach);
if (isdn2_debug & 0x10)
printf ("%sDetach card %d channel %d to minor %d%s\n",KERN_DEBUG, hdr.hdr_detach.card, hdr.hdr_detach.chan, minor, hdr.hdr_detach.perm ? " force" : "");
if(hdr.hdr_detach.card != 0) {
CARD (attach);
if (chan->card != crd) {
printf ("%s -- bad card\n",KERN_DEBUG);
h_reply (q, &hdr, EBUSY);
break;
}
if (hdr.hdr_detach.chan > crd->card->nr_chans) {
printf ("%s -- bad channel (%d > %d)\n",KERN_DEBUG, hdr.hdr_detach.chan, crd->card->nr_chans);
h_reply (q, &hdr, EINVAL);
}
if (crd->chan[hdr.hdr_detach.chan] != NULL && crd->chan[hdr.hdr_detach.chan] != chan) {
printf ("%s -- bad channel (%d)\n",KERN_DEBUG,hdr.hdr_detach.chan);
h_reply (q, &hdr, EBUSY);
break;
}
}
if (hdr.hdr_detach.perm) if (hdr.hdr_detach.perm)
poplist (chan->qptr, 0); poplist (chan->qptr, 0);
isdn2_disconnect (chan, hdr.hdr_detach.error); isdn2_disconnect (chan, hdr.hdr_detach.error);

View File

@ -116,7 +116,7 @@ static void CAPI_TFOO (isdn3_conn conn);
struct capi_info { struct capi_info {
unsigned short service; unsigned short service;
unsigned char subcard; unsigned char subcard;
unsigned char bchan; unsigned char bchan; /* the _real_ channel */
unsigned char flags; unsigned char flags;
#define INF_SPV 01 #define INF_SPV 01
unsigned char lnr[MAXNR]; unsigned char lnr[MAXNR];
@ -193,22 +193,30 @@ printf ("Conn CAPI:%d %05lx: State %d --> %d\n", deb_line, conn->call_ref, conn-
timer(CAPI_TFOO,conn); timer(CAPI_TFOO,conn);
break; break;
} }
if(state == 0 || state >= 20) {
/* Select/free a fake B channel. This is _not_ related to the channel
the ISDN is actually using, as it's shared if there's more than one
ISDN on the card. */
if(state == 0 || state == 99) {
if(conn->bchan != 0) { if(conn->bchan != 0) {
conn->talk->chanmask &=~ (1<<conn->bchan); conn->talk->chanmask &=~ (1<<(conn->bchan-1));
conn->bchan = 0; conn->bchan = 0;
conn->minorstate &=~ MS_BCHAN; conn->minorstate &=~ MS_BCHAN;
/* XXX send a clearing msg down? */ /* XXX send a clearing msg down? */
} }
} else if(conn->bchan == 0) { } else {
int ch; unsigned long chm; if((conn->bchan == 0) && (state > 0 && state <= 15)) {
for(ch=1,chm = 1;chm; chm <<= 1, ch++) int ch; unsigned long chm;
if(!(conn->talk->chanmask & chm)) for(ch=1,chm = 1;chm; chm <<= 1, ch++) {
break; if(!(conn->talk->chanmask & chm)) {
if(chm) { conn->bchan = ch;
conn->bchan = ch; break;
}
}
}
if(conn->bchan != 0) {
conn->minorstate |= MS_BCHAN; conn->minorstate |= MS_BCHAN;
conn->talk->chanmask |= chm; conn->talk->chanmask |= 1<<(conn->bchan-1);
isdn3_setup_conn (conn, EST_NO_CHANGE); isdn3_setup_conn (conn, EST_NO_CHANGE);
} }
} }
@ -559,6 +567,7 @@ chstate (isdn3_talk talk, uchar_t ind, short add)
/* TODO: reset / restart / XXX the card? */ /* TODO: reset / restart / XXX the card? */
break; break;
} }
talk->chanmask = 0;
send_open(talk); send_open(talk);
break; break;
case MDL_ERROR_IND: case MDL_ERROR_IND:

View File

@ -537,8 +537,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi
conn_info (conn, mb); conn_info (conn, mb);
putnext (isdn3_q, mb); putnext (isdn3_q, mb);
minorflags[conn->minor] |= MINOR_INITPROTO_SENT | MINOR_INITPROTO_SENT2; minorflags[conn->minor] |= MINOR_INITPROTO_SENT | MINOR_INITPROTO_SENT2;
} } else if ((log_34 & 2) && !(minorflags[conn->minor] & MINOR_INITPROTO_SENT)) {
else if ((log_34 & 2) && !(minorflags[conn->minor] & MINOR_INITPROTO_SENT)) {
printf ("-InitProto: "); printf ("-InitProto: ");
if (conn->minor == 0) if (conn->minor == 0)
printf ("Minor zero; "); printf ("Minor zero; ");
@ -896,6 +895,8 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi
hdr->key = HDR_DETACH; hdr->key = HDR_DETACH;
hdr->seqnum = hdrseq; hdrseq += 2; hdr->seqnum = hdrseq; hdrseq += 2;
hdr->hdr_detach.minor = conn->minor; hdr->hdr_detach.minor = conn->minor;
hdr->hdr_detach.card = conn->card->nr;
hdr->hdr_detach.chan = conn->bchan;
hdr->hdr_detach.error = 0; hdr->hdr_detach.error = 0;
hdr->hdr_detach.perm = 0; hdr->hdr_detach.perm = 0;
if ((err = isdn3_sendhdr (mp)) != 0) { if ((err = isdn3_sendhdr (mp)) != 0) {
@ -2206,6 +2207,8 @@ printf("ErX k\n");
hdr->key |= HDR_NOERROR; hdr->key |= HDR_NOERROR;
hdr->seqnum = hdrseq; hdrseq += 2; hdr->seqnum = hdrseq; hdrseq += 2;
hdr->hdr_detach.minor = fminor; hdr->hdr_detach.minor = fminor;
hdr->hdr_detach.card = 0;
hdr->hdr_detach.chan = 0;
hdr->hdr_detach.error = 0xFF; hdr->hdr_detach.error = 0xFF;
hdr->hdr_detach.perm = 1; hdr->hdr_detach.perm = 1;
if ((err = isdn3_sendhdr (mp)) != 0) { if ((err = isdn3_sendhdr (mp)) != 0) {
@ -2226,17 +2229,17 @@ printf("ErX k\n");
} }
break; break;
case CMD_OFF: case CMD_OFF:
#if 0
if(nodisc) { /* Prevent disconnect from being sent to the stream */ if(nodisc) { /* Prevent disconnect from being sent to the stream */
if(conn != NULL) { if(conn != NULL) {
if(conn->minor != 0 && minor2conn[conn->minor] == conn) if(conn->minor != 0 && minor2conn[conn->minor] == conn)
minor2conn[conn->minor] = NULL; minor2conn[conn->minor] = NULL;
conn->minor = 0; conn->minor = 0;
conn->minorstate |= MS_NOMINOR|MS_DETACHED; conn->minorstate |= MS_NOMINOR;
} }
minor = fminor = 0; /* XXX */ minor = fminor = 0; /* XXX */
} }
#if 0 if ((conn != NULL) && ((conn->minorstate & MS_CONN_MASK) == MS_CONN) && !force) {
if (conn != NULL && !force) {
isdn3_killconn (conn, 0); isdn3_killconn (conn, 0);
break; break;
} }
@ -2244,7 +2247,7 @@ printf("ErX k\n");
if(minor != 0 && do_int < 0) { if(minor != 0 && do_int < 0) {
minorflags[minor] &= ~(MINOR_PROTO|MINOR_INITPROTO_SENT); minorflags[minor] &= ~(MINOR_PROTO|MINOR_INITPROTO_SENT);
} }
/* FALLL THRU */ /* FALL THRU */
default: default:
/* /*
* Unknown command. Set pointer back to the beginning and forward to * Unknown command. Set pointer back to the beginning and forward to
@ -2937,15 +2940,15 @@ isdn3_rsrv (queue_t * q)
break; break;
case HDR_XDATA: case HDR_XDATA:
{ {
isdn3_conn conn = isdn3_findminor (hdr.hdr_detach.minor); isdn3_conn conn = isdn3_findminor (hdr.hdr_xdata.minor);
isdn3_talk talk; isdn3_talk talk;
if (conn == NULL) { if (conn == NULL) {
if (0) printf ("XData: Conn for minor %d nf\n", hdr.hdr_detach.minor); if (0) printf ("XData: Conn for minor %d nf\n", hdr.hdr_xdata.minor);
break; break;
} }
if ((talk = conn->talk) == NULL) { if ((talk = conn->talk) == NULL) {
printf ("XData m %d: No Talker\n", hdr.hdr_detach.minor); printf ("XData m %d: No Talker\n", hdr.hdr_xdata.minor);
break; break;
} }
if (talk->hndl->send != NULL && (*talk->hndl->send) (conn, mp) == 0) if (talk->hndl->send != NULL && (*talk->hndl->send) (conn, mp) == 0)
@ -3106,7 +3109,7 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor);
printf ("Detach: Conn for minor %d nf\n", hdr.hdr_detach.minor); printf ("Detach: Conn for minor %d nf\n", hdr.hdr_detach.minor);
break; break;
} }
isdn3_killconn (conn, 0); if(0) isdn3_killconn (conn, 0);
} }
break; break;
case HDR_CARD: case HDR_CARD:

View File

@ -1952,8 +1952,11 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
ulong_t service = ~0; ulong_t service = ~0;
int err = 0; int err = 0;
ushort_t typ; ushort_t typ;
uchar_t suppress = 0; char suppress = 0;
uchar_t svc = 0; char svc = 0;
char doforce = 0;
char donodisc = 0;
long cause = -1;
if(conn->p_data == NULL) { if(conn->p_data == NULL) {
if((conn->p_data = malloc(sizeof(struct t_info))) == NULL) { if((conn->p_data = malloc(sizeof(struct t_info))) == NULL) {
@ -1961,6 +1964,62 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
} }
bzero(conn->p_data,sizeof(struct t_info)); bzero(conn->p_data,sizeof(struct t_info));
} }
if(data != NULL) {
while (m_getsx (data, &typ) == 0) {
switch (typ) {
case ARG_FASTDROP:
if (conn->state == 6 || conn->state == 7 ||
conn->state == 8)
doforce = 1;
break;
case ARG_CAUSE:
{
ushort_t causeid;
if (m_getid (data, &causeid) != 0)
break;
cause = n1_idtocause(causeid);
}
break;
case ARG_FORCE:
doforce = 1;
break;
case ARG_NODISC:
donodisc = 1;
break;
case ARG_SUPPRESS:
suppress = 1;
break;
case ARG_SPV:
svc = 1;
break;
case ARG_SERVICE:
if ((err = m_getx (data, &service)) != 0) {
data->b_rptr = oldpos;
return err;
}
break;
case ARG_NUMBER:
m_getskip (data);
if ((err = m_getstr (data, (char *) ((struct t_info *)conn->p_data)->nr, MAXNR)) != 0) {
printf("GetStr Number: ");
return err;
}
break;
case ARG_LNUMBER:
{
char nbuf[MAXNR];
m_getskip (data);
if ((err = m_getstr (data, nbuf, MAXNR)) != 0) {
printf("GetX EAZans: ");
return err;
}
((struct t_info *)conn->p_data)->eaz = nbuf[strlen(nbuf)-1];
}
break;
}
}
}
conn->lockit++; conn->lockit++;
switch (id) { switch (id) {
case CMD_DIAL: case CMD_DIAL:
@ -1970,45 +2029,6 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
conn->lockit--; conn->lockit--;
return -EINVAL; return -EINVAL;
} }
while ((err = m_getsx (data, &typ)) == 0) {
switch (typ) {
case ARG_SUPPRESS:
suppress = 1;
break;
case ARG_SERVICE:
if ((err = m_getx (data, &service)) != 0) {
data->b_rptr = oldpos;
printf("GetX Service: ");
conn->lockit--;
return err;
}
break;
case ARG_SPV:
svc = 1;
break;
case ARG_LNUMBER:
{
char nbuf[MAXNR];
m_getskip (data);
if ((err = m_getstr (data, nbuf, MAXNR)) != 0) {
printf("GetX EAZ: ");
conn->lockit--;
return err;
}
((struct t_info *)conn->p_data)->eaz = nbuf[strlen(nbuf)-1];
}
break;
case ARG_NUMBER:
m_getskip (data);
if ((err = m_getstr (data, (char *) ((struct t_info *)conn->p_data)->nr, MAXNR)) != 0) {
printf("GetStr Number: ");
conn->lockit--;
return err;
}
break;
default:;
}
}
/* end_arg_dial: */ /* end_arg_dial: */
if (service == ~0) { if (service == ~0) {
if(log_34 & 2)printf("No Service: "); if(log_34 & 2)printf("No Service: ");
@ -2167,29 +2187,6 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
mblk_t *asn = NULL; mblk_t *asn = NULL;
if (data != NULL) { if (data != NULL) {
while (m_getsx (data, &typ) == 0) {
switch (typ) {
case ARG_SERVICE:
if ((err = m_getx (data, &service)) != 0) {
data->b_rptr = oldpos;
conn->lockit--;
return err;
}
break;
case ARG_LNUMBER:
{
char nbuf[MAXNR];
m_getskip (data);
if ((err = m_getstr (data, nbuf, MAXNR)) != 0) {
printf("GetX EAZans: ");
conn->lockit--;
return err;
}
((struct t_info *)conn->p_data)->eaz = nbuf[strlen(nbuf)-1];
}
break;
}
}
{ {
int qd_len = 0; int qd_len = 0;
uchar_t *qd_d; uchar_t *qd_d;
@ -2272,11 +2269,9 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
{ {
mblk_t *asn = NULL; mblk_t *asn = NULL;
char donum = 0; char donum = 0;
char doforce = 1;
char gotservice = 0; char gotservice = 0;
char eaz = 0; char eaz = 0;
char eaz2 = 0; char eaz2 = 0;
char nr[MAXNR + 1];
service = ((struct t_info *)conn->p_data)->service; service = ((struct t_info *)conn->p_data)->service;
@ -2284,41 +2279,6 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
conn->lockit--; conn->lockit--;
return -ENOENT; return -ENOENT;
} }
while (m_getsx (data, &typ) == 0) {
switch (typ) {
case ARG_FORCE:
doforce = 1;
break;
case ARG_NUMBER:
m_getskip (data);
if ((err = m_getstr (data, nr, MAXNR)) != 0) {
conn->lockit--;
return err;
}
donum = 1;
break;
case ARG_SERVICE:
if ((err = m_getx (data, &service)) != 0) {
data->b_rptr = oldpos;
conn->lockit--;
return err;
}
gotservice = 1;
break;
case ARG_LNUMBER:
{
m_getskip (data);
if (data->b_rptr > data->b_wptr-2) {
data->b_rptr = oldpos;
printf("EAZ3 ");
conn->lockit--;
return -EINVAL;
}
eaz = data->b_rptr[1];
eaz2= data->b_rptr[0];
} break;
}
}
isdn3_setup_conn (conn, EST_NO_CHANGE); isdn3_setup_conn (conn, EST_NO_CHANGE);
if (((conn->delay > 0) && (conn->minorstate & MS_DELAYING)) if (((conn->delay > 0) && (conn->minorstate & MS_DELAYING))
@ -2401,59 +2361,37 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
break; break;
case CMD_OFF: case CMD_OFF:
{ {
long error = -1;
long cause = -1;
char forceit = 0;
mblk_t *mb = NULL; mblk_t *mb = NULL;
if (data != NULL) { conn->minorstate &= ~MS_WANTCONN;
while (m_getsx (data, &typ) == 0) { if(cause != -1) {
switch (typ) { int len;
case ARG_FASTDROP: uchar_t *dp;
if (conn->state == 6 || conn->state == 7 || ushort_t causeid;
conn->state == 8)
forceit = 1;
break;
case ARG_FORCE:
forceit = 1;
break;
case ARG_ERRNO:
if (m_geti (data, &error) != 0)
break;
break;
case ARG_CAUSE:
{
int len;
uchar_t *dp;
ushort_t causeid;
if (m_getid (data, &causeid) != 0) if ((mb = allocb (16, BPRI_LO)) == NULL)
break; break;
cause = n1_idtocause(causeid);
if (mb == NULL && (mb = allocb (16, BPRI_LO)) == NULL)
break;
len = mb->b_wptr - mb->b_rptr;
dp = qd_insert ((uchar_t *) mb->b_rptr, &len, 0, PT_N0_cause, 1, 0);
if (dp != NULL) {
mb->b_wptr = mb->b_rptr + len;
*dp = cause | 0x80;
}
}
break;
}
len = mb->b_wptr - mb->b_rptr;
dp = qd_insert ((uchar_t *) mb->b_rptr, &len, 0, PT_N0_cause, 1, 0);
if (dp != NULL) {
mb->b_wptr = mb->b_rptr + len;
*dp = cause | 0x80;
} }
} }
conn->minorstate &= ~MS_WANTCONN;
/* set Data */ /* set Data */
if (conn->state == 6 && cause == -1) { if (conn->state == 6 && cause == -1) {
pr_setstate(conn,99); pr_setstate(conn,99);
if(mb != NULL) if(mb != NULL)
freemsg(mb); freemsg(mb);
} else if (send_N1_disc (conn, 1 + forceit, mb) != 0 && mb != NULL) } else {
freemsg (mb); if(doforce && donodisc) {
doforce = 0;
/* Hmmm */
}
if (send_N1_disc (conn, 1 + doforce, mb) != 0 && mb != NULL)
freemsg (mb);
}
isdn3_setup_conn (conn, EST_DISCONNECT); isdn3_setup_conn (conn, EST_DISCONNECT);
err = 0; err = 0;

View File

@ -2276,7 +2276,7 @@ send_ET_disc (isdn3_conn conn, char release, mblk_t * data)
goto common_off; /* XXX experimental */ goto common_off; /* XXX experimental */
if ((err = phone_sendback (conn, MT_ET_REL_COM, data)) != 0 && data != NULL) if ((err = phone_sendback (conn, MT_ET_REL_COM, data)) != 0 && data != NULL)
freemsg(data); freemsg(data);
pr_setstate (conn, 99); /* was 19 -- mistake */ pr_setstate (conn, 99);
break; break;
case 19: case 19:
case 99: case 99:
@ -2296,6 +2296,8 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
uchar_t suppress = 0; uchar_t suppress = 0;
/* uchar_t svc = 0; */ /* uchar_t svc = 0; */
struct e_info *info; struct e_info *info;
long cause = -1;
char forceit = 0;
if(conn->p_data == NULL) { if(conn->p_data == NULL) {
if((conn->p_data = malloc(sizeof(struct e_info))) == NULL) { if((conn->p_data = malloc(sizeof(struct e_info))) == NULL) {
@ -2309,6 +2311,23 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
oldpos = data->b_rptr; oldpos = data->b_rptr;
while ((err = m_getsx (data, &typ)) == 0) { while ((err = m_getsx (data, &typ)) == 0) {
switch (typ) { switch (typ) {
case ARG_FASTDROP:
if (conn->state == 6 || conn->state == 7 ||
conn->state == 8)
forceit = 1;
break;
case ARG_FORCE:
forceit = 1;
break;
case ARG_CAUSE:
{
ushort_t causeid;
if (m_getid (data, &causeid) != 0)
break;
cause = et_idtocause(causeid);
}
break;
case ARG_LLC: case ARG_LLC:
{ {
int len = m_gethexlen(data); int len = m_gethexlen(data);
@ -2345,29 +2364,6 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
case ARG_SUPPRESS: case ARG_SUPPRESS:
suppress = 1; suppress = 1;
break; break;
#if 0
case ARG_SERVICE:
if ((err = m_getx (data, &service)) != 0) {
data->b_rptr = oldpos;
printf("GetX Service: ");
conn->lockit--;
return err;
}
break;
case ARG_SPV:
svc = 1;
break;
case ARG_EAZ:{
m_getskip (data);
if (data->b_rptr == data->b_wptr) {
data->b_rptr = oldpos;
printf("GetX EAZ: ");
conn->lockit--;
return -EINVAL;
}
conn->eaz = *data->b_rptr++;
} break;
#endif
case ARG_LNUMBER: case ARG_LNUMBER:
m_getskip (data); m_getskip (data);
if ((err = m_getstr (data, (char *) info->lnr, MAXNR)) != 0) { if ((err = m_getstr (data, (char *) info->lnr, MAXNR)) != 0) {
@ -2684,193 +2680,26 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data)
freemsg (asn); freemsg (asn);
} }
break; break;
#if 0
case CMD_FORWARD:
{
mblk_t *asn = NULL;
char donum = 0;
char doforce = 1;
char gotservice = 0;
char eaz = 0;
char eaz2 = 0;
char nr[MAXNR + 1];
service = conn->service;
if (data == NULL) {
conn->lockit--;
return -ENOENT;
}
while (m_getsx (data, &typ) == 0) {
switch (typ) {
case ARG_FORCE:
doforce = 1;
break;
case ARG_NUMBER:
m_getskip (data);
if ((err = m_getstr (data, nr, MAXNR)) != 0) {
conn->lockit--;
return err;
}
donum = 1;
break;
case ARG_SERVICE:
if ((err = m_getx (data, &service)) != 0) {
data->b_rptr = oldpos;
conn->lockit--;
return err;
}
gotservice = 1;
break;
case ARG_EAZ:{
m_getskip (data);
if (data->b_rptr == data->b_wptr) {
data->b_rptr = oldpos;
printf("EAZ3 ");
conn->lockit--;
return -EINVAL;
}
eaz = *data->b_rptr++;
} break;
case ARG_EAZ2:{
m_getskip (data);
if (data->b_rptr == data->b_wptr) {
data->b_rptr = oldpos;
printf("EAZ4 ");
conn->lockit--;
return -EINVAL;
}
eaz2 = *data->b_rptr++;
} break;
}
}
isdn3_setup_conn (conn, EST_NO_CHANGE);
if ((conn->delay > 0) && (conn->minorstate & MS_DELAYING)
|| !(conn->minorstate & MS_PROTO)
|| !(conn->minorstate & MS_INITPROTO)
|| !(conn->minorstate & MS_BCHAN)
|| (conn->((struct e_info *)conn->p_data) & FAC_PENDING)) {
data->b_rptr = oldpos;
isdn3_repeat (conn, id, data);
conn->lockit--;
return 0;
}
if ((conn->minorstate & MS_CONN_MASK) == MS_CONN_NONE) {
printf("NoConnThere ");
conn->lockit--;
return -EINVAL;
}
if ((conn->minorstate & MS_CONN_MASK) != MS_CONN_INTERRUPT) {
isdn3_setup_conn (conn, EST_WILL_INTERRUPT);
data->b_rptr = oldpos;
isdn3_repeat (conn, id, data);
conn->lockit--;
return 0;
}
{
int qd_len = 0;
uchar_t *qd_d;
if ((asn = allocb (32, BPRI_MED)) == NULL) {
conn->lockit--;
return -ENOMEM;
}
if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_netSpecFac, (gotservice || eaz2 != 0) ? ((eaz != 0 || eaz2 != 0) ? 6 : 4) : (eaz != 0) ? 5 : 4, 0)) == NULL) {
freeb (asn);
conn->lockit--;
return -EIO;
}
qd_d[0] = 0;
qd_d[1] = (eaz2 > 0) ? ET_FAC_Dienstwechsel2 : ET_FAC_Dienstwechsel1;
qd_d[2] = service >> 8;
qd_d[3] = service & 0xFF;
if ((gotservice && eaz != 0) || eaz2 != 0) {
qd_d[4] = (eaz != 0) ? eaz : '0';
qd_d[5] = (eaz2 != 0) ? eaz2 : '0';
} else if (eaz != 0)
qd_d[4] = eaz;
asn->b_wptr = asn->b_rptr + qd_len;
}
switch (conn->state) {
case 4:
case 7:
case 8:
if (!doforce) {
if (data != NULL)
data->b_rptr = oldpos;
isdn3_repeat (conn, id, data);
if (asn != NULL)
freemsg (asn);
conn->lockit--;
return 0;
}
case 10:
if (!donum)
conn->minorstate |= MS_FORWARDING;
conn->((struct e_info *)conn->p_data) |= FAC_PENDING;
if ((err = phone_sendback (conn, MT_ET_FAC, asn)) == 0)
asn = NULL;
isdn3_setup_conn (conn, EST_LISTEN);
pr_setstate (conn, 8);
break;
default:
printf("BadState4 ");
err = -EINVAL;
break;
}
if (asn != NULL)
freemsg (asn);
}
break;
#endif
case CMD_OFF: case CMD_OFF:
{ {
long error = -1;
long cause = -1;
char forceit = 0;
mblk_t *mb = NULL; mblk_t *mb = NULL;
if (data != NULL) { if(cause != -1) {
while (m_getsx (data, &typ) == 0) { int len;
switch (typ) { uchar_t *dp;
case ARG_FASTDROP:
if (conn->state == 6 || conn->state == 7 ||
conn->state == 8)
forceit = 1;
break;
case ARG_FORCE:
forceit = 1;
break;
case ARG_ERRNO:
if (m_geti (data, &error) != 0)
break;
break;
case ARG_CAUSE:{
int len;
uchar_t *dp;
ushort_t causeid;
if (m_getid (data, &causeid) != 0) if ((mb = allocb (16, BPRI_LO)) == NULL)
break; break;
cause = et_idtocause(causeid);
if (mb == NULL && (mb = allocb (16, BPRI_LO)) == NULL)
break;
len = mb->b_wptr - mb->b_rptr; len = mb->b_wptr - mb->b_rptr;
dp = qd_insert ((uchar_t *) mb->b_rptr, &len, 0, PT_E0_cause, 2, 0); dp = qd_insert ((uchar_t *) mb->b_rptr, &len, 0, PT_E0_cause, 2, 0);
if (dp != NULL) { if (dp != NULL) {
mb->b_wptr = mb->b_rptr + len; mb->b_wptr = mb->b_rptr + len;
*dp++ = 0x80; *dp++ = 0x80;
*dp = cause | 0x80; *dp = cause | 0x80;
}
} break;
}
} }
} }
conn->minorstate &= ~MS_WANTCONN; conn->minorstate &= ~MS_WANTCONN;
/* set Data */ /* set Data */

View File

@ -46,7 +46,7 @@ read_line (FILE * ffile, int *theLine)
if (sofar == line || remain <= 3 || now == 0) if (sofar == line || remain <= 3 || now == 0)
return NULL; return NULL;
*sofar = '\0'; *sofar = '\0';
out = (struct _cf *)malloc (sizeof (struct _cf) + (now = sofar - line + 1)); out = (struct _cf *)xmalloc (sizeof (struct _cf) + (now = sofar - line + 1));
bcopy (line, (char *) (out + 1), now); bcopy (line, (char *) (out + 1), now);
bzero ((char *) out, sizeof (struct _cf)); bzero ((char *) out, sizeof (struct _cf));

View File

@ -16,7 +16,7 @@ Xnewgrab(conngrab master, int lin)
{ {
conngrab slave; conngrab slave;
slave = malloc(sizeof(*slave)); slave = xmalloc(sizeof(*slave));
if(slave == NULL) if(slave == NULL)
return NULL; return NULL;
if(master == NULL) { if(master == NULL) {
@ -98,7 +98,7 @@ connreport(char *foo, char *card, int minor)
continue; continue;
if(conn->lastMsg != NULL) if(conn->lastMsg != NULL)
free(conn->lastMsg); free(conn->lastMsg);
conn->lastMsg = malloc(strlen(foo)+1); conn->lastMsg = xmalloc(strlen(foo)+1);
if(conn->lastMsg != NULL) if(conn->lastMsg != NULL)
strcpy(conn->lastMsg,foo); strcpy(conn->lastMsg,foo);
@ -286,7 +286,7 @@ Xsetconnstate(const char *deb_file, unsigned int deb_line,conninfo conn, CState
} }
if(conn->state != c_forceoff && state == c_forceoff && conn->pid != 0) { if(conn->state != c_forceoff && state == c_forceoff && conn->pid != 0) {
struct conninfo *xconn; struct conninfo *xconn;
xconn = malloc(sizeof(*xconn)); xconn = xmalloc(sizeof(*xconn));
if(xconn != NULL) { if(xconn != NULL) {
bzero(xconn,sizeof(*xconn)); bzero(xconn,sizeof(*xconn));
xconn->seqnum = ++connseq; xconn->seqnum = ++connseq;

View File

@ -359,7 +359,7 @@ do_card(void)
if (!strcmp(card->name, crd)) if (!strcmp(card->name, crd))
return -EEXIST; return -EEXIST;
} }
card = malloc(sizeof(*card)); card = xmalloc(sizeof(*card));
if(card == NULL) if(card == NULL)
return -ENOMEM; return -ENOMEM;
bzero(card,sizeof(*card)); bzero(card,sizeof(*card));
@ -371,7 +371,7 @@ do_card(void)
card->next = isdn4_card; isdn4_card = card; card->next = isdn4_card; isdn4_card = card;
if(cardcap & CHM_INTELLIGENT) { if(cardcap & CHM_INTELLIGENT) {
ld = malloc(sizeof(struct loader)); ld = xmalloc(sizeof(struct loader));
if(ld == NULL) if(ld == NULL)
return -errno; return -errno;
bzero(ld,sizeof(*ld)); bzero(ld,sizeof(*ld));
@ -420,7 +420,7 @@ do_card(void)
(void) strwritev (xs_mon, io,len, 1); (void) strwritev (xs_mon, io,len, 1);
} }
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn != NULL) { if(conn != NULL) {
bzero(conn,sizeof(*conn)); bzero(conn,sizeof(*conn));
conn->seqnum = ++connseq; conn->seqnum = ++connseq;
@ -461,7 +461,7 @@ do_nocard(void)
break; break;
} }
} }
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn != NULL) { if(conn != NULL) {
bzero(conn,sizeof(*conn)); bzero(conn,sizeof(*conn));
conn->seqnum = ++connseq; conn->seqnum = ++connseq;
@ -490,7 +490,7 @@ do_offcard(void)
if ((ret = m_getstr(&xx, crd, 4)) != 0) if ((ret = m_getstr(&xx, crd, 4)) != 0)
return ret; return ret;
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn != NULL) { if(conn != NULL) {
bzero(conn,sizeof(*conn)); bzero(conn,sizeof(*conn));
conn->seqnum = ++connseq; conn->seqnum = ++connseq;
@ -512,7 +512,7 @@ do_recard(void)
if ((ret = m_getstr(&xx, crd, 4)) != 0) if ((ret = m_getstr(&xx, crd, 4)) != 0)
return ret; return ret;
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn != NULL) { if(conn != NULL) {
bzero(conn,sizeof(*conn)); bzero(conn,sizeof(*conn));
conn->seqnum = ++connseq; conn->seqnum = ++connseq;
@ -846,7 +846,7 @@ do_incoming(void)
conn->want_fast_reconn = 1; conn->want_fast_reconn = 1;
} }
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn != NULL) { if(conn != NULL) {
bzero(conn,sizeof(*conn)); bzero(conn,sizeof(*conn));
conn->seqnum = ++connseq; conn->seqnum = ++connseq;
@ -863,6 +863,7 @@ do_incoming(void)
if(log_34 & 2)printf("Dis2 "); if(log_34 & 2)printf("Dis2 ");
m_putid (mz, CMD_OFF); m_putid (mz, CMD_OFF);
m_putsx (mz, ARG_NODISC); m_putsx (mz, ARG_NODISC);
m_putsx (mz, ARG_FORCE);
m_putsx (mz, ID_N0_cause); m_putsx (mz, ID_N0_cause);
m_putsx2(mz, ID_N1_CallRejected); m_putsx2(mz, ID_N1_CallRejected);
if(conn->cg != NULL && conn->cg->card != NULL && conn->cg->card[0] != '\0') { if(conn->cg != NULL && conn->cg->card != NULL && conn->cg->card[0] != '\0') {
@ -890,10 +891,9 @@ do_incoming(void)
#if 1 #if 1
/* cg->flags &=~ F_INCOMING; */ /* cg->flags &=~ F_INCOMING; */
/* cg->flags |= F_OUTGOING; */ /* cg->flags |= F_OUTGOING; */
if(startconn(cg,fminor,connref,NULL, NULL) != conn) startconn(cg,fminor,connref,&resp, NULL);
resp = "ClashRestart Failed";
#endif #endif
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn != NULL) { if(conn != NULL) {
bzero(conn,sizeof(*conn)); bzero(conn,sizeof(*conn));
conn->seqnum = ++connseq; conn->seqnum = ++connseq;
@ -912,7 +912,7 @@ do_incoming(void)
/* At this point we don't have a connection. The call is valid, so /* At this point we don't have a connection. The call is valid, so
record the thing and start the program for it. */ record the thing and start the program for it. */
conn = (struct conninfo *)malloc (sizeof (struct conninfo)); conn = (struct conninfo *)xmalloc (sizeof (struct conninfo));
if (conn == NULL) { if (conn == NULL) {
resp = "NO MEMORY.5"; resp = "NO MEMORY.5";
@ -994,7 +994,7 @@ do_incoming(void)
DUMPW (ans, xlen); DUMPW (ans, xlen);
(void) strwrite (xs_mon, ans, xlen, 1); (void) strwrite (xs_mon, ans, xlen, 1);
} }
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn != NULL) { if(conn != NULL) {
bzero(conn,sizeof(*conn)); bzero(conn,sizeof(*conn));
conn->seqnum = ++connseq; conn->seqnum = ++connseq;
@ -1226,7 +1226,6 @@ do_disc(void)
m_putid (&xx, CMD_OFF); m_putid (&xx, CMD_OFF);
m_putsx (&xx, ARG_MINOR); m_putsx (&xx, ARG_MINOR);
m_puti (&xx, minor); m_puti (&xx, minor);
m_putsx (&xx, ARG_NOCONN);
xlen = xx.b_wptr - xx.b_rptr; xlen = xx.b_wptr - xx.b_rptr;
DUMPW (xx.b_rptr, xlen); DUMPW (xx.b_rptr, xlen);
(void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1);
@ -1512,8 +1511,10 @@ do_hasdisconnect(void)
m_putid (&xx, CMD_OFF); m_putid (&xx, CMD_OFF);
m_putsx (&xx, ARG_MINOR); m_putsx (&xx, ARG_MINOR);
m_puti (&xx, minor); m_puti (&xx, minor);
#if 0
if((conn != NULL) && (conn->flags & F_PERMANENT)) if((conn != NULL) && (conn->flags & F_PERMANENT))
m_putsx (&xx, ARG_NOCONN); m_putsx (&xx, ARG_NOCONN);
#endif
xlen = xx.b_wptr - xx.b_rptr; xlen = xx.b_wptr - xx.b_rptr;
DUMPW (xx.b_rptr, xlen); DUMPW (xx.b_rptr, xlen);
(void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1);
@ -1750,7 +1751,7 @@ do_atcmd(void)
struct conninfo *fconn; struct conninfo *fconn;
char buf[30]; char buf[30];
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn == NULL) { if(conn == NULL) {
free(msgbuf); free(msgbuf);
resp = "NoMem"; resp = "NoMem";
@ -1805,7 +1806,7 @@ do_atcmd(void)
case 'W': /* Monitor D channels */ case 'W': /* Monitor D channels */
{ {
char buf[30]; char buf[30];
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn == NULL) { if(conn == NULL) {
resp = "NoMemConn"; resp = "NoMemConn";
return 1; return 1;
@ -1850,7 +1851,7 @@ do_atcmd(void)
#if LEVEL < 4 #if LEVEL < 4
extern int l3print(char *); extern int l3print(char *);
#endif #endif
msgbuf = malloc(10240); msgbuf = xmalloc(10240);
if(msgbuf == NULL) { if(msgbuf == NULL) {
resp = "NO MEMORY.6"; resp = "NO MEMORY.6";
return 1; return 1;
@ -2066,7 +2067,7 @@ do_atcmd(void)
m3 = NULL; m3 = NULL;
} }
if(conn == NULL) { if(conn == NULL) {
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn != NULL) { if(conn != NULL) {
bzero(conn,sizeof(*conn)); bzero(conn,sizeof(*conn));
conn->seqnum = ++connseq; conn->seqnum = ++connseq;
@ -2222,7 +2223,7 @@ printf("GotAnError: Minor %ld, connref %ld, hdr %s\n",minor,connref,HdrName(hdrv
if(strchr(cfr->type,'E')) if(strchr(cfr->type,'E'))
cfr->got_err = 1; cfr->got_err = 1;
xconn = malloc(sizeof(*xconn)); xconn = xmalloc(sizeof(*xconn));
if(xconn != NULL) { if(xconn != NULL) {
bzero(xconn,sizeof(*xconn)); bzero(xconn,sizeof(*xconn));
xconn->seqnum = ++connseq; xconn->seqnum = ++connseq;

View File

@ -58,7 +58,7 @@ static const struct
* angegebenen Fensters an. * angegebenen Fensters an.
* *
* isintime=0 : Zeitpunkt nicht im Fenster; * isintime=0 : Zeitpunkt nicht im Fenster;
* isintime=-1 : Fehler (z.B. Syntax Error im Fenster, oder malloc() failed) * isintime=-1 : Fehler (z.B. Syntax Error im Fenster)
* *
* Georgios Papoutsis, 1995 zum Einbinden in Matthias Urlichs' ISDN * Georgios Papoutsis, 1995 zum Einbinden in Matthias Urlichs' ISDN
* *

View File

@ -45,7 +45,7 @@ card_load_close(struct loader *ld, char success)
break; break;
} }
if(conn == NULL) { if(conn == NULL) {
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
newconn = 1; newconn = 1;
} }
if(conn != NULL) { if(conn != NULL) {
@ -101,7 +101,7 @@ card_load_fail(struct loader *ld, int err)
break; break;
} }
if(conn == NULL) { if(conn == NULL) {
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
newconn = 1; newconn = 1;
} }
if(conn != NULL) { if(conn != NULL) {
@ -154,7 +154,7 @@ card_load(struct loader *ld)
} else } else
do_again = 1; do_again = 1;
if(!do_again || (ld->file != NULL)) { if(!do_again || (ld->file != NULL)) {
char *buf = NULL; /* shut up GCC */ char *buf = NULL;
int len, xlen, foffset; int len, xlen, foffset;
mblk_t xx; mblk_t xx;
struct datab db; struct datab db;
@ -162,7 +162,7 @@ card_load(struct loader *ld)
streamchar ans[50]; streamchar ans[50];
if(ld->file != NULL) { if(ld->file != NULL) {
buf = malloc(lf->num); buf = xmalloc(lf->num);
if(buf == NULL) { if(buf == NULL) {
syslog(LOG_ERR, "Card loader for %s !\n",ld->card); syslog(LOG_ERR, "Card loader for %s !\n",ld->card);
goto ex_load; goto ex_load;
@ -219,7 +219,8 @@ card_load(struct loader *ld)
} }
} }
(void) strwritev (xs_mon, io,len, 1); (void) strwritev (xs_mon, io,len, 1);
free(buf); if(buf != NULL)
free(buf);
if(do_again) { if(do_again) {
ld->timer = 1; ld->timer = 1;
timeout(card_load,ld,(ld->file || !lf) ? HZ : (HZ*lf->num2+HZ/3)); timeout(card_load,ld,(ld->file || !lf) ? HZ : (HZ*lf->num2+HZ/3));

View File

@ -26,7 +26,7 @@ tr_mallochook (size)
__ptr_t hdr; __ptr_t hdr;
__malloc_hook = tr_old_malloc_hook; __malloc_hook = tr_old_malloc_hook;
hdr = (__ptr_t) malloc (size); hdr = (__ptr_t) xmalloc (size);
__malloc_hook = tr_mallochook; __malloc_hook = tr_mallochook;
/* We could be printing a NULL here; that's OK. */ /* We could be printing a NULL here; that's OK. */
@ -67,7 +67,7 @@ mmtrace ()
if (mallfile != NULL) { if (mallfile != NULL) {
mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "a"); mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "a");
if (mallstream != NULL) { if (mallstream != NULL) {
/* Be sure it doesn't malloc its buffer! */ /* Be sure it doesn't xmalloc its buffer! */
setbuf (mallstream, mallbuf); setbuf (mallstream, mallbuf);
fprintf (mallstream, "= Start\n"); fprintf (mallstream, "= Start\n");
tr_old_free_hook = __free_hook; tr_old_free_hook = __free_hook;
@ -129,7 +129,7 @@ mallochook (size)
struct hdr *hdr; struct hdr *hdr;
__malloc_hook = old_malloc_hook; __malloc_hook = old_malloc_hook;
hdr = (struct hdr *) malloc (sizeof (struct hdr) + size + 1); hdr = (struct hdr *) xmalloc (sizeof (struct hdr) + size + 1);
__malloc_hook = mallochook; __malloc_hook = mallochook;
if (hdr == NULL) if (hdr == NULL)
return NULL; return NULL;
@ -185,7 +185,7 @@ mcheck (func)
if (func != NULL) if (func != NULL)
abortfunc = func; abortfunc = func;
/* These hooks may not be safely inserted if malloc is already in use. */ /* These hooks may not be safely inserted if xmalloc is already in use. */
if (!__malloc_initialized && !mcheck_used) if (!__malloc_initialized && !mcheck_used)
{ {
old_free_hook = __free_hook; old_free_hook = __free_hook;

View File

@ -68,6 +68,7 @@ EXTERN int fd_mon;
EXTERN char *progname; EXTERN char *progname;
void xquit (const char *s, const char *t); void xquit (const char *s, const char *t);
void *xmalloc(size_t sz);
#ifdef DO_DEBUG_MALLOC #ifdef DO_DEBUG_MALLOC

View File

@ -204,10 +204,10 @@ pmatch1 (cf prot, conngrab *cgm)
#define CHKVI() \ #define CHKVI() \
({ __label__ ex; int xx,yy,xm; streamchar *vx,*vy,*vm; ushort_t id2; \ ({ __label__ ex; int xx,yy,xm; streamchar *vx,*vy,*vm; ushort_t id2; \
yy = m_gethexlen(cand); \ yy = m_gethexlen(cand); \
if (yy <= 0 || (vy=malloc(yy))==NULL) break; \ if (yy <= 0 || (vy=xmalloc(yy))==NULL) break; \
if(m_gethex(cand,vy,yy) != 0) { free(vy); break; } \ if(m_gethex(cand,vy,yy) != 0) { free(vy); break; } \
if ((xm = m_gethexlen(cand)) > 0) { \ if ((xm = m_gethexlen(cand)) > 0) { \
if ((vm=malloc(xm)) == NULL) \ if ((vm=xmalloc(xm)) == NULL) \
{ free(vy); break; } \ { free(vy); break; } \
if(m_gethex(cand,vm,xm) != 0) \ if(m_gethex(cand,vm,xm) != 0) \
{ free(vy); free(vm); break; } \ { free(vy); free(vm); break; } \
@ -217,7 +217,7 @@ pmatch1 (cf prot, conngrab *cgm)
while(m_getsx(cgc->par_in,&id2) == 0) { \ while(m_getsx(cgc->par_in,&id2) == 0) { \
if(id != id2) continue; \ if(id != id2) continue; \
xx = m_gethexlen(cgc->par_in); \ xx = m_gethexlen(cgc->par_in); \
if (xx <= 0 || (vx=malloc(xx))==NULL) break; \ if (xx <= 0 || (vx=xmalloc(xx))==NULL) break; \
if(m_gethex(cgc->par_in,vx,xx) != 0) \ if(m_gethex(cgc->par_in,vx,xx) != 0) \
{ free(vx); break; } \ { free(vx); break; } \
if(abs(vectcmp(vx,xx,vy,yy,vm,xm)) < 5) \ if(abs(vectcmp(vx,xx,vy,yy,vm,xm)) < 5) \
@ -235,10 +235,10 @@ pmatch1 (cf prot, conngrab *cgm)
#define CHKVO() \ #define CHKVO() \
({ __label__ ex; int xx,yy,xm; streamchar *vx,*vy,*vm; ushort_t id2; \ ({ __label__ ex; int xx,yy,xm; streamchar *vx,*vy,*vm; ushort_t id2; \
yy = m_gethexlen(cand); \ yy = m_gethexlen(cand); \
if (yy <= 0 || (vy=malloc(yy))==NULL) break; \ if (yy <= 0 || (vy=xmalloc(yy))==NULL) break; \
if(m_gethex(cand,vy,yy) != 0) { free(vy); break; } \ if(m_gethex(cand,vy,yy) != 0) { free(vy); break; } \
if ((xm = m_gethexlen(cand)) > 0) { \ if ((xm = m_gethexlen(cand)) > 0) { \
if ((vm=malloc(xm)) == NULL) \ if ((vm=xmalloc(xm)) == NULL) \
{ free(vy); break; } \ { free(vy); break; } \
if(m_gethex(cand,vm,xm) != 0) \ if(m_gethex(cand,vm,xm) != 0) \
{ free(vy); free(vm); break; } \ { free(vy); free(vm); break; } \
@ -248,7 +248,7 @@ pmatch1 (cf prot, conngrab *cgm)
while(m_getsx(cgc->par_out,&id2) == 0) { \ while(m_getsx(cgc->par_out,&id2) == 0) { \
if(id != id2) continue; \ if(id != id2) continue; \
xx = m_gethexlen(cgc->par_out); \ xx = m_gethexlen(cgc->par_out); \
if (xx <= 0 || (vx=malloc(xx))==NULL) break; \ if (xx <= 0 || (vx=xmalloc(xx))==NULL) break; \
if(m_gethex(cgc->par_out,vx,xx) != 0) \ if(m_gethex(cgc->par_out,vx,xx) != 0) \
{ free(vx); break; } \ { free(vx); break; } \
if(abs(vectcmp(vx,xx,vy,yy,vm,xm)) < 5) \ if(abs(vectcmp(vx,xx,vy,yy,vm,xm)) < 5) \
@ -685,20 +685,25 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); /* I hate debugging. */
continue; continue;
for(conn = isdn4_conn; conn != NULL; conn = conn->next) { for(conn = isdn4_conn; conn != NULL; conn = conn->next) {
char *prot,*sit;
if(conn->ignore || !conn->cg) if(conn->ignore || !conn->cg)
continue; continue;
if(conn->state < c_going_up) if(conn->state < c_going_up)
continue; continue;
if(wildmatch(conn->cg->card, cl->card) == NULL) if(wildmatch(conn->cg->card, cl->card) == NULL)
continue; continue;
if(wildmatch(conn->cg->protocol, cl->protocol) == NULL) if((prot = wildmatch(conn->cg->protocol, cl->protocol)) == NULL)
continue; continue;
if(wildmatch(conn->cg->site, cl->site) == NULL) if((sit = wildmatch(conn->cg->site, cl->site)) == NULL)
continue; continue;
if(classmatch(conn->cg->cclass, cl->cclass) == NULL) if(classmatch(conn->cg->cclass, cl->cclass) == NULL)
continue; continue;
if(maskmatch(conn->cg->mask,cl->mask) == 0) if(maskmatch(conn->cg->mask,cl->mask) == 0)
continue; continue;
if(conn->state == c_going_up &&
wildmatch(sit,cg->site) != NULL &&
wildmatch(prot,cg->protocol) != NULL)
continue;
if(conn->flags & F_IGNORELIMIT) if(conn->flags & F_IGNORELIMIT)
continue; continue;
naconn++; naconn++;

View File

@ -7,6 +7,23 @@
#include "master.h" #include "master.h"
/* If we could assume it'd work right without any memory,
we might die cleanly, like AT/Q does. Maybe sometime in the future.
Thus, DO NOT assume xmalloc aborts; it may still return NULL. */
void *
xmalloc(size_t sz)
{
void *foo;
foo = malloc(sz);
if(foo == NULL) {
syslog(LOG_CRIT,"No memory for %ld bytes! Dying!\n",sz);
abort();
}
return foo;
}
/* Too many strings to keep track of, no time for garbage collection. */ /* Too many strings to keep track of, no time for garbage collection. */
/* Enter them in a binary tree... */ /* Enter them in a binary tree... */
/* str_enter MUST NOT be called while any string in the tree is temporarily /* str_enter MUST NOT be called while any string in the tree is temporarily
@ -31,7 +48,7 @@ char *str_enter(char *master)
str = &st->right; str = &st->right;
st = *str; st = *str;
} }
st = malloc(sizeof(struct string)+strlen(master)); st = xmalloc(sizeof(struct string)+strlen(master));
if(st == NULL) if(st == NULL)
return NULL; return NULL;
@ -206,7 +223,7 @@ classmatch(char *a, char *b)
void void
putenv2 (const char *key, const char *val) putenv2 (const char *key, const char *val)
{ {
char *xx = (char *)malloc (strlen (key) + strlen (val) + 2); char *xx = (char *)xmalloc (strlen (key) + strlen (val) + 2);
if (xx != NULL) { if (xx != NULL) {
sprintf (xx, "%s=%s", key, val); sprintf (xx, "%s=%s", key, val);
@ -236,8 +253,7 @@ void
dropdead(void) dropdead(void)
{ {
if(zzconn != NULL && zzconn->cg != NULL) if(zzconn != NULL && zzconn->cg != NULL)
syslog(LOG_ERR, "Startup of %s:%s cancelled -- syslog(LOG_ERR, "Startup of %s:%s cancelled -- timeout",zzconn->cg->site,zzconn->cg->protocol);
timeout",zzconn->cg->site,zzconn->cg->protocol);
else else
syslog(LOG_ERR, "Startup cancelled because of a timeout!"); syslog(LOG_ERR, "Startup cancelled because of a timeout!");
exit(9); exit(9);
@ -246,15 +262,32 @@ dropdead(void)
void void
log_idle (void *xxx) log_idle (void *xxx)
{ {
syslog (LOG_DEBUG, "ISDN is still alive."); static time_t started = 0;
timeout (log_idle, NULL, 10 * 60 * HZ); char repbuf[80];
struct tm *tm;
time_t now;
if(started == 0)
started = time(NULL);
now = time(NULL);
tm = localtime(&now);
now = (now - started) / 60;
sprintf(repbuf,"#%d %02d:%02d", (int)now, tm->tm_hour,tm->tm_min);
connreport(repbuf,"*",0);
if(!(now % 5))
syslog (LOG_DEBUG, "ISDN is alive; %d minutes.",(int)now);
timeout (log_idle, NULL, 60 * HZ);
} }
void void
queue_idle (void *xxx) queue_idle (void *xxx)
{ {
runqueues (); runqueues(); runqueues ();
timeout (queue_idle, NULL, HZ/2); timeout (queue_idle, NULL, HZ);
} }
void void

View File

@ -126,7 +126,7 @@ pushprot (conngrab cg, int minor, int connref, char update)
(void) strwrite (xs_mon, (uchar_t *) mj->b_rptr, len, 1); (void) strwrite (xs_mon, (uchar_t *) mj->b_rptr, len, 1);
freeb (mj); freeb (mj);
sx = (char *)malloc (strlen (prot->args) + 5 + strlen (PROTO_NAME)); sx = (char *)xmalloc (strlen (prot->args) + 5 + strlen (PROTO_NAME));
if (sx == NULL) if (sx == NULL)
return -ENOMEM; return -ENOMEM;
sprintf (sx, " %s %s", prot->args, PROTO_NAME); sprintf (sx, " %s %s", prot->args, PROTO_NAME);
@ -277,7 +277,7 @@ pushcardprot (conngrab cg, int minor, int connref)
break; break;
} }
if (cmod == NULL) { if (cmod == NULL) {
struct conninfo *xconn = malloc(sizeof(*xconn)); struct conninfo *xconn = xmalloc(sizeof(*xconn));
if(xconn != NULL) { if(xconn != NULL) {
bzero(xconn,sizeof(*xconn)); bzero(xconn,sizeof(*xconn));
xconn->seqnum = ++connseq; xconn->seqnum = ++connseq;
@ -295,7 +295,7 @@ pushcardprot (conngrab cg, int minor, int connref)
break; break;
} }
if (prot == NULL) { if (prot == NULL) {
struct conninfo *xconn = malloc(sizeof(*xconn)); struct conninfo *xconn = xmalloc(sizeof(*xconn));
if(xconn != NULL) { if(xconn != NULL) {
bzero(xconn,sizeof(*xconn)); bzero(xconn,sizeof(*xconn));
xconn->seqnum = ++connseq; xconn->seqnum = ++connseq;
@ -672,7 +672,7 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo)
cg = *foo; cg = *foo;
if(conn == NULL) { if(conn == NULL) {
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn == NULL) { if(conn == NULL) {
return "NO MEMORY.1"; return "NO MEMORY.1";
} }
@ -719,7 +719,7 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo)
} }
} }
} }
prog = (struct proginfo *) malloc (sizeof (struct proginfo)); prog = (struct proginfo *) xmalloc (sizeof (struct proginfo));
if (prog == NULL) if (prog == NULL)
return "NO MEMORY.2"; return "NO MEMORY.2";
@ -1165,7 +1165,7 @@ kill_rp(struct conninfo *conn, char whatnot)
if(maskmatch(pro->mask,conn->cg->mask) == 0) continue; if(maskmatch(pro->mask,conn->cg->mask) == 0) continue;
if(classmatch(pro->cclass,conn->cg->cclass) == NULL) continue; if(classmatch(pro->cclass,conn->cg->cclass) == NULL) continue;
xconn = malloc(sizeof(*xconn)); xconn = xmalloc(sizeof(*xconn));
if(xconn != NULL) { if(xconn != NULL) {
bzero(xconn,sizeof(*xconn)); bzero(xconn,sizeof(*xconn));
xconn->seqnum = ++connseq; xconn->seqnum = ++connseq;
@ -1216,7 +1216,7 @@ run_rp(struct conninfo *conn, char what)
if(maskmatch(pr->mask,sub) == 0) continue; if(maskmatch(pr->mask,sub) == 0) continue;
if(classmatch(pr->cclass,cla) == NULL) continue; if(classmatch(pr->cclass,cla) == NULL) continue;
xconn = malloc(sizeof(*xconn)); xconn = xmalloc(sizeof(*xconn));
if(xconn != NULL) { if(xconn != NULL) {
bzero(xconn,sizeof(*xconn)); bzero(xconn,sizeof(*xconn));
xconn->seqnum = ++connseq; xconn->seqnum = ++connseq;
@ -1301,7 +1301,7 @@ printf("run %s:%s; ",what->site,what->protocol);
kill_rp(conn,'t'); kill_rp(conn,'t');
run_rp(conn,'i'); run_rp(conn,'i');
} else if(err != NULL) { } else if(err != NULL) {
conn = malloc(sizeof(*conn)); conn = xmalloc(sizeof(*conn));
if(conn != NULL) { if(conn != NULL) {
bzero(conn,sizeof(*conn)); bzero(conn,sizeof(*conn));
conn->seqnum = ++connseq; conn->seqnum = ++connseq;

View File

@ -227,7 +227,8 @@ dump_one_hdr (isdn23_hdr hdr)
(hdr->hdr_attach.listen & 2) ? " force" : ""); (hdr->hdr_attach.listen & 2) ? " force" : "");
break; break;
case HDR_DETACH: case HDR_DETACH:
printf ("Detach port %d, errno %d, force %d", hdr->hdr_detach.minor, printf ("Detach chan %d/%d from port %d, errno %d, force %d",
hdr->hdr_detach.card, hdr->hdr_detach.chan, hdr->hdr_detach.minor,
hdr->hdr_detach.error,hdr->hdr_detach.perm); hdr->hdr_detach.error,hdr->hdr_detach.perm);
break; break;
case HDR_CARD: case HDR_CARD:

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
PATH=/usr/local/isdn/bin-$(uname -r):/usr/local/isdn/bin:.:/sbin:/usr/sbin:$PATH
set -e set -e
PATH=/usr/local/isdn/bin-$(uname -r):/usr/local/isdn/bin:/usr/sbin:/sbin:/usr/lcoal/bin:/usr/bin:/bin
if lsmod | grep isdn_2 >/dev/null 2>&1 ; then : ; else if lsmod | grep isdn_2 >/dev/null 2>&1 ; then : ; else
cd /lib/modules/$(uname -r) cd /lib/modules/$(uname -r)
@ -12,9 +12,13 @@ if lsmod | grep isdn_2 >/dev/null 2>&1 ; then : ; else
done < ../modules.isdn > symbols.isdn done < ../modules.isdn > symbols.isdn
/bin/echo "\rISDN Modules...done. " /bin/echo "\rISDN Modules...done. "
fi fi
cd /usr/local/isdn
cd bin-$(uname -r) || cd bin cd /var/tmp
## /usr might be write protected and the debugging person
# might want to have coredumps. So I provide them.
ulimit -c 40000
# ulimit -d 20000
# monitor -b >>/var/log/acct/ip & # monitor -b >>/var/log/acct/ip &