srcsrpy Subroutine

Purpose

Sends a reply to a request from the System Resource Controller (SRC) back to the client process.

Library

System Resource Controller Library (libsrc.a)

Syntax

#include <spc.h>

int srcsrpy ( SRChdr,  PPacket,  PPacketSize,  Continued)

struct srchdr *SRChdr;
char *PPacket;
int PPacketSize;
ushort Continued;

Description

The srcsrpy subroutine returns a subsystem reply to a System Resource Controller (SRC) subsystem request. The format and content of the reply are determined by the subsystem and the requester, but must start with a srchdr structure. This structure and all others required for subsystem communication with the SRC are defined in the /usr/include/spc.h file. The subsystem must reply with a pre-defined format and content for the following requests: START, STOP, STATUS, REFRESH, and TRACE. The START, STOP, REFRESH, and TRACE requests must be answered with a srcrep structure. The STATUS request must be answered with a reply in the form of a statbuf structure.

Note: The srcsrpy subroutine creates its own socket to send the subsystem reply packets.

Parameters

Item Description
SRChdr Points to the reply address buffer as returned by the srcrrqs subroutine.
PPacket Points to the reply packet. The first element of the reply packet is a srchdr structure. The cont element of the PPacket->srchdr structure is modified on returning from the srcsrpy subroutine. The second element of the reply packet should be a svrreply structure, an array of statcode structures, or another format upon which the subsystem and the requester have agreed.
PPacketSize Specifies the number of bytes in the reply packet pointed to by the PPacket parameter. The PPacketSize parameter may be the size of a short, or it may be between the size of a srchdr structure and the SRCPKTMAX value, which is defined in the spc.h file.
Continued Indicates whether this reply is to be continued. If the Continued parameter is set to the constant END, no more reply packets are sent for this request. If the Continued parameter is set to CONTINUED, the second element of what is indicated by the PPacket parameter must be a svrreply structure, since the rtnmsg element of the svrreply structure is printed to standard output. For a status reply, the Continued parameter is set to STATCONTINUED, and the second element of what is pointed to by the PPacket parameter must be an array of statcode structures. If a STOP subsystem request is received, only one reply packet can be sent and the Continued parameter must be set to END. Other types of continuations, as determined by the subsystem and the requester, must be defined using positive values for the Continued parameter. Values other than the following must be used:
0
END
1
CONTINUED
2
STATCONTINUED

Return Values

If the srcsrpy subroutine succeeds, it returns the value SRC_OK.

Error Codes

The srcsrpy subroutine fails if one or both of the following are true:

Item Description
SRC_SOCK There is a problem with SRC socket communications.
SRC_REPLYSZ SRC reply size is invalid.

Examples

  1. To send a STOP subsystem reply, enter:
    struct srcrep return_packet;
    struct srchdr *srchdr;
     
    bzero(&return_packet,sizeof(return_packet));
    return_packet.svrreply.rtncode=SRC_OK;
    strcpy(return_packet.svrreply,"srctest");
     
    srcsrpy(srchdr,return_packet,sizeof(return_packet),END);

    This entry sends a message that the subsystem srctest is stopping successfully.

  2. To send a START subserver reply, enter:
    struct srcrep return_packet;
    struct srchdr *srchdr;
     
    bzero(&return_packet,sizeof(return_packet));
    return_packet.svrreply.rtncode=SRC_SUBMSG;
    strcpy(return_packet.svrreply,objname,"mysubserver");
    strcpy(return_packet.svrreply,objtext,"The subserver,\
    mysubserver, has been started");
     
    srcsrpy(srchdr,return_packet,sizeof(return_packet),END);

    The resulting message indicates that the start subserver request was successful.

  3. To send a status reply, enter:
    int rc;
    struct sockaddr addr;
    int addrsz;
    struct srcreq packet;
    struct
    {
       struct srchdr srchdr;
       struct statcode statcode[10];
    } status;
    struct srchdr *srchdr;
    struct srcreq packet;
       .
       .
       .
    /* grab the reply information from the SRC packet */
    srchdr=srcrrqs(&packet);
    bzero(&status.statcode[0].objname,
     
    /* get SRC status header */
    srcstathdr(status.statcode[0].objname,
      status.statcode[0].objtext);
       .
       .
       .
    /* send status packet(s) */
    srcsrpy(srchdr,&status,sizeof(status),STATCONTINUED);
       .
       .
       .
    srcsrpy(srchdr,&status,sizeof(status),STATCONTINUED);
     
    /* send final packet */
    srcsrpy(srchdr,&status,sizeof(struct srchdr),END);
      

    This entry sends several status packets.

Files

Item Description
/dev/.SRC-unix Specifies the location for temporary socket files.