/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos72Q src/bos/kernel/sys/sock_api.h 1.4                               */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* Restricted Materials of IBM                                            */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2009,2019              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)16       1.4  src/bos/kernel/sys/sock_api.h, sysuipc, bos72Q, q2019_13A4 2/6/19 00:40:41 */

/*
 *   NAME: sock_api.h
 *
 *   DESC: Definitions for the pidAddr facility
 *
 *   COMPONENT_NAME: SYSUIPC
 *
 *   MACROS: CMSG_DATA
 *           CMSG_FIRSTHDR
 *           CMSG_NXTHDR
 *           CMSG_ALIGN
 *           CMSG_SPACE
 *           CMSG_LEN
 *
 *   ORIGINS: 26,27,85
 *
 */

#ifndef _SOCK_API_H
#define _SOCK_API_H

#include <netinet/in.h>

#ifdef __cplusplus
extern "C" {
#endif

/* -------------------------------------------------------------------------------------
// Definitions
*/

#define PAVERSION       1

typedef struct pidAddr
{
    int paVersion;                     /* Version number */
    int paElmCnt;                      /* Count of element array       */
    struct paPair
    {
        short paType;                  /* Protocol type                */
        short paProtocol;              /* Protocol Number              */
        union
        {
            struct sockaddr_in pa4;    /* IPv4 address                 */
            struct sockaddr_in6 pa6;   /* IPv6 address                 */

        } paSrc, paDst;

    } paElm[1];                        /* Array src and dst addresses  */

#define PAELMSRC(i)       paElm[i].paSrc
#define PAELMDST(i)       paElm[i].paDst
#define PAELMTYPE(i)      paElm[i].paType
#define PAELMPROTOCOL(i)  paElm[i].paProtocol

#define PAELMSRCFAMILY(pa, i) ((struct sockaddr *)&pa->PAELMSRC(i))->sa_family

} pidAddr_t;

/* -------------------------------------------------------------------------------------
// Function Prototypes
*/

kerrno_t getPidAddr(pid_t id, pidAddr_t **pa);

void freePidAddr(pidAddr_t *pa);

#ifdef __cplusplus
}
#endif

#endif

