FreeBSD/sys/netpfil/ipfw/ip_fw_sockopt.c
/*
 * Writes data accumulated in @sd to sockopt buffer.
 * Zeroes internal @sd buffer.
 */
Writes data accumulated in @sd to sockopt buffer.
Zeroes internal @sd buffer.
Writes data accumulated in @sd to sockopt buffer . Zeroes internal @sd buffer .
static int
ipfw_flush_sopt_data(struct sockopt_data *sd)
{
	struct sockopt *sopt;
	int error;
	size_t sz;
	sz = sd->koff;
	if (sz == 0)
		return (0);
	sopt = sd->sopt;
	if (sopt->sopt_dir == SOPT_GET) {
		error = copyout(sd->kbuf, sopt->sopt_val, sz);
		if (error != 0)
			return (error);
	}
	memset(sd->kbuf, 0, sd->ksize);
	sd->ktotal += sz;
	sd->koff = 0;
	if (sd->ktotal + sd->ksize < sd->valsize)
		sd->kavail = sd->ksize;
	else
		sd->kavail = sd->valsize - sd->ktotal;
	sopt->sopt_valsize = sd->ktotal;
	sopt->sopt_val = sd->sopt_val + sd->ktotal;
	return (0);
}
static int ipfw_flush_sopt_data ( struct sockopt_data * sd ) { struct sockopt * sopt ; int error ; size_t sz ; sz = sd -> koff ; if ( sz == 0 ) return ( 0 ) ; sopt = sd -> sopt ; if ( sopt -> sopt_dir == SOPT_GET ) { error = copyout ( sd -> kbuf , sopt -> sopt_val , sz ) ; if ( error != 0 ) return ( error ) ; } memset ( sd -> kbuf , 0 , sd -> ksize ) ; sd -> ktotal += sz ; sd -> koff = 0 ; if ( sd -> ktotal + sd -> ksize < sd -> valsize ) sd -> kavail = sd -> ksize ; else sd -> kavail = sd -> valsize - sd -> ktotal ; sopt -> sopt_valsize = sd -> ktotal ; sopt -> sopt_val = sd -> sopt_val + sd -> ktotal ; return ( 0 ) ; }
Writes data accumulated in @sd to sockopt buffer.
Writes data accumulated in @sd to sockopt buffer .
/* Update sopt buffer data */