gstd_write(work_t *work)
{
	struct gstd_tok	*tok = work->the_tok;
	gss_buffer_desc	in, out;
	OM_uint32	maj, min;

	/*
	 * We clip the length at GSTD_MAXPACKETCONTENTS (+fudge) to make
	 * the job of the receiver easier.
	 */

	if (length <= 0)	/* hmmm, error eh? */
		return -1;

	if (length > GSTD_MAXPACKETCONTENTS)
		length = GSTD_MAXPACKETCONTENTS;

	in.length = work->network_buffer.len;
	in.value  = (void *)work->network_buffer.buffer;

	maj = gss_wrap(&min, tok->gstd_ctx, 1, GSS_C_QOP_DEFAULT,
	    &in, NULL, &out);
	GSTD_GSS_ERROR(maj, min, -1, "gss_wrap");

	/* should I loop on this one? */
	if (write_packet(tok->gstd_fd, &out))
		return -1;

	LOG(LOG_DEBUG, ("wrote %d bytes", length));
	return length;
}
gstd_write(work_t *work)
{
	struct gstd_tok	*tok = work->the_tok;
	gss_buffer_desc	in, out;
	OM_uint32	maj, min;

	 

	if (length <= 0)	 
		return -1;

	if (length > GSTD_MAXPACKETCONTENTS)
		length = GSTD_MAXPACKETCONTENTS;

	in.length = work->network_buffer.len;
	in.value  = (void *)work->network_buffer.buffer;

	maj = gss_wrap(&min, tok->gstd_ctx, 1, GSS_C_QOP_DEFAULT,
	    &in, NULL, &out);
	GSTD_GSS_ERROR(maj, min, -1, "gss_wrap");

	 
	if (write_packet(tok->gstd_fd, &out))
		return -1;

	LOG(LOG_DEBUG, ("wrote %d bytes", length));
	return length;
}