32 static const char ID_sccs[] =
"@(#)pmf.c 1.37 97/08/04 (C) SK " ;
37 static const struct s_p_tab* smt_get_ptab(
u_short para);
38 static int smt_mib_phys(
struct s_smc *
smc);
42 int index,
int local);
45 static int port_to_mib(
struct s_smc *
smc,
int p);
47 #define MOFFSS(e) offsetof(struct fddi_mib, e)
48 #define MOFFMS(e) offsetof(struct fddi_mib_m, e)
49 #define MOFFAS(e) offsetof(struct fddi_mib_a, e)
50 #define MOFFPS(e) offsetof(struct fddi_mib_p, e)
58 #define MS2BCLK(x) ((x)*12500L)
71 static const struct s_p_tab {
128 { SMT_P10F2,
AC_GR,
MOFFSS(fddiESSPayload),
"lL" } ,
129 { SMT_P10F3,
AC_GR,
MOFFSS(fddiESSOverhead),
"lL" } ,
130 { SMT_P10F4,
AC_GR,
MOFFSS(fddiESSMaxTNeg),
"lL" } ,
131 { SMT_P10F5,
AC_GR,
MOFFSS(fddiESSMinSegmentSize),
"lL" } ,
132 { SMT_P10F6,
AC_GR,
MOFFSS(fddiESSCategory),
"lL" } ,
133 { SMT_P10F7,
AC_GR,
MOFFSS(fddiESSSynchTxMode),
"wS" } ,
136 { SMT_P10F8,
AC_GR,
MOFFSS(fddiSBACommand),
"bF" } ,
137 { SMT_P10F9,
AC_GR,
MOFFSS(fddiSBAAvailable),
"bF" } ,
287 DB_SMT(
"SMT: processing PMF frame at %x len %d\n",sm,mb->
sm_len) ;
299 reply = smt_build_pmf_response(smc,sm,
318 const struct s_p_tab *pt ;
348 pcon.pc_p = (
void *) (smt + 1) ;
355 if (!local && smt_authorize(smc,req))
357 else if (smt_check_set_count(smc,req))
371 pcon.pc_err =
error ;
373 pa = (
struct smt_para *) (req + 1) ;
377 while (!pcon.pc_err && len > 0 ) {
383 if (((range = (pa->
p_type & 0xf000)) == 0x2000) ||
384 range == 0x3000 || range == 0x4000) {
390 if (!
set && (pa->
p_len != 4)) {
394 if (!index && !
set) {
398 idx_end = index - 1 +
NUMMACS ;
406 idx_end = index - 1 +
NUMPHYS ;
419 if (!
set && (pa->
p_len != 0)) {
426 while (index <= idx_end) {
431 pt = smt_get_ptab(pa->
p_type) ;
432 if (pt && pt->p_access ==
AC_GROUP && !
set) {
434 while (pt->p_access ==
AC_G ||
435 pt->p_access ==
AC_GR) {
449 if (pcon.pc_badset) {
454 st = smt_set_para(smc,pa,index,local,1);
463 if (pt && pt->p_access ==
AC_S) {
482 res->
rdf_reason = pcon.pc_badset ? pcon.pc_badset :
490 smc->
mib.fddiSMTSetCount.count++ ;
492 smc->
mib.fddiSMTLastSetStationId = req->
smt_sid ;
508 p = (
char *) &smc->
mib.fddiPRPMFStation ;
509 for (i = 0 ; i < 8 && !p[
i] ; i++)
513 (
char *) &smc->
mib.fddiPRPMFStation,8))
519 p = (
char *) smc->
mib.fddiPRPMFPasswd ;
520 for (i = 0 ; i < 8 && !p[
i] ; i++)
528 if (
memcmp((
char *)(pa+1),(
char *)smc->
mib.fddiPRPMFPasswd,8))
534 static int smt_check_set_count(
struct s_smc *smc,
struct smt_header *sm)
542 if ((smc->
mib.fddiSMTSetCount.count != sc->
count) ||
543 memcmp((
char *) smc->
mib.fddiSMTSetCount.timestamp,
551 int index,
int local)
554 const struct s_p_tab *pt ;
555 struct fddi_mib_m *mib_m =
NULL;
556 struct fddi_mib_p *mib_p =
NULL;
579 pt = smt_get_ptab(para) ;
580 if (pt && pt->p_access ==
AC_S)
583 to = (
char *) (pcon->
pc_p) ;
592 if (((range = (para & 0xf000)) == 0x2000) ||
593 range == 0x3000 || range == 0x4000) {
612 mib_addr = (
char *) (&smc->
mib) ;
619 mib_addr = (
char *) (&smc->
mib.m[mac]) ;
620 mib_m = (
struct fddi_mib_m *) mib_addr ;
627 mib_addr = (
char *) (&smc->
mib.a[path]) ;
634 mib_addr = (
char *) (&smc->
mib.p[port_to_mib(smc,port)]) ;
635 mib_p = (
struct fddi_mib_p *) mib_addr ;
672 mib_p->fddiPORTPC_LS =
LS2MIB(
685 swap =
"IIIIIIIIIIII" ;
694 swap =
"IIIIIIIIIIIIIIIIIIIIIIII" ;
720 smc->
mib.m[
MAC0].fddiMACDuplicateAddressCond ;
725 mib_m->fddiMACSMTAddress ;
727 mib_m->fddiMACUpstreamNbr ;
737 mib_m->fddiMACFrameErrorFlag ;
739 mib_m->fddiMACFrame_Ct ;
741 mib_m->fddiMACError_Ct ;
743 mib_m->fddiMACLost_Ct ;
745 mib_m->fddiMACFrameErrorRatio ;
754 mib_m->fddiMACNotCopiedFlag ;
756 mib_m->fddiMACNotCopied_Ct ;
758 mib_m->fddiMACCopied_Ct ;
760 mib_m->fddiMACNotCopiedRatio ;
769 mib_m->fddiMACMultiple_N ;
771 mib_m->fddiMACDuplicateAddressCond ;
773 mib_m->fddiMACOldUpstreamNbr ;
775 mib_m->fddiMACUpstreamNbr ;
777 mib_m->fddiMACOldDownstreamNbr ;
779 mib_m->fddiMACDownstreamNbr ;
781 mib_m->fddiMACCurrentPath ;
783 mib_m->fddiMACSMTAddress ;
792 mib_m->fddiMACMultiple_P ;
794 mib_m->fddiMACAvailablePaths ;
796 mib_m->fddiMACCurrentPath ;
798 mib_m->fddiMACRequestedPaths ;
807 mib_p->fddiPORTLerFlag ;
810 mib_p->fddiPORTLer_Cutoff ;
812 mib_p->fddiPORTLer_Alarm ;
814 mib_p->fddiPORTLer_Estimate ;
816 mib_p->fddiPORTLem_Reject_Ct ;
818 mib_p->fddiPORTLem_Ct ;
828 mib_p->fddiPORTMultiple_U ;
830 mib_p->fddiPORTMy_Type ;
832 mib_p->fddiPORTConnectState ;
834 mib_p->fddiPORTNeighborType ;
836 mib_p->fddiPORTPC_Withhold ;
845 mib_p->fddiPORTEB_Condition ;
847 mib_p->fddiPORTEBError_Ct ;
856 mib_p->fddiPORTMultiple_P ;
858 mib_p->fddiPORTAvailablePaths ;
860 mib_p->fddiPORTCurrentPath ;
862 (
char *) mib_p->fddiPORTRequestedPaths,4) ;
864 mib_p->fddiPORTMy_Type ;
866 mib_p->fddiPORTNeighborType ;
884 switch (pt->p_access) {
892 from = mib_addr + pt->p_offset ;
899 while ((c = *swap++)) {
997 memcpy((
char *) to+2,(
char *) from,6) ;
1005 memcpy((
char *) to,(
char *) from,8) ;
1013 memcpy((
char *) to,(
char *) from,32) ;
1046 to += 4 - (len & 3 ) ;
1054 pcon->
pc_p = (
void *) to ;
1075 static int smt_set_para(
struct s_smc *smc,
struct smt_para *pa,
int index,
1078 #define IFSET(x) if (set) (x)
1080 const struct s_p_tab *pt ;
1088 struct fddi_mib_m *mib_m =
NULL;
1089 struct fddi_mib_a *mib_a =
NULL;
1090 struct fddi_mib_p *mib_p =
NULL;
1102 from = (
char *) (pa + 1 ) ;
1105 switch (pa->
p_type & 0xf000) {
1108 mib_addr = (
char *) mib ;
1114 mib_m = &smc->
mib.m[
mac] ;
1115 mib_addr = (
char *) mib_m ;
1124 mib_addr = (
char *) mib_a ;
1132 mib_p = &smc->
mib.p[port_to_mib(smc,port)] ;
1133 mib_addr = (
char *) mib_p ;
1158 pt = smt_get_ptab(pa->
p_type) ;
1162 switch (pt->p_access) {
1169 to = mib_addr + pt->p_offset ;
1172 while (swap && (c = *swap++)) {
1175 to = (
char *) &byte_val ;
1178 to = (
char *) &word_val ;
1181 to = (
char *) &long_val ;
1190 if (from[0] | from[1])
1192 #ifdef LITTLE_ENDIAN
1214 if (from[0] | from[1] | from[2])
1227 #ifdef LITTLE_ENDIAN
1311 if (word_val < 2 || word_val > 30)
1325 if (long_val < (
long)0x478bf51L)
1331 if (long_val > 1562)
1333 if (
set && smc->
mib.fddiESSPayload != long_val) {
1334 smc->ess.raf_act_timer_poll =
TRUE ;
1335 smc->
mib.fddiESSPayload = long_val ;
1339 if (long_val < 50 || long_val > 5000)
1341 if (
set && smc->
mib.fddiESSPayload &&
1342 smc->
mib.fddiESSOverhead != long_val) {
1343 smc->ess.raf_act_timer_poll =
TRUE ;
1344 smc->
mib.fddiESSOverhead = long_val ;
1350 IFSET(mib->fddiESSMaxTNeg = long_val) ;
1353 if (long_val < 1 || long_val > 4478)
1355 IFSET(mib->fddiESSMinSegmentSize = long_val) ;
1358 if ((long_val & 0xffff) != 1)
1360 IFSET(mib->fddiESSCategory = long_val) ;
1365 IFSET(mib->fddiESSSynchTxMode = word_val) ;
1372 IFSET(mib->fddiSBACommand = byte_val) ;
1377 IFSET(mib->fddiSBAAvailable = byte_val) ;
1384 IFSET(mib_m->fddiMACRequestedPaths = word_val) ;
1388 IFSET(mib_m->fddiMACFrameErrorThreshold = word_val) ;
1392 IFSET(mib_m->fddiMACNotCopiedThreshold = word_val) ;
1398 mib_m->fddiMACMA_UnitdataEnable = byte_val ;
1403 IFSET(mib_m->fddiMACT_Min = long_val) ;
1406 if (long_val > 1562)
1408 IFSET(mib_a->fddiPATHSbaPayload = long_val) ;
1411 ess_para_change(smc) ;
1415 if (long_val > 5000)
1418 if (long_val != 0 && mib_a->fddiPATHSbaPayload == 0)
1421 IFSET(mib_a->fddiPATHSbaOverhead = long_val) ;
1424 ess_para_change(smc) ;
1432 mib_a->fddiPATHT_Rmode = long_val ;
1437 if (long_val > 0x00BEBC20L)
1440 if (
set && mib->fddiSBACommand ==
SB_STOP)
1443 IFSET(mib_a->fddiPATHSbaAvailable = long_val) ;
1446 IFSET(mib_a->fddiPATHTVXLowerBound = long_val) ;
1447 goto change_mac_para ;
1449 IFSET(mib_a->fddiPATHT_MaxLowerBound = long_val) ;
1450 goto change_mac_para ;
1452 IFSET(mib_a->fddiPATHMaxT_Req = long_val) ;
1457 smc->
sm.please_reconnect = 1 ;
1464 IFSET(mib_p->fddiPORTConnectionPolicies = byte_val) ;
1468 IFSET(
memcpy((
char *)mib_p->fddiPORTRequestedPaths,
1469 (
char *)&long_val,4)) ;
1474 IFSET(mib_p->fddiPORTMaint_LS = word_val) ;
1477 if (byte_val < 4 || byte_val > 15)
1479 IFSET(mib_p->fddiPORTLer_Cutoff = byte_val) ;
1482 if (byte_val < 4 || byte_val > 15)
1484 IFSET(mib_p->fddiPORTLer_Alarm = byte_val) ;
1496 port_to_mib(smc,port)))
1523 static const struct s_p_tab *smt_get_ptab(
u_short para)
1525 const struct s_p_tab *pt ;
1526 for (pt = p_tab ; pt->p_num && pt->p_num != para ; pt++)
1528 return pt->p_num ? pt :
NULL;
1531 static int smt_mib_phys(
struct s_smc *smc)
1544 static int port_to_mib(
struct s_smc *smc,
int p)
1567 #ifdef LITTLE_ENDIAN
1574 if (smc->debug.d_smtf < 2)
1576 if (
debug.d_smtf < 2)
1579 #ifdef LITTLE_ENDIAN
1582 printf(
"SMT Frame [%s]:\nDA ",text) ;
1583 dump_hex((
char *) &sm->
smt_dest,6) ;
1586 printf(
" Class %x Type %x Version %x\n",
1589 dump_hex((
char *) &sm->
smt_sid,8) ;
1593 pa = (
struct smt_para *) (sm + 1) ;
1602 if ( (n < 0 ) || (n > (
int)(len -
PARA_LEN))) {
1604 printf(
" BAD LENGTH\n") ;
1607 #ifdef LITTLE_ENDIAN
1611 dump_hex((
char *)(pa+1),(
int) n) ;
1616 c = (
char *)(pa+1) ;
1622 nn = (n > 16) ? 16 : n ;
1637 #ifdef LITTLE_ENDIAN
1644 printf(
"-------------------------------------------------\n\n") ;
1647 void dump_hex(
char *p,
int len)
1653 printf(
"%x%s",*p++ & 0xff,len ? ( (n & 7) ?
" " :
"-") :
"") ;
1655 printf(
"%02x%s",*p++ & 0xff,len ? ( (n & 7) ?
" " :
"-") :
"") ;