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.
\*****************************************************************************/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include "src/common/bitstring.h"
#include "src/common/log.h"
#include "src/common/pack.h"
#include "src/common/slurm_auth.h"
#include "src/common/slurm_cred.h"
#include "src/common/slurm_protocol_api.h"
#include "src/common/slurm_protocol_defs.h"
#include "src/common/slurm_protocol_pack.h"
#include "src/common/xmalloc.h"
#if HAVE_ELAN
# include "src/common/qsw.h"
#endif
#define _pack_job_info_msg(msg,buf) _pack_buffer_msg(msg,buf)
#define _pack_job_step_info_msg(msg,buf) _pack_buffer_msg(msg,buf)
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
static void _pack_update_node_msg(update_node_msg_t * msg, Buf buffer);
static int _unpack_update_node_msg(update_node_msg_t ** msg, Buf buffer);
static void
_pack_node_registration_status_msg(slurm_node_registration_status_msg_t *
msg, Buf buffer);
static int
_unpack_node_registration_status_msg(slurm_node_registration_status_msg_t
** msg, Buf buffer);
static void
_pack_resource_allocation_response_msg(resource_allocation_response_msg_t *
msg, Buf buffer);
static int
_unpack_resource_allocation_response_msg(resource_allocation_response_msg_t
** msg, Buf buffer);
static void
_pack_resource_allocation_and_run_response_msg
(resource_allocation_and_run_response_msg_t * msg, Buf buffer);
static int
_unpack_resource_allocation_and_run_response_msg
(resource_allocation_and_run_response_msg_t ** msg, Buf buffer);
static void _pack_submit_response_msg(submit_response_msg_t * msg,
Buf buffer);
static int _unpack_submit_response_msg(submit_response_msg_t ** msg,
Buf buffer);
static void _pack_node_info_msg(slurm_msg_t * msg, Buf buffer);
static int _unpack_node_info_msg(node_info_msg_t ** msg, Buf buffer);
static int _unpack_node_info_members(node_info_t * node, Buf buffer);
static void _pack_update_partition_msg(update_part_msg_t * msg, Buf buffer);
static int _unpack_update_partition_msg(update_part_msg_t ** msg, Buf buffer);
static void _pack_job_step_create_request_msg(job_step_create_request_msg_t
* msg, Buf buffer);
static int
_unpack_job_step_create_request_msg(job_step_create_request_msg_t ** msg,
Buf buffer);

Moe Jette
committed
static void _pack_kill_job_msg(kill_job_msg_t * msg, Buf buffer);
static int _unpack_kill_job_msg(kill_job_msg_t ** msg, Buf buffer);
static void _pack_epilog_comp_msg(epilog_complete_msg_t * msg, Buf buffer);
static int _unpack_epilog_comp_msg(epilog_complete_msg_t ** msg, Buf buffer);
static void _pack_update_job_time_msg(job_time_msg_t * msg, Buf buffer);
static int _unpack_update_job_time_msg(job_time_msg_t ** msg, Buf buffer);
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
static void
_pack_job_step_create_response_msg(job_step_create_response_msg_t * msg,
Buf buffer);
static int
_unpack_job_step_create_response_msg(job_step_create_response_msg_t ** msg,
Buf buffer);
static void _pack_partition_info_msg(slurm_msg_t * msg, Buf buffer);
static int _unpack_partition_info_msg(partition_info_msg_t ** msg,
Buf buffer);
static int _unpack_partition_info_members(partition_info_t * part,
Buf buffer);
static void _pack_launch_tasks_request_msg(launch_tasks_request_msg_t *
msg, Buf buffer);
static int _unpack_launch_tasks_request_msg(launch_tasks_request_msg_t **
msg_ptr, Buf buffer);
static void _pack_cancel_tasks_msg(kill_tasks_msg_t * msg, Buf buffer);
static int _unpack_cancel_tasks_msg(kill_tasks_msg_t ** msg_ptr, Buf buffer);
static void _pack_launch_tasks_response_msg(launch_tasks_response_msg_t *
msg, Buf buffer);
static int _unpack_launch_tasks_response_msg(launch_tasks_response_msg_t **
msg_ptr, Buf buffer);
static void _pack_shutdown_msg(shutdown_msg_t * msg, Buf buffer);
static int _unpack_shutdown_msg(shutdown_msg_t ** msg_ptr, Buf buffer);
static void _pack_reattach_tasks_request_msg(reattach_tasks_request_msg_t *,
Buf);
static int _unpack_reattach_tasks_request_msg(reattach_tasks_request_msg_t **,
Buf);
static void
_pack_reattach_tasks_response_msg(reattach_tasks_response_msg_t *, Buf);
static int
_unpack_reattach_tasks_response_msg(reattach_tasks_response_msg_t **, Buf);
static void _pack_task_exit_msg(task_exit_msg_t * msg, Buf buffer);
static int _unpack_task_exit_msg(task_exit_msg_t ** msg_ptr, Buf buffer);
static void _pack_old_job_desc_msg(old_job_alloc_msg_t * job_desc_ptr,
Buf buffer);
static int _unpack_old_job_desc_msg(old_job_alloc_msg_t **
job_desc_buffer_ptr, Buf buffer);
static void _pack_return_code_msg(return_code_msg_t * msg, Buf buffer);
static int _unpack_return_code_msg(return_code_msg_t ** msg, Buf buffer);
static void _pack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t * build_ptr,
Buf buffer);
static int _unpack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t **
build_buffer_ptr, Buf buffer);
static void _pack_job_step_id_msg(job_step_id_t * msg, Buf buffer);
static int _unpack_job_step_id_msg(job_step_id_t ** msg_ptr, Buf buffer);
static void _pack_get_job_step_info_msg(job_step_info_request_msg_t * msg,
Buf buffer);
static int _unpack_get_job_step_info_msg(job_step_info_request_msg_t **
msg, Buf buffer);
static int _unpack_job_step_info_response_msg(job_step_info_response_msg_t
** msg, Buf buffer);
static int _unpack_job_step_info_members(job_step_info_t * step, Buf buffer);
static void _pack_complete_job_step_msg(complete_job_step_msg_t * msg,
Buf buffer);
static int _unpack_complete_job_step_msg(complete_job_step_msg_t **
msg_ptr, Buf buffer);
static int _unpack_job_info_members(job_info_t * job, Buf buffer);
static void _pack_batch_job_launch_msg(batch_job_launch_msg_t * msg,
Buf buffer);
static int _unpack_batch_job_launch_msg(batch_job_launch_msg_t ** msg,
Buf buffer);
static void _pack_job_desc_msg(job_desc_msg_t * job_desc_ptr, Buf buffer);
static int _unpack_job_desc_msg(job_desc_msg_t ** job_desc_buffer_ptr,
Buf buffer);
static int _unpack_job_info_msg(job_info_msg_t ** msg, Buf buffer);
static void _pack_last_update_msg(last_update_msg_t * msg, Buf buffer);
static int _unpack_last_update_msg(last_update_msg_t ** msg, Buf buffer);
static void _pack_slurm_addr_array(slurm_addr * slurm_address,
uint16_t size_val, Buf buffer);
static int _unpack_slurm_addr_array(slurm_addr ** slurm_address,
uint16_t * size_val, Buf buffer);
static void _pack_job_id_request_msg(job_id_request_msg_t * msg, Buf buffer);
static int _unpack_job_id_request_msg(job_id_request_msg_t ** msg, Buf buffer);
static void _pack_job_id_response_msg(job_id_response_msg_t * msg, Buf buffer);
static int _unpack_job_id_response_msg(job_id_response_msg_t ** msg,
Buf buffer);
static void _pack_job_step_kill_msg(job_step_kill_msg_t * msg, Buf buffer);
static int _unpack_job_step_kill_msg(job_step_kill_msg_t ** msg_ptr,
Buf buffer);
static void _pack_buffer_msg(slurm_msg_t * msg, Buf buffer);
/* pack_header
* packs a slurm protocol header that proceeds every slurm message
* IN header - the header structure to pack
* IN/OUT buffer - destination of the pack, contains pointers that are
void
pack_header(header_t * header, Buf buffer)
pack16(header->version, buffer);
pack16(header->flags, 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
* OUT header - the header structure to unpack
* IN/OUT buffer - source of the unpack data, contains pointers that are
int
unpack_header(header_t * header, Buf buffer)
safe_unpack16(&header->version, buffer);
safe_unpack16(&header->flags, buffer);
safe_unpack16(&tmp, buffer);
header->msg_type = (slurm_msg_type_t) tmp;
safe_unpack32(&header->body_length, buffer);
return SLURM_SUCCESS;
return SLURM_ERROR;
* packs a generic slurm protocol message body
* IN msg - the body structure to pack (note: includes message type)
* IN/OUT buffer - destination of the pack, contains pointers that are
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_msg((last_update_msg_t *)
msg->data, buffer);
break;
case RESPONSE_BUILD_INFO:
_pack_slurm_ctl_conf_msg((slurm_ctl_conf_info_msg_t *)
msg->data, buffer);
break;
case RESPONSE_JOB_INFO:
_pack_job_info_msg((slurm_msg_t *) msg, buffer);
break;
case RESPONSE_PARTITION_INFO:
_pack_partition_info_msg((slurm_msg_t *) msg, buffer);
break;
case RESPONSE_NODE_INFO:
_pack_node_info_msg((slurm_msg_t *) msg, buffer);
break;
case MESSAGE_NODE_REGISTRATION_STATUS:
_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_JOB_WILL_RUN:
case REQUEST_ALLOCATION_AND_RUN_JOB_STEP:
case REQUEST_UPDATE_JOB:
_pack_job_desc_msg((job_desc_msg_t *)
msg->data, buffer);
break;
case REQUEST_OLD_JOB_RESOURCE_ALLOCATION:
_pack_old_job_desc_msg((old_job_alloc_msg_t *) msg->data,
buffer);
break;
case REQUEST_NODE_REGISTRATION_STATUS:
case REQUEST_RECONFIGURE:
case REQUEST_SHUTDOWN_IMMEDIATE:
case REQUEST_PING:
case REQUEST_CONTROL:
/* Message contains no body/information */
break;
case REQUEST_SHUTDOWN:
_pack_shutdown_msg((shutdown_msg_t *) msg->data, buffer);
break;
case RESPONSE_SUBMIT_BATCH_JOB:
_pack_submit_response_msg((submit_response_msg_t *)
msg->data, buffer);
break;
case RESPONSE_RESOURCE_ALLOCATION:
case RESPONSE_JOB_WILL_RUN:
_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);
break;
case REQUEST_UPDATE_NODE:
_pack_update_node_msg((update_node_msg_t *) msg->data,
buffer);
break;
case REQUEST_UPDATE_PARTITION:
_pack_update_partition_msg((update_part_msg_t *) msg->
data, buffer);
break;
case REQUEST_REATTACH_TASKS:
_pack_reattach_tasks_request_msg(
(reattach_tasks_request_msg_t *) msg->data, buffer);
break;
case RESPONSE_REATTACH_TASKS:
_pack_reattach_tasks_response_msg(
(reattach_tasks_response_msg_t *) msg->data, buffer);
break;
case REQUEST_LAUNCH_TASKS:
_pack_launch_tasks_request_msg(
(launch_tasks_request_msg_t *) msg->data,
buffer);
break;
case RESPONSE_LAUNCH_TASKS:
_pack_launch_tasks_response_msg((launch_tasks_response_msg_t
*) msg->data, buffer);
break;
case REQUEST_KILL_TASKS:
_pack_cancel_tasks_msg((kill_tasks_msg_t *) msg->data,
buffer);
break;
case REQUEST_JOB_STEP_INFO:
_pack_get_job_step_info_msg((job_step_info_request_msg_t
*) msg->data, buffer);
break;
Loading
Loading full blame...