Skip to content
Snippets Groups Projects
slurm_protocol_pack.c 71.1 KiB
Newer Older
	safe_unpack32(&tmp_ptr->job_id, buffer);
	return SLURM_SUCCESS;
static void
_pack_node_info_msg(slurm_msg_t * msg, Buf buffer)
	packmem_array(msg->data, msg->data_size, buffer);
static int
_unpack_node_info_msg(node_info_msg_t ** msg, Buf buffer)
jce's avatar
jce committed

	assert(msg != NULL);
	*msg = xmalloc(sizeof(node_info_msg_t));

	/* load buffer's header (data structure version and time) */
	safe_unpack32(&((*msg)->record_count), buffer);
	safe_unpack_time(&((*msg)->last_update), buffer);
	node = (*msg)->node_array =
	    xmalloc(sizeof(node_info_t) * (*msg)->record_count);
	for (i = 0; i < (*msg)->record_count; i++) {
		if (_unpack_node_info_members(&node[i], buffer))
static int
_unpack_node_info_members(node_info_t * node, Buf buffer)
tewk's avatar
 
tewk committed
{
	uint16_t uint16_tmp;

	assert(node != NULL);
	safe_unpackstr_xmalloc(&node->name, &uint16_tmp, buffer);
	safe_unpack16(&node->node_state, buffer);
	safe_unpack32(&node->cpus, buffer);
	safe_unpack32(&node->real_memory, buffer);
	safe_unpack32(&node->tmp_disk, buffer);
	safe_unpack32(&node->weight, buffer);
	safe_unpackstr_xmalloc(&node->features, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&node->partition, &uint16_tmp, buffer);
tewk's avatar
 
tewk committed

	FREE_NULL(node->name);
	FREE_NULL(node->features);
	FREE_NULL(node->partition);
tewk's avatar
 
tewk committed
}

static void
_pack_update_partition_msg(update_part_msg_t * msg, Buf buffer)
	assert(msg != NULL);
	packstr(msg->name, buffer);
	pack32(msg->max_time, buffer);
	pack32(msg->max_nodes, buffer);
	pack16(msg->default_part, buffer);
	pack16(msg->root_only, buffer);
	pack16(msg->shared, buffer);
	pack16(msg->state_up, buffer);
	packstr(msg->nodes, buffer);
	packstr(msg->allow_groups, buffer);
static int
_unpack_update_partition_msg(update_part_msg_t ** msg, Buf buffer)
	update_part_msg_t *tmp_ptr;

	assert(msg != NULL);
	/* alloc memory for structure */
	tmp_ptr = xmalloc(sizeof(update_part_msg_t));
	safe_unpackstr_xmalloc(&tmp_ptr->name, &uint16_tmp, buffer);
	safe_unpack32(&tmp_ptr->max_time, buffer);
	safe_unpack32(&tmp_ptr->max_nodes, buffer);
	safe_unpack16(&tmp_ptr->default_part, buffer);
	safe_unpack16(&tmp_ptr->root_only, buffer);
	safe_unpack16(&tmp_ptr->shared, buffer);
	safe_unpack16(&tmp_ptr->state_up, buffer);
	safe_unpackstr_xmalloc(&tmp_ptr->nodes, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&tmp_ptr->allow_groups, &uint16_tmp, buffer);
	FREE_NULL(tmp_ptr->name);
	FREE_NULL(tmp_ptr->nodes);
	FREE_NULL(tmp_ptr->allow_groups);
	FREE_NULL(tmp_ptr);
static void
_pack_job_step_create_request_msg(job_step_create_request_msg_t
				  * msg, Buf buffer)
	assert(msg != NULL);
	pack32(msg->job_id, buffer);
	pack32(msg->user_id, buffer);
	pack32(msg->node_count, buffer);
	pack32(msg->cpu_count, buffer);
	pack16(msg->relative, buffer);
	pack16(msg->task_dist, buffer);
	packstr(msg->node_list, buffer);
static int
_unpack_job_step_create_request_msg(job_step_create_request_msg_t ** msg,
				    Buf buffer)
{
	uint16_t uint16_tmp;
	job_step_create_request_msg_t *tmp_ptr;
	/* alloc memory for structure */
	assert(msg != NULL);
	tmp_ptr = xmalloc(sizeof(job_step_create_request_msg_t));
	safe_unpack32(&(tmp_ptr->job_id), buffer);
	safe_unpack32(&(tmp_ptr->user_id), buffer);
	safe_unpack32(&(tmp_ptr->node_count), buffer);
	safe_unpack32(&(tmp_ptr->cpu_count), buffer);
	safe_unpack32(&(tmp_ptr->num_tasks), buffer);

	safe_unpack16(&(tmp_ptr->relative), buffer);
	safe_unpack16(&(tmp_ptr->task_dist), buffer);
	safe_unpackstr_xmalloc(&(tmp_ptr->node_list), &uint16_tmp, buffer);
	FREE_NULL(tmp_ptr->node_list);
	FREE_NULL(tmp_ptr);
static void
_pack_revoke_credential_msg(revoke_credential_msg_t * msg, Buf buffer)
tewk's avatar
tewk committed
{
	assert(msg != NULL);
tewk's avatar
tewk committed

	pack32(msg->job_id,  buffer);
	pack32(msg->job_uid, buffer);
	pack_time(msg->expiration_time, buffer);
	packmem_array(msg->signature,
		      (uint32_t) SLURM_SSL_SIGNATURE_LENGTH, buffer);
static int
_unpack_revoke_credential_msg(revoke_credential_msg_t ** msg, Buf buffer)
tewk's avatar
tewk committed
{
	revoke_credential_msg_t *tmp_ptr;
	/* alloc memory for structure */
	assert(msg);
	tmp_ptr = xmalloc(sizeof(slurm_job_credential_t));
tewk's avatar
tewk committed

	safe_unpack32(&(tmp_ptr->job_id),  buffer);
	safe_unpack32(&(tmp_ptr->job_uid), buffer);
	safe_unpack_time(& (tmp_ptr->expiration_time), buffer);
	safe_unpackmem_array(tmp_ptr->signature,
			     (uint32_t) SLURM_SSL_SIGNATURE_LENGTH, buffer);
tewk's avatar
tewk committed

static void
_pack_update_job_time_msg(job_time_msg_t * msg, Buf buffer)
{
	assert(msg != NULL);

	pack32(msg->job_id, buffer);
	pack_time((uint32_t) msg->expiration_time, buffer);
}

static int
_unpack_update_job_time_msg(job_time_msg_t ** msg, Buf buffer)
{
	job_time_msg_t *tmp_ptr;

	/* alloc memory for structure */
	assert(msg);
	tmp_ptr = xmalloc(sizeof(job_time_msg_t));
	*msg = tmp_ptr;

	safe_unpack32(&(tmp_ptr->job_id), buffer);
	safe_unpack_time(& (tmp_ptr->expiration_time), buffer);
	return SLURM_SUCCESS;

      unpack_error:
/* pack_job_credential
 * packs a slurm job credential
 * IN cred - pointer to the credential
 * IN/OUT buffer - destination of the pack, contains pointers that are 
 *			automatically updated
 */
void
pack_job_credential(slurm_job_credential_t * cred, Buf buffer)
	assert(cred != NULL);
	pack32(cred->job_id, buffer);
	pack16((uint16_t) cred->user_id, buffer);
	packstr(cred->node_list, buffer);
	pack_time(cred->expiration_time, buffer);
	packmem_array(cred->signature,
		      (uint32_t) SLURM_SSL_SIGNATURE_LENGTH, buffer);
/* unpack_job_credential
 * unpacks a slurm job credential
 * OUT cred - pointer to the credential pointer
 * IN/OUT buffer - source of the unpack, contains pointers that are 
 *			automatically updated
 * RET 0 or error code
 */
int
unpack_job_credential(slurm_job_credential_t ** cred, Buf buffer)
{
	uint16_t uint16_tmp;
	slurm_job_credential_t *tmp_ptr;
	/* alloc memory for structure */
	tmp_ptr = xmalloc(sizeof(slurm_job_credential_t));
	*cred = tmp_ptr;
	safe_unpack32(&(tmp_ptr->job_id), buffer);
	safe_unpack16((uint16_t *) & (tmp_ptr->user_id), buffer);
	safe_unpackstr_xmalloc(&(tmp_ptr->node_list), &uint16_tmp, buffer);
	safe_unpack_time(&(tmp_ptr->expiration_time), buffer);
	safe_unpackmem_array(tmp_ptr->signature,
			     (uint32_t) SLURM_SSL_SIGNATURE_LENGTH, buffer);
	FREE_NULL(tmp_ptr->node_list);
	FREE_NULL(tmp_ptr);
static void
_pack_job_step_create_response_msg(job_step_create_response_msg_t * msg,
				   Buf buffer)
	assert(msg != NULL);
	pack32(msg->job_step_id, buffer);
	packstr(msg->node_list, buffer);
	pack_job_credential(msg->credentials, buffer);
#ifdef HAVE_LIBELAN3
	qsw_pack_jobinfo(msg->qsw_job, buffer);
static int
_unpack_job_step_create_response_msg(job_step_create_response_msg_t ** msg,
				     Buf buffer)
{
	uint16_t uint16_tmp;
	job_step_create_response_msg_t *tmp_ptr;
	/* alloc memory for structure */
	assert(msg != NULL);
	tmp_ptr = xmalloc(sizeof(job_step_create_response_msg_t));
	safe_unpack32(&tmp_ptr->job_step_id, buffer);
	safe_unpackstr_xmalloc(&tmp_ptr->node_list, &uint16_tmp, buffer);
	if (unpack_job_credential(&tmp_ptr->credentials, buffer))
	qsw_alloc_jobinfo(&tmp_ptr->qsw_job);
	if (qsw_unpack_jobinfo(tmp_ptr->qsw_job, buffer)) {
		error("qsw_unpack_jobinfo: %m");
		qsw_free_jobinfo(tmp_ptr->qsw_job);
	FREE_NULL(tmp_ptr->node_list);
	FREE_NULL(tmp_ptr);
static void
_pack_partition_info_msg(slurm_msg_t * msg, Buf buffer)
{
	packmem_array(msg->data, msg->data_size, buffer);
tewk's avatar
 
tewk committed
}

static int
_unpack_partition_info_msg(partition_info_msg_t ** msg, Buf buffer)
tewk's avatar
 
tewk committed
{
	int i;
	partition_info_t *partition = NULL;
tewk's avatar
 
tewk committed

	*msg = xmalloc(sizeof(partition_info_msg_t));
tewk's avatar
 
tewk committed

	/* load buffer's header (data structure version and time) */
	safe_unpack32(&((*msg)->record_count), buffer);
	safe_unpack_time(&((*msg)->last_update), buffer);
tewk's avatar
 
tewk committed

	partition = (*msg)->partition_array =
	    xmalloc(sizeof(partition_info_t) * (*msg)->record_count);
tewk's avatar
 
tewk committed

	/* load individual job info */
	for (i = 0; i < (*msg)->record_count; i++) {
		if (_unpack_partition_info_members(&partition[i], buffer))
	}
	return SLURM_SUCCESS;
	FREE_NULL(*msg);
	FREE_NULL(partition);
tewk's avatar
 
tewk committed
}


static int
_unpack_partition_info_members(partition_info_t * part, Buf buffer)
	char *node_inx_str = NULL;
	safe_unpackstr_xmalloc(&part->name, &uint16_tmp, buffer);
		part->name = xmalloc(1);	/* part->name = "" implicit */
	safe_unpack32(&part->max_time, buffer);
	safe_unpack32(&part->max_nodes, buffer);
	safe_unpack32(&part->total_nodes, buffer);

	safe_unpack32(&part->total_cpus, buffer);
	safe_unpack16(&part->default_part, buffer);
	safe_unpack16(&part->root_only, buffer);
	safe_unpack16(&part->shared, buffer);

	safe_unpack16(&part->state_up, buffer);
	safe_unpackstr_xmalloc(&part->allow_groups, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&part->nodes, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&node_inx_str, &uint16_tmp, buffer);
		part->node_inx = bitfmt2int("");
	else {
		part->node_inx = bitfmt2int(node_inx_str);
	FREE_NULL(part->name);
	FREE_NULL(part->allow_groups);
	FREE_NULL(part->nodes);
	FREE_NULL(node_inx_str);
/* pack_job_step_info_members
 * pack selected fields of the description of a job into a buffer
 * IN job_id, step_id, user_id, start_time, partition, nodes - job info
 * IN/OUT buffer - destination of the pack, contains pointers that are 
 *			automatically updated
 */
void
pack_job_step_info_members(uint32_t job_id, uint16_t step_id,
			   uint32_t user_id, uint32_t num_tasks,
			   time_t start_time, char *partition, 
			   char *nodes, Buf buffer)
	pack32(job_id, buffer);
	pack16(step_id, buffer);
	pack32(user_id, buffer);
	pack_time(start_time, buffer);
	packstr(partition, buffer);
	packstr(nodes, buffer);

/* pack_job_step_info
 * packs a slurm job steps info
 * IN step - pointer to the job step info
 * IN/OUT buffer - destination of the pack, contains pointers that are 
 *			automatically updated
 */
void
pack_job_step_info(job_step_info_t * step, Buf buffer)
	pack_job_step_info_members(step->job_id,
				   step->step_id,
				   step->user_id,
				   step->start_time,
				   step->partition, step->nodes, buffer);
/* _unpack_job_step_info_members
 * unpacks a set of slurm job step info for one job step
 * OUT step - pointer to the job step info buffer
 * IN/OUT buffer - source of the unpack, contains pointers that are 
 *			automatically updated
 */
static int
_unpack_job_step_info_members(job_step_info_t * step, Buf buffer)
	safe_unpack32(&step->job_id, buffer);
	safe_unpack16(&step->step_id, buffer);
	safe_unpack32(&step->user_id, buffer);
	safe_unpack32(&step->num_tasks, buffer);

	safe_unpack_time(&step->start_time, buffer);
	safe_unpackstr_xmalloc(&step->partition, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&step->nodes, &uint16_tmp, buffer);
	FREE_NULL(step->partition);
	FREE_NULL(step->nodes);
static int
_unpack_job_step_info_response_msg(job_step_info_response_msg_t
				   ** msg, Buf buffer)
	int i = 0;
	job_step_info_t *step;
	*msg = xmalloc(sizeof(job_step_info_response_msg_t));
	safe_unpack_time(&(*msg)->last_update, buffer);
	safe_unpack32(&(*msg)->job_step_count, buffer);
	step = (*msg)->job_steps =
	    xmalloc(sizeof(job_step_info_t) * (*msg)->job_step_count);

	for (i = 0; i < (*msg)->job_step_count; i++)
		if (_unpack_job_step_info_members(&step[i], buffer))
static void
_pack_buffer_msg(slurm_msg_t * msg, Buf buffer)
	packmem_array(msg->data, msg->data_size, buffer);
static int
_unpack_job_info_msg(job_info_msg_t ** msg, Buf buffer)
tewk's avatar
tewk committed
{
	int i;

	*msg = xmalloc(sizeof(job_info_msg_t));
tewk's avatar
tewk committed

	/* load buffer's header (data structure version and time) */
	safe_unpack32(&((*msg)->record_count), buffer);
	safe_unpack_time(&((*msg)->last_update), buffer);
	job = (*msg)->job_array =
	    xmalloc(sizeof(job_info_t) * (*msg)->record_count);
tewk's avatar
tewk committed

	/* load individual job info */
	for (i = 0; i < (*msg)->record_count; i++) {
		if (_unpack_job_info_members(&job[i], buffer))
	return SLURM_ERROR;
/* _unpack_job_info_members
 * unpacks a set of slurm job info for one job
 * OUT job - pointer to the job info buffer
 * IN/OUT buffer - source of the unpack, contains pointers that are 
 *			automatically updated
 */
static int
_unpack_job_info_members(job_info_t * job, Buf buffer)
tewk's avatar
tewk committed
{
	uint16_t uint16_tmp;
	char *node_inx_str;
	safe_unpack32(&job->job_id, buffer);
	safe_unpack32(&job->user_id, buffer);
	safe_unpack16(&job->job_state,  buffer);
	safe_unpack16(&job->batch_flag, buffer);
	safe_unpack32(&job->batch_sid,  buffer);
	safe_unpack32(&job->time_limit, buffer);
	safe_unpack_time(&job->start_time, buffer);
	safe_unpack_time(&job->end_time, buffer);
	safe_unpack32(&job->priority, buffer);
	safe_unpackstr_xmalloc(&job->nodes, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&job->partition, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&job->name, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&node_inx_str, &uint16_tmp, buffer);
tewk's avatar
tewk committed
	if (node_inx_str == NULL)
		job->node_inx = bitfmt2int("");
	else {
		job->node_inx = bitfmt2int(node_inx_str);
	safe_unpack32(&job->num_procs, buffer);
	safe_unpack32(&job->num_nodes, buffer);
	safe_unpack16(&job->shared, buffer);
	safe_unpack16(&job->contiguous, buffer);
	safe_unpack32(&job->min_procs, buffer);
	safe_unpack32(&job->min_memory, buffer);
	safe_unpack32(&job->min_tmp_disk, buffer);
	safe_unpackstr_xmalloc(&job->req_nodes, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&node_inx_str, &uint16_tmp, buffer);
tewk's avatar
tewk committed
	if (node_inx_str == NULL)
		job->req_node_inx = bitfmt2int("");
	else {
Moe Jette's avatar
Moe Jette committed
		job->req_node_inx = bitfmt2int(node_inx_str);
	safe_unpackstr_xmalloc(&job->features, &uint16_tmp, buffer);
	return SLURM_SUCCESS;
	FREE_NULL(job->nodes);
	FREE_NULL(job->partition);
	FREE_NULL(job->name);
	FREE_NULL(job->req_nodes);
	FREE_NULL(job->features);
	return SLURM_ERROR;
static void
_pack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t * build_ptr, Buf buffer)
{
	pack_time(build_ptr->last_update, buffer);
	packstr(build_ptr->backup_addr, buffer);
	packstr(build_ptr->backup_controller, buffer);
	packstr(build_ptr->control_addr, buffer);
	packstr(build_ptr->control_machine, buffer);
	packstr(build_ptr->epilog, buffer);
	pack16(build_ptr->fast_schedule, buffer);
	pack16(build_ptr->hash_base, buffer);
	pack16(build_ptr->heartbeat_interval, buffer);
	pack16(build_ptr->inactive_limit, buffer);
	pack16(build_ptr->kill_wait, buffer);
	packstr(build_ptr->prioritize, buffer);
	packstr(build_ptr->prolog, buffer);
	pack16(build_ptr->ret2service, buffer);
	pack16(build_ptr->slurm_user_id, buffer);
	packstr(build_ptr->slurm_user_name, buffer);
	pack16(build_ptr->slurmctld_debug, buffer);
	packstr(build_ptr->slurmctld_logfile, buffer);
	pack16(build_ptr->slurmctld_timeout, buffer);
	pack16(build_ptr->slurmd_debug, buffer);
	packstr(build_ptr->slurmd_logfile, buffer);
	packstr(build_ptr->slurmd_spooldir, buffer);
	pack16(build_ptr->slurmd_timeout, buffer);
	packstr(build_ptr->slurm_conf, buffer);
	packstr(build_ptr->state_save_location, buffer);
	packstr(build_ptr->tmp_fs, buffer);
	packstr(build_ptr->job_credential_private_key, buffer);
	packstr(build_ptr->job_credential_public_certificate, buffer);
}

static int
_unpack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t **
			   build_buffer_ptr, Buf buffer)
{
	slurm_ctl_conf_info_msg_t *build_ptr;
	/* alloc memory for structure */
	build_ptr = xmalloc(sizeof(slurm_ctl_conf_t));
	*build_buffer_ptr = build_ptr;

	/* load the data values */
	/* unpack timestamp of snapshot */
	safe_unpack_time(&build_ptr->last_update, buffer);
	safe_unpackstr_xmalloc(&build_ptr->backup_addr, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&build_ptr->backup_controller, &uint16_tmp,
			       buffer);
	safe_unpackstr_xmalloc(&build_ptr->control_addr, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&build_ptr->control_machine, &uint16_tmp,
			       buffer);
	safe_unpackstr_xmalloc(&build_ptr->epilog, &uint16_tmp, buffer);
	safe_unpack16(&build_ptr->fast_schedule, buffer);
	safe_unpack16(&build_ptr->hash_base, buffer);
	safe_unpack16(&build_ptr->heartbeat_interval, buffer);
	safe_unpack16(&build_ptr->inactive_limit, buffer);
	safe_unpack16(&build_ptr->kill_wait, buffer);
	safe_unpackstr_xmalloc(&build_ptr->prioritize, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&build_ptr->prolog, &uint16_tmp, buffer);
	safe_unpack16(&build_ptr->ret2service, buffer);
	safe_unpack16(&build_ptr->slurm_user_id, buffer);
	safe_unpackstr_xmalloc(&build_ptr->slurm_user_name,
			       &uint16_tmp, buffer);
	safe_unpack16(&build_ptr->slurmctld_debug, buffer);
	safe_unpackstr_xmalloc(&build_ptr->slurmctld_logfile,
			       &uint16_tmp, buffer);
	safe_unpack16(&build_ptr->slurmctld_timeout, buffer);
	safe_unpack16(&build_ptr->slurmd_debug, buffer);
	safe_unpackstr_xmalloc(&build_ptr->slurmd_logfile, &uint16_tmp,
			       buffer);
	safe_unpackstr_xmalloc(&build_ptr->slurmd_spooldir, &uint16_tmp,
			       buffer);
	safe_unpack16(&build_ptr->slurmd_timeout, buffer);
	safe_unpackstr_xmalloc(&build_ptr->slurm_conf, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&build_ptr->state_save_location,
			       &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&build_ptr->tmp_fs, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&build_ptr->job_credential_private_key,
			       &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&build_ptr->
			       job_credential_public_certificate,
			       &uint16_tmp, buffer);
	return SLURM_SUCCESS;
	FREE_NULL(build_ptr->backup_addr);
	FREE_NULL(build_ptr->backup_controller);
	FREE_NULL(build_ptr->control_addr);
	FREE_NULL(build_ptr->control_machine);
	FREE_NULL(build_ptr->epilog);
	FREE_NULL(build_ptr->prioritize);
	FREE_NULL(build_ptr->prolog);
	FREE_NULL(build_ptr->slurmctld_logfile);
	FREE_NULL(build_ptr->slurmd_logfile);
	FREE_NULL(build_ptr->slurmd_spooldir);
	FREE_NULL(build_ptr->slurm_conf);
	FREE_NULL(build_ptr->state_save_location);
	FREE_NULL(build_ptr->tmp_fs);
	FREE_NULL(build_ptr->job_credential_private_key);
	FREE_NULL(build_ptr->job_credential_public_certificate);
	FREE_NULL(build_ptr);
	*build_buffer_ptr = NULL;
	return SLURM_ERROR;
tewk's avatar
tewk committed
 * packs a job_desc struct 
 * IN job_desc_ptr - pointer to the job descriptor to pack
 * IN/OUT buffer - destination of the pack, contains pointers that are 
 *			automatically updated
tewk's avatar
tewk committed
 */
static void
_pack_job_desc_msg(job_desc_msg_t * job_desc_ptr, Buf buffer)
{
	/* load the data values */
	pack16(job_desc_ptr->contiguous, buffer);
	pack16(job_desc_ptr->kill_on_node_fail, buffer);
	packstr(job_desc_ptr->features, buffer);
	pack32(job_desc_ptr->job_id, buffer);
	packstr(job_desc_ptr->name, buffer);

	pack32(job_desc_ptr->min_procs, buffer);
	pack32(job_desc_ptr->min_memory, buffer);
	pack32(job_desc_ptr->min_tmp_disk, buffer);

	packstr(job_desc_ptr->partition, buffer);
	pack32(job_desc_ptr->priority, buffer);

	packstr(job_desc_ptr->req_nodes, buffer);
	packstr(job_desc_ptr->exc_nodes, buffer);
	packstr_array(job_desc_ptr->environment, job_desc_ptr->env_size,
		      buffer);
	packstr(job_desc_ptr->script, buffer);

	packstr(job_desc_ptr->err, buffer);
	packstr(job_desc_ptr->in, buffer);
	packstr(job_desc_ptr->out, buffer);
	packstr(job_desc_ptr->work_dir, buffer);

	pack16(job_desc_ptr->immediate, buffer);
	pack16(job_desc_ptr->shared, buffer);
	pack16(job_desc_ptr->task_dist, buffer);
	pack32(job_desc_ptr->time_limit, buffer);

	pack32(job_desc_ptr->num_procs, buffer);
	pack32(job_desc_ptr->min_nodes, buffer);
	pack32(job_desc_ptr->max_nodes, buffer);
	pack32(job_desc_ptr->num_tasks, buffer);
	pack32(job_desc_ptr->user_id, buffer);
tewk's avatar
tewk committed
 * unpacks a job_desc struct
 * OUT job_desc_buffer_ptr - place to put pointer to allocated job desc struct
 * IN/OUT buffer - source of the unpack, contains pointers that are 
 *			automatically updated
tewk's avatar
tewk committed
 */
static int
_unpack_job_desc_msg(job_desc_msg_t ** job_desc_buffer_ptr, Buf buffer)
{
	uint16_t uint16_tmp;
	job_desc_msg_t *job_desc_ptr;

	/* alloc memory for structure */
	job_desc_ptr = xmalloc(sizeof(job_desc_msg_t));
	*job_desc_buffer_ptr = job_desc_ptr;

	/* load the data values */
	safe_unpack16(&job_desc_ptr->contiguous, buffer);
	safe_unpack16(&job_desc_ptr->kill_on_node_fail, buffer);
	safe_unpackstr_xmalloc(&job_desc_ptr->features, &uint16_tmp, buffer);
	safe_unpack32(&job_desc_ptr->job_id, buffer);
	safe_unpackstr_xmalloc(&job_desc_ptr->name, &uint16_tmp, buffer);
	safe_unpack32(&job_desc_ptr->min_procs, buffer);
	safe_unpack32(&job_desc_ptr->min_memory, buffer);
	safe_unpack32(&job_desc_ptr->min_tmp_disk, buffer);

	safe_unpackstr_xmalloc(&job_desc_ptr->partition, &uint16_tmp, buffer);
	safe_unpack32(&job_desc_ptr->priority, buffer);

	safe_unpackstr_xmalloc(&job_desc_ptr->req_nodes, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&job_desc_ptr->exc_nodes, &uint16_tmp, buffer);
	safe_unpackstr_array(&job_desc_ptr->environment,
			     &job_desc_ptr->env_size, buffer);
	safe_unpackstr_xmalloc(&job_desc_ptr->script, &uint16_tmp, buffer);

	safe_unpackstr_xmalloc(&job_desc_ptr->err, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&job_desc_ptr->in, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&job_desc_ptr->out, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&job_desc_ptr->work_dir, &uint16_tmp, buffer);

	safe_unpack16(&job_desc_ptr->immediate, buffer);
	safe_unpack16(&job_desc_ptr->shared, buffer);
	safe_unpack16(&job_desc_ptr->task_dist, buffer);
	safe_unpack32(&job_desc_ptr->time_limit, buffer);

	safe_unpack32(&job_desc_ptr->num_procs, buffer);
	safe_unpack32(&job_desc_ptr->min_nodes, buffer);
	safe_unpack32(&job_desc_ptr->max_nodes, buffer);
	safe_unpack32(&job_desc_ptr->num_tasks, buffer);
	safe_unpack32(&job_desc_ptr->user_id, buffer);

	return SLURM_SUCCESS;

      unpack_error:
	FREE_NULL(job_desc_ptr->features);
	FREE_NULL(job_desc_ptr->name);
	FREE_NULL(job_desc_ptr->partition);
	FREE_NULL(job_desc_ptr->req_nodes);
	FREE_NULL(job_desc_ptr->environment);
	FREE_NULL(job_desc_ptr->script);
	FREE_NULL(job_desc_ptr->err);
	FREE_NULL(job_desc_ptr->in);
	FREE_NULL(job_desc_ptr->out);
	FREE_NULL(job_desc_ptr->work_dir);
	FREE_NULL(job_desc_ptr);
	*job_desc_buffer_ptr = NULL;
	return SLURM_ERROR;
static void
_pack_old_job_desc_msg(old_job_alloc_msg_t * job_desc_ptr, Buf buffer)
{
	pack32(job_desc_ptr->job_id, buffer);
	pack32(job_desc_ptr->uid, buffer);
static int
_unpack_old_job_desc_msg(old_job_alloc_msg_t **
			 job_desc_buffer_ptr, Buf buffer)
{
	old_job_alloc_msg_t *job_desc_ptr;
	assert(job_desc_buffer_ptr != NULL);
	job_desc_ptr = xmalloc(sizeof(old_job_alloc_msg_t));
	*job_desc_buffer_ptr = job_desc_ptr;
	safe_unpack32(&job_desc_ptr->job_id, buffer);
	safe_unpack32(&job_desc_ptr->uid, buffer);
	return SLURM_SUCCESS;
	*job_desc_buffer_ptr = NULL;
	return SLURM_ERROR;
static void
_pack_last_update_msg(last_update_msg_t * msg, Buf buffer)
	pack_time(msg->last_update, buffer);
static int
_unpack_last_update_msg(last_update_msg_t ** msg, Buf buffer)
	last_update_msg_t *last_update_msg;
	last_update_msg = xmalloc(sizeof(last_update_msg_t));
	*msg = last_update_msg;
	safe_unpack_time(&last_update_msg->last_update, buffer);
	return SLURM_SUCCESS;
	*msg = NULL;
	return SLURM_ERROR;
static void
_pack_return_code_msg(return_code_msg_t * msg, Buf buffer)
	pack32(msg->return_code, buffer);
static int
_unpack_return_code_msg(return_code_msg_t ** msg, Buf buffer)
	return_code_msg_t *return_code_msg;
	return_code_msg = xmalloc(sizeof(return_code_msg_t));
	*msg = return_code_msg;
	safe_unpack32(&return_code_msg->return_code, buffer);
	return SLURM_SUCCESS;
	*msg = NULL;
	return SLURM_ERROR;
static void
_pack_reattach_tasks_request_msg(reattach_tasks_request_msg_t * msg,
				 Buf buffer)
	pack32(msg->job_id, buffer);
	pack32(msg->job_step_id, buffer);
	pack32(msg->srun_node_id, buffer);
	pack16(msg->resp_port, buffer);
	pack16(msg->io_port, buffer);
	packstr(msg->ofname, buffer);
	packstr(msg->efname, buffer);
	packstr(msg->ifname, buffer);
	packmem_array(msg->key,
		      (uint32_t) SLURM_SSL_SIGNATURE_LENGTH, buffer);
static int
_unpack_reattach_tasks_request_msg(reattach_tasks_request_msg_t ** msg_ptr,
				   Buf buffer)
{
	uint16_t uint16_tmp;
	reattach_tasks_request_msg_t *msg;
	msg = xmalloc(sizeof(*msg));
	*msg_ptr = msg;
	safe_unpack32(&msg->job_id, buffer);
	safe_unpack32(&msg->job_step_id, buffer);
	safe_unpack32(&msg->srun_node_id, buffer);
	safe_unpack16(&msg->resp_port, buffer);
	safe_unpack16(&msg->io_port, buffer);
	safe_unpackstr_xmalloc(&msg->ofname, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&msg->efname, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&msg->ifname, &uint16_tmp, buffer);
	safe_unpackmem_array(msg->key,
			     (uint32_t) SLURM_SSL_SIGNATURE_LENGTH, buffer);
	return SLURM_SUCCESS;

      unpack_error:
	slurm_free_reattach_tasks_request_msg(msg);
	*msg_ptr = NULL;
	return SLURM_ERROR;
static void
_pack_reattach_tasks_response_msg(reattach_tasks_response_msg_t * msg,
				  Buf buffer)
tewk's avatar
tewk committed
{
	packstr(msg->node_name,   buffer);
	packstr(msg->executable_name, buffer);
	pack32(msg->return_code,  buffer);
	pack32(msg->srun_node_id, buffer);
	pack32(msg->ntasks,       buffer);
	pack32_array(msg->gids,       msg->ntasks, buffer);
	pack32_array(msg->local_pids, msg->ntasks, buffer);
tewk's avatar
tewk committed
}

static int
_unpack_reattach_tasks_response_msg(reattach_tasks_response_msg_t ** msg_ptr,
				    Buf buffer)
tewk's avatar
tewk committed
{
	uint32_t ntasks;
	uint16_t uint16_tmp;
	reattach_tasks_response_msg_t *msg = xmalloc(sizeof(*msg));
	*msg_ptr = msg;

	safe_unpackstr_xmalloc(&msg->node_name, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&msg->executable_name, &uint16_tmp, buffer);
	safe_unpack32(&msg->return_code,  buffer);
	safe_unpack32(&msg->srun_node_id, buffer);
	safe_unpack32(&msg->ntasks,       buffer);
	safe_unpack32_array(&msg->gids,       &ntasks, buffer);
	safe_unpack32_array(&msg->local_pids, &ntasks, buffer);
	if (msg->ntasks != ntasks)
		goto unpack_error;
	return SLURM_SUCCESS;
tewk's avatar
tewk committed

      unpack_error:
	slurm_free_reattach_tasks_response_msg(msg);
	*msg_ptr = NULL;
	return SLURM_ERROR;
}
static void
_pack_task_exit_msg(task_exit_msg_t * msg, Buf buffer)
{
	pack32(msg->return_code, buffer);
	pack32(msg->num_tasks, buffer);
	pack32_array(msg->task_id_list,
		     msg->num_tasks, buffer);
tewk's avatar
tewk committed
}

static int
_unpack_task_exit_msg(task_exit_msg_t ** msg_ptr, Buf buffer)
{
	task_exit_msg_t *msg;