/*------------------------------------------------------------------------ * getiname - get name of this host and place it where specified *------------------------------------------------------------------------ */ int getiname(int ifn, char *nam) { struct netif *intf; IPaddr myaddr; char *p; if (ifn < 0 || ifn >= Net.nif) return SYSERR; intf = &nif[ifn]; *nam = NULLCH; if (!intf->ni_nvalid) { myaddr = getiaddr(ifn); if (ip2name(myaddr, intf->ni_name) == (char *)SYSERR) return SYSERR; intf->ni_nvalid = TRUE; } for (p=intf->ni_name ; p && *p != NULLCH; ) *nam++ = *p++; *nam = NULLCH; return OK; }
Pf * orbclients2pf( double atime, Orbclient *clients, int nclients ) { Orbclient *aclient; Pf *pf; Pf *pfclients; Pf *clientpf; int iclient; char thread[STRSZ]; char name[STRSZ]; char perm_string[2]; char *ptr; struct in_addr in; double latency_sec; pf = pfnew( PFFILE ); pfput_time( pf, "client_when", atime ); pfclients = pfnew( PFARR ); for( iclient = 0; iclient < nclients; iclient++ ) { clientpf = pfnew( PFARR ); aclient = &clients[iclient]; pfput_time( clientpf, "lastpkt", aclient->lastpkt ); pfput_time( clientpf, "started", aclient->started ); pfput_int( clientpf, "read", aclient->read ); pfput_int( clientpf, "pid", aclient->pid ); pfput_int( clientpf, "bytes", aclient->bytes ); pfput_int( clientpf, "packets", aclient->packets ); pfput_int( clientpf, "pktid", aclient->pktid ); pfput_int( clientpf, "port", aclient->port ); memcpy( &in.s_addr, &aclient->address, sizeof( struct in_addr ) ); pfput_string( clientpf, "address", inet_ntoa( in ) ); ip2name( in.s_addr, name ); pfput_string( clientpf, "name", name ); pfput_int( clientpf, "thread", aclient->thread ); pfput_int( clientpf, "fd", aclient->fd ); pfput_int( clientpf, "nreject", aclient->nreject ); pfput_int( clientpf, "nselect", aclient->nselect ); pfput_int( clientpf, "errors", aclient->errors ); pfput_int( clientpf, "priority", aclient->priority ); pfput_int( clientpf, "lastrequest", aclient->lastrequest ); pfput_int( clientpf, "mymessages", aclient->mymessages ); pfput_int( clientpf, "nrequests", aclient->nrequests ); pfput_int( clientpf, "nwrites", aclient->nwrites ); pfput_int( clientpf, "nreads", aclient->nreads ); pfput_int( clientpf, "written", aclient->written ); perm_string[0] = aclient->perm; perm_string[1] = '\0'; pfput_string( clientpf, "perm", perm_string ); pfput_string( clientpf, "what", aclient->what ); pfput_string( clientpf, "host", aclient->host ); pfput_string( clientpf, "who", aclient->who ); pfput_string( clientpf, "select", aclient->select ); pfput_string( clientpf, "reject", aclient->reject ); if( aclient->lastpkt > 0 ) { latency_sec = atime - aclient->lastpkt; pfput_double( clientpf, "latency_sec", latency_sec ); } sprintf( thread, "%d", aclient->thread ); pfput( pfclients, thread, clientpf, PFPF ); } pfput( pf, "clients", pfclients, PFPF ); return pf; }