/*
SSSD
SSS Client Responder, command parser
Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <errno.h>
#include <talloc.h>
#include "responder/common/responder_packet.h"
struct sss_packet {
/* Structure of the buffer:
* Bytes Content
* ---------------------------------
* 0-15 packet header
* 0-3 packet length (uint32_t)
* 4-7 command type (uint32_t)
* 8-11 status (uint32_t)
* 12-15 reserved
* 16+ packet body */
/* io pointer */
};
/* Offsets to data in sss_packet's buffer */
#define SSS_PACKET_LEN_OFFSET 0
enum sss_cli_command cmd);
/*
* Allocate a new packet structure
*
* - if size is defined use it otherwise the default packet will be
* SSSSRV_PACKET_MEM_SIZE bytes.
*/
enum sss_cli_command cmd,
struct sss_packet **rpacket)
{
if (size) {
} else {
}
return ENOMEM;
}
return EOK;
}
/* grows a packet size only in SSSSRV_PACKET_MEM_SIZE chunks */
{
if (size == 0) {
return EOK;
}
/* make sure we do not overflow */
totlen += n * SSSSRV_PACKET_MEM_SIZE;
return EINVAL;
}
}
if (!newmem) {
return ENOMEM;
}
/* re-set pointers if realloc had to move memory */
}
}
packet_len += size;
return 0;
}
/* reclaim backet previously resrved space in the packet
* usually done in functione recovering from not fatal erros */
{
return 0;
}
{
/* make sure we do not overflow */
return 0;
}
{
void *buf;
int ret;
/* check for wrapping */
return EINVAL;
}
errno = 0;
if (rb == -1) {
return EAGAIN;
} else {
return errno;
}
}
if (rb == 0) {
return ENODATA;
}
/* Allow certificate based requests to use larger buffer but not
* larger than SSS_CERT_PACKET_MAX_RECV_SIZE. Due to the way
* sss_packet_grow() works the packet len must be set to '0' first and
* then grow to the expected size. */
sss_packet_set_len(packet, 0);
return ret;
}
} else {
return EINVAL;
}
}
return EAGAIN;
}
return EAGAIN;
}
return EOK;
}
{
void *buf;
if (!packet) {
/* No packet object to write to? */
return EINVAL;
}
errno = 0;
if (rb == -1) {
return EAGAIN;
} else {
return errno;
}
}
if (rb == 0) {
return EIO;
}
return EAGAIN;
}
return EOK;
}
{
return (enum sss_cli_command)cmd;
}
{
NULL);
return status;
}
{
}
{
NULL);
}
{
}
enum sss_cli_command cmd)
{
}
{
return len;
}