static void id_clients( Pf *pf ) { Pf *pfclients; Pf *pfclient; char client_summary[STRSZ]; char *serveraddress; char *serverport; Tbl *client_keys; int ikey; char *client_key; char clientid_key[STRSZ]; char *clientaddress; char *what; char clientid[33]; pfeval( pf, "server{address}", &serveraddress ); pfeval( pf, "server{port}", &serverport ); pfget( pf, "clients", (void **) &pfclients ); client_keys = pfkeys( pfclients ); for( ikey = 0; ikey < maxtbl( client_keys ); ikey++ ) { client_key = gettbl( client_keys, ikey ); pfget( pfclients, client_key, (void **) &pfclient ); clientaddress = pfget_string( pfclient, "address" ); what = pfget_string( pfclient, "what" ); sprintf( client_summary, "%s %s %s %s", serveraddress, serverport, clientaddress, what ); sprintf( clientid_key, "clients{%s}{clientid}", client_key ); mdhex( clientid, client_summary, strlen( client_summary ) ); pfset( pf, clientid_key, clientid ); } freetbl( client_keys, 0 ); return; }
static void pfmorph( Pf *pf ) { Pf *dlspf; Pf *stapf; Tbl *stas; int ista; char *sta; char *opt_string; if( pfget( pf, "dls", (void **) &dlspf ) == PFINVALID ) { return; } stas = pfkeys( dlspf ); for( ista = 0; ista < maxtbl( stas ); ista++ ) { sta = gettbl( stas, ista ); if( pfget( dlspf, sta, (void **) &stapf ) == PFINVALID ) { continue; } if( ( opt_string = pfget_string( stapf, "opt" ) ) == (char *) NULL || ! strcmp( opt_string, "-" ) ) { pfset( stapf, "acok", "-" ); pfset( stapf, "api", "-" ); pfset( stapf, "isp1", "-" ); pfset( stapf, "isp2", "-" ); pfset( stapf, "ti", "-" ); } else { if( strcontains( opt_string, "acok", NULL, NULL, NULL ) ) { pfset( stapf, "acok", "1" ); } else { pfset( stapf, "acok", "0" ); } if( strcontains( opt_string, "api", NULL, NULL, NULL ) ) { pfset( stapf, "api", "1" ); } else { pfset( stapf, "api", "0" ); } if( strcontains( opt_string, "isp1", NULL, NULL, NULL ) ) { pfset( stapf, "isp1", "1" ); } else { pfset( stapf, "isp1", "0" ); } if( strcontains( opt_string, "isp2", NULL, NULL, NULL ) ) { pfset( stapf, "isp2", "1" ); } else { pfset( stapf, "isp2", "0" ); } if( strcontains( opt_string, "ti", NULL, NULL, NULL ) ) { pfset( stapf, "ti", "1" ); } else { pfset( stapf, "ti", "0" ); } } } freetbl( stas, 0 ); return; }