l += sprintf(buffer + l, "halviv");
l += sprintf(buffer + l, "halfiv");
ipsp_kern(int off, char **bufp, int len){    static char buffer[IPSEC_KERNFS_BUFSIZE];    struct flow *flow;    struct tdb *tdb;    int l, i;    if (off == 0)      kernfs_epoch++;        if (bufp == NULL)      return 0;    bzero(buffer, IPSEC_KERNFS_BUFSIZE);    *bufp = buffer;        for (i = 0; i < TDB_HASHMOD; i++)      for (tdb = tdbh[i]; tdb; tdb = tdb->tdb_hnext)	if (tdb->tdb_epoch != kernfs_epoch)	{	    tdb->tdb_epoch = kernfs_epoch;	    l = sprintf(buffer, "SPI = %08x, Destination = %s, Sproto = %u\n",			ntohl(tdb->tdb_spi),			ipsp_address(tdb->tdb_dst), tdb->tdb_sproto);	    l += sprintf(buffer + l, "\tEstablished %d seconds ago\n",			 time.tv_sec - tdb->tdb_established);	    l += sprintf(buffer + l, "\tSource = %s",			 ipsp_address(tdb->tdb_src));	    if (tdb->tdb_proxy.sa.sa_family)	      l += sprintf(buffer + l, ", Proxy = %s\n",			   ipsp_address(tdb->tdb_proxy));	    else	      l += sprintf(buffer + l, "\n");	    l += sprintf(buffer + l, "\tFlags (%08x) = <", tdb->tdb_flags);	    if ((tdb->tdb_flags & ~(TDBF_TIMER | TDBF_BYTES |				    TDBF_ALLOCATIONS | TDBF_FIRSTUSE |				    TDBF_SOFT_TIMER | TDBF_SOFT_BYTES |				    TDBF_SOFT_FIRSTUSE |				    TDBF_SOFT_ALLOCATIONS)) == 0)	      l += sprintf(buffer + l, "none>\n");	    else	    {		/* We can reuse variable 'i' here, since we're not looping */		i = 0;		if (tdb->tdb_flags & TDBF_UNIQUE)		{		    if (i)		      l += sprintf(buffer + l, ", ");		    else		      i = 1;		    l += sprintf(buffer + l, "unique");		    i = 1;		}		if (tdb->tdb_flags & TDBF_INVALID)		{		    if (i)		      l += sprintf(buffer + l, ", ");		    else		      i = 1;		    l += sprintf(buffer + l, "invalid");		}		if (tdb->tdb_flags & TDBF_HALFIV)		{		    if (i)		      l += sprintf(buffer + l, ", ");		    else		      i = 1;		    l += sprintf(buffer + l, "halviv");		}		if (tdb->tdb_flags & TDBF_PFS)		{		    if (i)		      l += sprintf(buffer + l, ", ");		    else		      i = 1;		    l += sprintf(buffer + l, "pfs");		}		if (tdb->tdb_flags & TDBF_TUNNELING)		{		    if (i)		      l += sprintf(buffer + l, ", ");		    else		      i = 1;		    l += sprintf(buffer + l, "tunneling");		}		l += sprintf(buffer + l, ">\n");	    }	    if (tdb->tdb_xform)	      l += sprintf(buffer + l, "\txform = <%s>\n", 			   tdb->tdb_xform->xf_name);	    if (tdb->tdb_encalgxform)	      l += sprintf(buffer + l, "\t\tEncryption = <%s>\n",			   tdb->tdb_encalgxform->name);	    if (tdb->tdb_authalgxform)	      l += sprintf(buffer + l, "\t\tAuthentication = <%s>\n",			   tdb->tdb_authalgxform->name);	    if (tdb->tdb_onext)	      l += sprintf(buffer + l,			   "\tNext SA: SPI = %08x, "			   "Destination = %s, Sproto = %u\n",			   ntohl(tdb->tdb_onext->tdb_spi),			   ipsp_address(tdb->tdb_onext->tdb_dst),			   tdb->tdb_onext->tdb_sproto);	    if (tdb->tdb_inext)	      l += sprintf(buffer + l,			   "\tPrevious SA: SPI = %08x, "			   "Destination = %s, Sproto = %u\n",			   ntohl(tdb->tdb_inext->tdb_spi),			   ipsp_address(tdb->tdb_inext->tdb_dst),			   tdb->tdb_inext->tdb_sproto);	    for (i = 0, flow = tdb->tdb_flow; flow; flow = flow->flow_next)	      i++;	    l+= sprintf(buffer + l, "\tCurrently used by %d flows\n", i);	    l += sprintf(buffer + l, "\t%u flows have used this SA\n",			 tdb->tdb_cur_allocations);	    	    l += sprintf(buffer + l, "\t%qu bytes processed by this SA\n",			 tdb->tdb_cur_bytes);	    	    l += sprintf(buffer + l, "\tExpirations:\n");	    if (tdb->tdb_flags & TDBF_TIMER)	      l += sprintf(buffer + l,			   "\t\tHard expiration(1) in %qu seconds\n",			   tdb->tdb_exp_timeout - time.tv_sec);	    	    if (tdb->tdb_flags & TDBF_SOFT_TIMER)	      l += sprintf(buffer + l,			   "\t\tSoft expiration(1) in %qu seconds\n",			   tdb->tdb_soft_timeout - time.tv_sec);	    	    if (tdb->tdb_flags & TDBF_BYTES)	      l += sprintf(buffer + l, "\t\tHard expiration after %qu bytes\n",			   tdb->tdb_exp_bytes);	    	    if (tdb->tdb_flags & TDBF_SOFT_BYTES)	      l += sprintf(buffer + l, "\t\tSoft expiration after %qu bytes\n",			   tdb->tdb_soft_bytes);	    if (tdb->tdb_flags & TDBF_ALLOCATIONS)	      l += sprintf(buffer + l,			   "\t\tHard expiration after %u flows\n",			   tdb->tdb_exp_allocations);	    	    if (tdb->tdb_flags & TDBF_SOFT_ALLOCATIONS)	      l += sprintf(buffer + l,			   "\t\tSoft expiration after %u flows\n",			   tdb->tdb_soft_allocations);	    if (tdb->tdb_flags & TDBF_FIRSTUSE)	    {		if (tdb->tdb_first_use)		l += sprintf(buffer + l,			     "\t\tHard expiration(2) in %qu seconds\n",			     (tdb->tdb_first_use + tdb->tdb_exp_first_use) -			     time.tv_sec);		else		l += sprintf(buffer + l,			     "\t\tHard expiration in %qu seconds after first "			     "use\n", tdb->tdb_exp_first_use);	    }	    if (tdb->tdb_flags & TDBF_SOFT_FIRSTUSE)	    {	        if (tdb->tdb_first_use)		  l += sprintf(buffer + l,			       "\t\tSoft expiration(2) in %qu seconds\n",			       (tdb->tdb_first_use + tdb->tdb_soft_first_use) -			       time.tv_sec);	        else		  l += sprintf(buffer + l,			       "\t\tSoft expiration in %qu seconds after first "			       "use\n", tdb->tdb_soft_first_use);	    }	    if (!(tdb->tdb_flags & (TDBF_TIMER | TDBF_SOFT_TIMER | TDBF_BYTES |				    TDBF_SOFT_ALLOCATIONS | TDBF_ALLOCATIONS |				    TDBF_SOFT_BYTES | TDBF_FIRSTUSE |				    TDBF_SOFT_FIRSTUSE)))	      l += sprintf(buffer + l, "\t\t(none)\n");	    l += sprintf(buffer + l, "\n");	    	    return l;	}        return 0;}