Newer
Older
/****************************************************************************\
* slurm_protocol_pack.c - functions to pack and unpack structures for RPCs
*****************************************************************************
* Copyright (C) 2002 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Kevin Tew <tew1@llnl.gov>, Moe Jette <jette1@llnl.gov>, et. al.
* UCRL-CODE-2002-040.
*
* This file is part of SLURM, a resource management program.
* For details, see <http://www.llnl.gov/linux/slurm/>.
*
* SLURM is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with SLURM; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
\*****************************************************************************/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <src/common/bitstring.h>
#include <src/common/slurm_protocol_pack.h>
#include <src/common/slurm_protocol_defs.h>
#include <src/common/slurm_auth.h>
#include <src/common/log.h>
void pack_job_credential ( slurm_job_credential_t* cred , Buf buffer );
int unpack_job_credential( slurm_job_credential_t** msg , Buf buffer );
/* pack_header
* packs a slurm protocol header that proceeds every slurm message
* header - the header structure to pack
* buffer - destination of the pack, contains pointers that are automatically updated
void pack_header ( header_t * header, Buf buffer )
pack16 ( header -> version , buffer ) ;
pack16 ( header -> flags , buffer ) ;
pack16 ( (uint16_t)header -> cred_type , buffer ) ;
pack32 ( header -> cred_length , buffer ) ;
pack16 ( (uint16_t)header -> msg_type , buffer ) ;
pack32 ( header -> body_length , buffer ) ;
/* unpack_header
* unpacks a slurm protocol header that proceeds every slurm message
* header - the header structure to unpack
* buffer - destination of the pack, contains pointers that are automatically updated
int unpack_header ( header_t * header , Buf buffer )
safe_unpack16 ( & header -> version , buffer ) ;
safe_unpack16 ( & header -> flags , buffer ) ;
safe_unpack16 ( & tmp , buffer ) ;
header -> cred_type = (slurm_credential_type_t ) tmp ;
safe_unpack32 ( & header -> cred_length , buffer ) ;
safe_unpack16 ( & tmp , buffer ) ;
header -> msg_type = (slurm_msg_type_t ) tmp ;
safe_unpack32 ( & header -> body_length , buffer ) ;
return SLURM_SUCCESS;
unpack_error:
return SLURM_ERROR;
int size_io_stream_header (void)
{ /* must match un/pack_io_stream_header and size_io_stream_header */
return (SLURM_SSL_SIGNATURE_LENGTH + 2 * sizeof(uint16_t) + sizeof(uint32_t));
}
void pack_io_stream_header ( slurm_io_stream_header_t * msg , Buf buffer )
{ /* must match un/pack_io_stream_header and size_io_stream_header */
pack16( msg->version, buffer ) ;
packmem_array( msg->key, (uint32_t) SLURM_SSL_SIGNATURE_LENGTH, buffer ) ;
pack32( msg->task_id, buffer ) ;
pack16( msg->type, buffer ) ;
int unpack_io_stream_header ( slurm_io_stream_header_t * msg , Buf buffer )
{ /* must match un/pack_io_stream_header and size_io_stream_header */
safe_unpack16( & msg->version, buffer ) ;
safe_unpackmem_array( msg->key, (uint32_t) SLURM_SSL_SIGNATURE_LENGTH , buffer ) ;
safe_unpack32( & msg->task_id, buffer ) ;
safe_unpack16( & msg->type, buffer ) ;
return SLURM_SUCCESS;
unpack_error:
return SLURM_ERROR;
/* pack_msg
* packs a slurm protocol mesg body
* header - the body structure to pack
* buffer - destination of the pack, contains pointers that are automatically updated
int pack_msg ( slurm_msg_t const * msg , Buf buffer )
switch ( msg -> msg_type )
case REQUEST_BUILD_INFO :
case REQUEST_NODE_INFO :
case REQUEST_PARTITION_INFO :
case REQUEST_ACCTING_INFO :
pack_last_update ( ( last_update_msg_t * ) msg -> data , buffer ) ;
break;
case RESPONSE_BUILD_INFO:
pack_slurm_ctl_conf ( ( slurm_ctl_conf_info_msg_t * ) msg -> data , buffer ) ;
pack_job_info_msg ( ( slurm_msg_t * ) msg , buffer ) ;

tewk
committed
case RESPONSE_PARTITION_INFO:
pack_partition_info_msg ( ( slurm_msg_t * ) msg , buffer ) ;

tewk
committed
break ;
pack_node_info_msg ( ( slurm_msg_t * ) msg , buffer ) ;
pack_node_registration_status_msg ( ( slurm_node_registration_status_msg_t * ) msg -> data , buffer );
break ;
case REQUEST_RESOURCE_ALLOCATION :
case REQUEST_SUBMIT_BATCH_JOB :
case REQUEST_IMMEDIATE_RESOURCE_ALLOCATION :

Moe Jette
committed
case REQUEST_ALLOCATION_AND_RUN_JOB_STEP :
pack_job_desc ( (job_desc_msg_t * ) msg -> data , buffer ) ;
case REQUEST_OLD_JOB_RESOURCE_ALLOCATION :
pack_old_job_desc ( (old_job_alloc_msg_t * ) msg -> data , buffer ) ;
break ;
case REQUEST_RECONFIGURE :
case REQUEST_SHUTDOWN_IMMEDIATE :
case REQUEST_CONTROL :
/* Message contains no body/information */

Moe Jette
committed
case REQUEST_SHUTDOWN :
pack_shutdown_msg ( (shutdown_msg_t *) msg -> data, buffer ) ;

Moe Jette
committed
break;
case RESPONSE_SUBMIT_BATCH_JOB:
pack_submit_response_msg ( ( submit_response_msg_t * ) msg -> data , buffer ) ;
break ;
case RESPONSE_RESOURCE_ALLOCATION :
case RESPONSE_IMMEDIATE_RESOURCE_ALLOCATION :
pack_resource_allocation_response_msg ( ( resource_allocation_response_msg_t * ) msg -> data ,
buffer ) ;
break ;
case RESPONSE_ALLOCATION_AND_RUN_JOB_STEP :
pack_resource_allocation_and_run_response_msg ( ( resource_allocation_and_run_response_msg_t * ) msg -> data ,
buffer ) ;
pack_job_desc ( (job_desc_msg_t * ) msg -> data , buffer ) ;
pack_update_node_msg ( ( update_node_msg_t * ) msg-> data , buffer ) ;
pack_update_partition_msg ( ( update_part_msg_t * ) msg->data , buffer ) ;
case REQUEST_REATTACH_TASKS_STREAMS :
pack_reattach_tasks_streams_msg ( ( reattach_tasks_streams_msg_t * ) msg->data , buffer ) ;
pack_launch_tasks_request_msg ( ( launch_tasks_request_msg_t * ) msg->data , buffer ) ;
case RESPONSE_LAUNCH_TASKS :
pack_launch_tasks_response_msg ( ( launch_tasks_response_msg_t * ) msg->data , buffer ) ;
pack_cancel_tasks_msg ( ( kill_tasks_msg_t * ) msg->data , buffer ) ;
pack_get_job_step_info ( ( job_step_info_request_msg_t * ) msg->data , buffer ) ;
/******** job_step_id_t Messages ********/
case REQUEST_JOB_INFO :
case REQUEST_COMPLETE_JOB_STEP :
pack_job_step_id ( ( job_step_id_t * ) msg->data , buffer ) ;
pack_revoke_credential_msg ( ( revoke_credential_msg_t * ) msg->data , buffer ) ;
case REQUEST_SIGNAL_JOB :
break ;
case REQUEST_SIGNAL_JOB_STEP :
break ;
case RESPONSE_RECONFIGURE :
case RESPONSE_CANCEL_JOB_STEP :
case RESPONSE_COMPLETE_JOB_STEP :
case RESPONSE_SIGNAL_JOB :
case RESPONSE_SIGNAL_JOB_STEP :
break ;
case REQUEST_JOB_ATTACH :
break ;
case RESPONSE_JOB_ATTACH :
break ;
pack_job_step_info_msg( ( slurm_msg_t * ) msg , buffer ) ;
break ;
case REQUEST_JOB_RESOURCE :
break ;
case RESPONSE_JOB_RESOURCE :
break ;
case REQUEST_RUN_JOB_STEP :
break ;
case RESPONSE_RUN_JOB_STEP:
break ;
case MESSAGE_TASK_EXIT :
pack_task_exit_msg ( ( task_exit_msg_t * ) msg -> data , buffer ) ;
break ;
case REQUEST_BATCH_JOB_LAUNCH :
pack_batch_job_launch ( ( batch_job_launch_msg_t * ) msg -> data , buffer ) ;
break ;
case MESSAGE_UPLOAD_ACCOUNTING_INFO :
break ;
pack_return_code ( ( return_code_msg_t * ) msg -> data , buffer ) ;
case RESPONSE_JOB_STEP_CREATE:
pack_job_step_create_response_msg(( job_step_create_response_msg_t * ) msg -> data , buffer ) ;
break;
case REQUEST_JOB_STEP_CREATE:
pack_job_step_create_request_msg(( job_step_create_request_msg_t * ) msg -> data , buffer ) ;
debug ( "No pack method for msg type %i", msg -> msg_type ) ;
return SLURM_SUCCESS ;
/* unpack_msg
* unpacks a slurm protocol msg body
* header - the body structure to unpack
* buffer - source of the unpack, contains pointers that are automatically updated
int unpack_msg ( slurm_msg_t * msg , Buf buffer )
int rc = SLURM_SUCCESS;
case REQUEST_BUILD_INFO :
case REQUEST_NODE_INFO :
case REQUEST_PARTITION_INFO :
case REQUEST_ACCTING_INFO :
rc = unpack_last_update ( ( last_update_msg_t **) &(msg -> data) , buffer ) ;
break;
case RESPONSE_BUILD_INFO:
rc = unpack_slurm_ctl_conf ( ( slurm_ctl_conf_info_msg_t ** ) &(msg -> data) , buffer ) ;
break;
rc = unpack_job_info_msg ( ( job_info_msg_t ** ) &(msg -> data) , buffer ) ;

tewk
committed
case RESPONSE_PARTITION_INFO:
rc = unpack_partition_info_msg ( ( partition_info_msg_t ** ) &(msg -> data) , buffer ) ;

tewk
committed
break;
rc = unpack_node_info_msg ( ( node_info_msg_t ** ) &(msg -> data) , buffer) ;
rc = unpack_node_registration_status_msg ( ( slurm_node_registration_status_msg_t ** ) &( msg -> data ), buffer );
break ;
case REQUEST_RESOURCE_ALLOCATION :
case REQUEST_SUBMIT_BATCH_JOB :
case REQUEST_IMMEDIATE_RESOURCE_ALLOCATION :
case REQUEST_ALLOCATION_AND_RUN_JOB_STEP :
rc = unpack_job_desc ( ( job_desc_msg_t **) & ( msg-> data ), buffer ) ;
case REQUEST_OLD_JOB_RESOURCE_ALLOCATION :
rc = unpack_old_job_desc ( (old_job_alloc_msg_t ** ) & ( msg -> data ), buffer ) ;
case REQUEST_RECONFIGURE :
case REQUEST_SHUTDOWN_IMMEDIATE :
case REQUEST_CONTROL :
/* Message contains no body/information */

Moe Jette
committed
case REQUEST_SHUTDOWN :
rc = unpack_shutdown_msg ( ( shutdown_msg_t **) & ( msg-> data ), buffer ) ;

Moe Jette
committed
break ;
case RESPONSE_SUBMIT_BATCH_JOB :
rc = unpack_submit_response_msg ( ( submit_response_msg_t ** ) & ( msg -> data ) , buffer ) ;
break ;
case RESPONSE_RESOURCE_ALLOCATION :
case RESPONSE_IMMEDIATE_RESOURCE_ALLOCATION :
rc = unpack_resource_allocation_response_msg ( ( resource_allocation_response_msg_t ** ) & ( msg -> data ) , buffer ) ;
break ;
case RESPONSE_ALLOCATION_AND_RUN_JOB_STEP :
rc = unpack_resource_allocation_and_run_response_msg ( ( resource_allocation_and_run_response_msg_t ** ) & ( msg -> data ) , buffer ) ;
rc = unpack_job_desc ( ( job_desc_msg_t **) & ( msg-> data ), buffer ) ;
rc = unpack_update_node_msg ( ( update_node_msg_t ** ) & ( msg-> data ) , buffer ) ;
rc = unpack_update_partition_msg ( ( update_part_msg_t ** ) & ( msg->data ) , buffer ) ;
rc = unpack_launch_tasks_request_msg ( ( launch_tasks_request_msg_t ** ) & ( msg->data ) , buffer ) ;
case RESPONSE_LAUNCH_TASKS :
rc = unpack_launch_tasks_response_msg ( ( launch_tasks_response_msg_t ** ) & ( msg->data ) , buffer ) ;
case REQUEST_REATTACH_TASKS_STREAMS :
rc = unpack_reattach_tasks_streams_msg ( ( reattach_tasks_streams_msg_t ** ) & ( msg->data ) , buffer ) ;
rc = unpack_cancel_tasks_msg ( ( kill_tasks_msg_t ** ) & ( msg->data ) , buffer ) ;
rc = unpack_get_job_step_info ( ( job_step_info_request_msg_t ** ) & ( msg->data ) , buffer ) ;
/******** job_step_id_t Messages ********/
case REQUEST_JOB_INFO :
case REQUEST_CANCEL_JOB_STEP :
case REQUEST_COMPLETE_JOB_STEP :
rc = unpack_job_step_id ( ( job_step_id_t ** ) & ( msg->data ) , buffer ) ;
rc = unpack_revoke_credential_msg ( ( revoke_credential_msg_t ** ) & ( msg->data ) , buffer ) ;
case REQUEST_SIGNAL_JOB :
break ;
case REQUEST_SIGNAL_JOB_STEP :
break ;
case RESPONSE_RECONFIGURE :
case RESPONSE_CANCEL_JOB_STEP :
case RESPONSE_COMPLETE_JOB_STEP :
case RESPONSE_SIGNAL_JOB :
case RESPONSE_SIGNAL_JOB_STEP :
break ;
case REQUEST_JOB_ATTACH :
break ;
case RESPONSE_JOB_ATTACH :
break ;
unpack_job_step_info_response_msg( ( job_step_info_response_msg_t ** ) & ( msg->data ) , buffer ) ;
break ;
case REQUEST_JOB_RESOURCE :
break ;
case RESPONSE_JOB_RESOURCE :
break ;
case REQUEST_RUN_JOB_STEP :
break ;
case RESPONSE_RUN_JOB_STEP:
break ;
case MESSAGE_TASK_EXIT :
rc = unpack_task_exit_msg ( ( task_exit_msg_t ** ) & (msg->data ) , buffer ) ;
break ;
case REQUEST_BATCH_JOB_LAUNCH :
rc = unpack_batch_job_launch ( ( batch_job_launch_msg_t **) &(msg -> data) , buffer) ;
break ;
case MESSAGE_UPLOAD_ACCOUNTING_INFO :
break ;
rc = unpack_return_code ( ( return_code_msg_t **) &(msg -> data) , buffer ) ;
case RESPONSE_JOB_STEP_CREATE:
rc = unpack_job_step_create_response_msg(( job_step_create_response_msg_t ** ) &msg -> data , buffer ) ;
break;
case REQUEST_JOB_STEP_CREATE:
rc = unpack_job_step_create_request_msg(( job_step_create_request_msg_t ** ) &msg -> data , buffer ) ;
default :
debug ( "No unpack method for msg type %i", msg -> msg_type ) ;
return EINVAL ;
break;
if (rc)
error("Malformed RPC of type %u received", msg->msg_type);
return rc ;
void pack_update_node_msg ( update_node_msg_t * msg, Buf buffer )
packstr ( msg -> node_names , buffer ) ;
pack16 ( msg -> node_state , buffer ) ;
int unpack_update_node_msg ( update_node_msg_t ** msg , Buf buffer )
{
uint16_t uint16_tmp;
update_node_msg_t * tmp_ptr ;
tmp_ptr = xmalloc ( sizeof ( update_node_msg_t ) ) ;
*msg = tmp_ptr ;
safe_unpackstr_xmalloc ( & tmp_ptr -> node_names , &uint16_tmp, buffer ) ;
safe_unpack16 ( & tmp_ptr -> node_state , buffer ) ;
return SLURM_SUCCESS ;
unpack_error:
if (tmp_ptr->node_names)
xfree (tmp_ptr->node_names);
xfree (tmp_ptr);
*msg = NULL;
return SLURM_ERROR;
void pack_node_registration_status_msg ( slurm_node_registration_status_msg_t * msg, Buf buffer )
int i;
pack32 ( msg -> timestamp , buffer ) ;
packstr ( msg -> node_name , buffer ) ;
pack32 ( msg -> cpus , buffer ) ;
pack32 ( msg -> real_memory_size , buffer ) ;
pack32 ( msg -> temporary_disk_space , buffer ) ;
pack32 ( msg -> job_count , buffer ) ;
for (i = 0; i < msg->job_count ; i++) {
pack32 ( msg -> job_id[i] , buffer ) ;
for (i = 0; i < msg->job_count ; i++) {
pack16 ( msg -> step_id[i] , buffer ) ;
int unpack_node_registration_status_msg ( slurm_node_registration_status_msg_t ** msg , Buf buffer )
uint16_t uint16_tmp;
int i;
slurm_node_registration_status_msg_t * node_reg_ptr ;
/* alloc memory for structure */
node_reg_ptr = xmalloc ( sizeof ( slurm_node_registration_status_msg_t ) ) ;
*msg = node_reg_ptr ;
/* unpack timestamp of snapshot */
safe_unpack32 ( & node_reg_ptr -> timestamp , buffer ) ;
/* load the data values */
safe_unpackstr_xmalloc ( & node_reg_ptr -> node_name , &uint16_tmp, buffer ) ;
safe_unpack32 ( & node_reg_ptr -> cpus , buffer ) ;
safe_unpack32 ( & node_reg_ptr -> real_memory_size , buffer ) ;
safe_unpack32 ( & node_reg_ptr -> temporary_disk_space , buffer ) ;
safe_unpack32 ( & node_reg_ptr -> job_count , buffer ) ;
node_reg_ptr -> job_id = xmalloc (sizeof (uint32_t) * node_reg_ptr->job_count);
for (i = 0; i < node_reg_ptr->job_count ; i++) {
safe_unpack32 ( & node_reg_ptr->job_id[i] , buffer ) ;
node_reg_ptr -> step_id = xmalloc (sizeof (uint16_t) * node_reg_ptr->job_count);
for (i = 0; i < node_reg_ptr->job_count ; i++) {
safe_unpack16 ( & node_reg_ptr->step_id[i] , buffer ) ;
return SLURM_SUCCESS ;
unpack_error:
if (node_reg_ptr->node_name)
xfree (node_reg_ptr->node_name);
if (node_reg_ptr->job_id)
xfree (node_reg_ptr->job_id);
if (node_reg_ptr->step_id)
xfree (node_reg_ptr->step_id);
xfree (node_reg_ptr);
*msg = NULL;
return SLURM_ERROR;
void pack_resource_allocation_response_msg ( resource_allocation_response_msg_t * msg, Buf buffer )
pack32 ( msg->job_id , buffer ) ;
packstr ( msg->node_list , buffer ) ;
pack16 ( msg->num_cpu_groups , buffer ) ;
pack32_array ( msg->cpus_per_node, msg->num_cpu_groups , buffer ) ;
pack32_array ( msg->cpu_count_reps, msg->num_cpu_groups, buffer ) ;
pack16 ( msg->node_cnt , buffer ) ;
pack_slurm_addr_array ( msg->node_addr, msg->node_cnt , buffer ) ;
int unpack_resource_allocation_response_msg ( resource_allocation_response_msg_t ** msg , Buf buffer )
{
uint16_t uint16_tmp;
resource_allocation_response_msg_t * tmp_ptr ;
assert ( msg != NULL );
tmp_ptr = xmalloc ( sizeof ( resource_allocation_response_msg_t ) ) ;
*msg = tmp_ptr ;
safe_unpack32 ( & tmp_ptr -> job_id , buffer ) ;
safe_unpackstr_xmalloc ( & tmp_ptr -> node_list , &uint16_tmp, buffer ) ;
safe_unpack16 ( & tmp_ptr -> num_cpu_groups , buffer ) ;
if ( tmp_ptr -> num_cpu_groups > 0 ){
tmp_ptr->cpus_per_node = (uint32_t*) xmalloc( sizeof(uint32_t) * tmp_ptr -> num_cpu_groups );
tmp_ptr->cpu_count_reps = (uint32_t*) xmalloc( sizeof(uint32_t) * tmp_ptr -> num_cpu_groups );
safe_unpack32_array ( (uint32_t**) &(tmp_ptr->cpus_per_node), &uint16_tmp, buffer ) ;
safe_unpack32_array ( (uint32_t**) &(tmp_ptr->cpu_count_reps), &uint16_tmp, buffer ) ;
}
else
{
tmp_ptr->cpus_per_node = NULL;
tmp_ptr->cpu_count_reps = NULL;
}
safe_unpack16 ( & tmp_ptr -> node_cnt , buffer ) ;
if ( tmp_ptr -> node_cnt > 0 ) {
if (unpack_slurm_addr_array ( &(tmp_ptr->node_addr) ,
&(tmp_ptr->node_cnt) , buffer ))
goto unpack_error;
} else
tmp_ptr->node_addr = NULL;
info ("job id is %u", tmp_ptr->job_id);
return SLURM_SUCCESS ;
unpack_error:
if (tmp_ptr->node_list)
xfree (tmp_ptr->node_list);
if (tmp_ptr->cpus_per_node)
xfree (tmp_ptr->cpus_per_node);
if (tmp_ptr->cpu_count_reps)
xfree (tmp_ptr->cpu_count_reps);
xfree (tmp_ptr);
*msg = NULL;
return SLURM_ERROR;
void pack_resource_allocation_and_run_response_msg ( resource_allocation_and_run_response_msg_t * msg, Buf buffer )
{
assert ( msg != NULL );
pack32 ( msg->job_id , buffer ) ;
packstr ( msg->node_list , buffer ) ;
pack16 ( msg->num_cpu_groups , buffer ) ;
pack32_array ( msg->cpus_per_node, msg->num_cpu_groups , buffer ) ;
pack32_array ( msg->cpu_count_reps, msg->num_cpu_groups, buffer ) ;
pack32 ( msg -> job_step_id , buffer ) ;
pack16 ( msg->node_cnt , buffer ) ;
pack_slurm_addr_array ( msg->node_addr, msg->node_cnt , buffer ) ;
pack_job_credential( msg->credentials, buffer ) ;
#ifdef HAVE_LIBELAN3
qsw_pack_jobinfo( msg -> qsw_job , buffer ) ;
int unpack_resource_allocation_and_run_response_msg ( resource_allocation_and_run_response_msg_t ** msg , Buf buffer )
{
uint16_t uint16_tmp;
resource_allocation_and_run_response_msg_t * tmp_ptr ;
/* alloc memory for structure */
assert ( msg != NULL );
tmp_ptr = xmalloc ( sizeof ( resource_allocation_and_run_response_msg_t ) ) ;
*msg = tmp_ptr ;
/* load the data values */
safe_unpack32 ( & tmp_ptr -> job_id , buffer ) ;
safe_unpackstr_xmalloc ( & tmp_ptr -> node_list , &uint16_tmp, buffer ) ;
safe_unpack16 ( & tmp_ptr -> num_cpu_groups , buffer ) ;
if ( tmp_ptr -> num_cpu_groups > 0 ){
tmp_ptr->cpus_per_node = (uint32_t*) xmalloc( sizeof(uint32_t) * tmp_ptr -> num_cpu_groups );
tmp_ptr->cpu_count_reps = (uint32_t*) xmalloc( sizeof(uint32_t) * tmp_ptr -> num_cpu_groups );
safe_unpack32_array ( (uint32_t**) &(tmp_ptr->cpus_per_node), &uint16_tmp, buffer ) ;
safe_unpack32_array ( (uint32_t**) &(tmp_ptr->cpu_count_reps), &uint16_tmp, buffer ) ;
safe_unpack32 ( &tmp_ptr -> job_step_id, buffer ) ;
safe_unpack16 ( & tmp_ptr -> node_cnt , buffer ) ;
if ( tmp_ptr -> node_cnt > 0 ) {
if (unpack_slurm_addr_array ( &(tmp_ptr->node_addr) ,
&(tmp_ptr->node_cnt) , buffer ))
goto unpack_error;
} else
tmp_ptr->node_addr = NULL;
if (unpack_job_credential( &tmp_ptr->credentials, buffer ))
goto unpack_error;
#ifdef HAVE_LIBELAN3
qsw_alloc_jobinfo(&tmp_ptr->qsw_job);
if (qsw_unpack_jobinfo(tmp_ptr->qsw_job, buffer) < 0) {
qsw_free_jobinfo (tmp_ptr->qsw_job);
goto unpack_error;
return SLURM_SUCCESS ;
unpack_error:
if (tmp_ptr->node_list)
xfree (tmp_ptr->node_list);
if (tmp_ptr->cpus_per_node)
xfree (tmp_ptr->cpus_per_node);
if (tmp_ptr->cpu_count_reps)
xfree (tmp_ptr->cpu_count_reps);
xfree (tmp_ptr);
*msg = NULL;
return SLURM_ERROR;
void pack_submit_response_msg ( submit_response_msg_t * msg, Buf buffer )
pack32 ( msg->job_id , buffer ) ;
}
int unpack_submit_response_msg ( submit_response_msg_t ** msg , Buf buffer )
{
submit_response_msg_t * tmp_ptr ;
/* alloc memory for structure */
tmp_ptr = xmalloc ( sizeof ( submit_response_msg_t ) ) ;
*msg = tmp_ptr ;
/* load the data values */
safe_unpack32 ( & tmp_ptr -> job_id , buffer ) ;
return SLURM_SUCCESS ;
unpack_error:
xfree (tmp_ptr);
*msg = NULL;
return SLURM_ERROR;
void pack_node_info_msg ( slurm_msg_t * msg, Buf buffer )
{
packmem_array ( msg->data , msg->data_size, buffer );

tewk
committed
}
int unpack_node_info_msg ( node_info_msg_t ** msg , Buf buffer )

tewk
committed
{
int i;
node_info_t *node = NULL;
*msg = xmalloc ( sizeof ( node_info_msg_t ) );

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
committed
node = (*msg) -> node_array = xmalloc ( sizeof ( node_info_t ) * (*msg)->record_count ) ;

tewk
committed
/* load individual job info */
for (i = 0; i < (*msg)->record_count ; i++) {
if (unpack_node_info_members ( & node[i] , buffer ) )
goto unpack_error;

tewk
committed
}
return SLURM_SUCCESS;
unpack_error:
if (node)
xfree (node);
xfree (*msg);
*msg = NULL;
return SLURM_ERROR;

tewk
committed
}
int unpack_node_info ( node_info_t ** node , Buf buffer )
if (unpack_node_info_members ( *node , buffer )) {
xfree (*node);
*node = NULL;
return SLURM_ERROR;
} else
return SLURM_SUCCESS ;
int unpack_node_info_members ( node_info_t * node , Buf buffer )
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);
return SLURM_SUCCESS;
unpack_error:
if (node->name) {
xfree (node->name);
node->name = NULL;
}
if (node->features) {
xfree (node->features);
node->features = NULL;
}
if (node->partition) {
xfree (node->partition);
node->partition = NULL;
}
return SLURM_ERROR;
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 ) ;
int unpack_update_partition_msg ( update_part_msg_t ** msg , Buf buffer )
{
uint16_t uint16_tmp;
update_part_msg_t * tmp_ptr ;
/* alloc memory for structure */
tmp_ptr = xmalloc ( sizeof ( update_part_msg_t ) ) ;
*msg = tmp_ptr;
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 ) ;
return SLURM_SUCCESS;
unpack_error:
if (tmp_ptr -> name)
xfree (tmp_ptr -> name);
if (tmp_ptr -> nodes)
xfree (tmp_ptr -> nodes);
if (tmp_ptr -> allow_groups)
xfree (tmp_ptr -> allow_groups);
xfree (tmp_ptr);
*msg = NULL;
return SLURM_ERROR;
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 ) ;
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 */
tmp_ptr = xmalloc ( sizeof ( job_step_create_request_msg_t ) ) ;
*msg = tmp_ptr;
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_unpack16 ( &( tmp_ptr -> relative), buffer ) ;
safe_unpack16 ( &( tmp_ptr -> task_dist), buffer ) ;
safe_unpackstr_xmalloc ( &( tmp_ptr -> node_list ), &uint16_tmp, buffer ) ;
return SLURM_SUCCESS;
unpack_error:
if (tmp_ptr -> node_list)
xfree (tmp_ptr -> node_list);
xfree (tmp_ptr);
*msg = NULL;
return SLURM_ERROR;
void pack_revoke_credential_msg ( revoke_credential_msg_t* msg , Buf buffer )
pack32( msg->job_id, buffer ) ;
pack32( ( uint32_t ) msg->expiration_time, buffer ) ;
packmem_array( msg->signature, (uint32_t) SLURM_SSL_SIGNATURE_LENGTH , buffer ) ;
int unpack_revoke_credential_msg ( revoke_credential_msg_t** msg , Buf buffer )
assert (msg);
tmp_ptr = xmalloc ( sizeof ( slurm_job_credential_t ) ) ;
*msg = tmp_ptr;
safe_unpack32( &(tmp_ptr->job_id), buffer ) ;
safe_unpack32( (uint32_t*) &(tmp_ptr->expiration_time), buffer ) ;
safe_unpackmem_array( tmp_ptr->signature,
(uint32_t) SLURM_SSL_SIGNATURE_LENGTH , buffer ) ;
return SLURM_SUCCESS;
unpack_error:
xfree (tmp_ptr);
*msg = NULL;
return SLURM_ERROR;
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 ) ;
int unpack_job_credential( slurm_job_credential_t** msg , Buf buffer )
{
uint16_t uint16_tmp;
slurm_job_credential_t* tmp_ptr ;
/* alloc memory for structure */
tmp_ptr = xmalloc ( sizeof ( slurm_job_credential_t ) ) ;
*msg = 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 ) ;
return SLURM_SUCCESS;
unpack_error:
if (tmp_ptr->node_list)
xfree (tmp_ptr->node_list);
xfree (tmp_ptr);
*msg = NULL;
return SLURM_ERROR;
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 ) ;
qsw_pack_jobinfo( msg->qsw_job , buffer ) ;
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 ) ) ;
*msg = tmp_ptr;
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 ) )
goto unpack_error;
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);
goto unpack_error;
}
return SLURM_SUCCESS;
unpack_error:
if (tmp_ptr -> node_list)
xfree (tmp_ptr -> node_list);
xfree (tmp_ptr);
*msg = NULL;
return SLURM_ERROR;
void pack_partition_info_msg ( slurm_msg_t * msg, Buf buffer )
packmem_array(msg->data, msg->data_size, buffer);
int unpack_partition_info_msg ( partition_info_msg_t ** msg , Buf buffer )
partition_info_t *partition = NULL;
*msg = xmalloc ( sizeof ( partition_info_msg_t ) );
safe_unpack32 (&((*msg) -> record_count), buffer);
safe_unpack_time (&((*msg) -> last_update ) , buffer);
partition = (*msg) -> partition_array =
xmalloc ( sizeof ( partition_info_t ) * (*msg)->record_count ) ;
/* load individual job info */
for (i = 0; i < (*msg)->record_count ; i++) {
if (unpack_partition_info_members ( & partition[i] , buffer ))
goto unpack_error;
return SLURM_SUCCESS;
unpack_error:
xfree (*msg);
*msg = NULL;
if (partition)
xfree (partition);
return SLURM_ERROR;
int unpack_partition_info ( partition_info_t ** part , Buf buffer )

tewk
committed
{