diff -ruN radiusd-cistron-1.6.2-stable/src/Makefile radiusd-cistron-1.6.2-tea/src/Makefile --- radiusd-cistron-1.6.2-stable/src/Makefile Sun Sep 19 00:10:41 1999 +++ radiusd-cistron-1.6.2-tea/src/Makefile Sat Jan 22 10:26:02 2000 @@ -14,7 +14,7 @@ endif CC = gcc -CFLAGS = -Wall -g # -DNOSHADOW +CFLAGS = -Wall -g -DREDSTONE_HACK # -DNOSHADOW LDFLAGS = # -s # tatic LIBS = $(LSHADOW) diff -ruN radiusd-cistron-1.6.2-stable/src/acct.c radiusd-cistron-1.6.2-tea/src/acct.c --- radiusd-cistron-1.6.2-stable/src/acct.c Tue Sep 28 14:30:07 1999 +++ radiusd-cistron-1.6.2-tea/src/acct.c Tue Jan 25 14:31:09 2000 @@ -96,6 +96,48 @@ return res; } +#ifdef REDSTONE_HACK +/* + * The Redstone BBRAS RX700 and RX1400 series do not include + * a NAS-Port-ID, but as of firmware 1.2.0 the accounting + * packets include a Acct-Session-Id with the needed info: + * + * Acct-Session-Id = "erx atm 5/0:0.129:00007f0c" + * IF VPI VCI + * + * This is encoded as a NAS-Port-ID of [VPI][2 VCI][IF] + */ +void redstone_calc_port(AUTH_REQ *authreq) +{ + VALUE_PAIR *vp, *p; + int ifa, subif, vpi, vci; + int port; + + if ((p = pairfind(authreq->request, PW_NAS_PORT_ID)) != NULL) + return; + if ((p = pairfind(authreq->request, PW_ACCT_SESSION_ID)) == NULL) + return; + if (sscanf(p->strvalue, "erx atm %d/%d:%d.%d:", &ifa, &subif, + &vpi, &vci) != 4) return; + port = ((vpi & 0xff) << 24) | ((vci & 0xffff) << 8) | + ((ifa & 0x1f) << 4) | (subif & 0x1f); + + if ((vp = malloc(sizeof(VALUE_PAIR))) == NULL) { + log(L_CONS|L_ERR, "no memory"); + exit(1); + } + memset(vp, 0, sizeof(VALUE_PAIR)); + strcpy(vp->name, "NAS-Port-ID"); + vp->attribute = PW_NAS_PORT_ID; + vp->type = PW_TYPE_INTEGER; + vp->lvalue = port; + + vp->next = p->next; + p->next = vp; + + return; +} +#endif /* REDSTONE_HACK */ /* * Convert a struct radutmp to a normal struct utmp @@ -359,6 +403,17 @@ if (off < 0) off = 0; memcpy(ut.session_id, vp->strvalue + off, sizeof(ut.session_id)); +#ifdef REDSTONE_HACK + /* format: erx atm 5/0:0.128:00007fd0 */ + if (!strncmp(vp->strvalue, "erx atm ", 8)) { + char *p; + strNcpy(ut.caller_id, vp->strvalue + 8, + sizeof(ut.caller_id)); + p = strchr(ut.caller_id, ':'); + if (p) p = strchr(p + 1, ':'); + if (p) *p = 0; + } +#endif /* REDSTONE_HACK */ break; case PW_NAS_PORT_TYPE: if (vp->lvalue >= 0 && vp->lvalue <= 4) @@ -703,6 +758,10 @@ authfree(authreq); return -1; } + +#ifdef REDSTONE_HACK + redstone_calc_port(authreq); +#endif if (log_stripped_names) { /* --- radiusd-cistron-1.6.2-stable/src/version.c Wed Jan 19 15:43:46 2000 +++ radiusd-cistron-1.6.2-tea/src/version.c Sat Jan 22 10:25:47 2000 @@ -67,6 +67,9 @@ #if defined(SPECIALIX_JETSTREAM_HACK) fprintf(stderr," SPECIALIX_JETSTREAM_HACK"); #endif +#if defined(REDSTONE_HACK) + fprintf(stderr," REDSTONE_HACK"); +#endif #if defined(NOCASE) fprintf(stderr," NOCASE"); #endif