1*aea60beeSderaadt /* $OpenBSD: bootparam_prot.x,v 1.10 2015/01/16 16:48:51 deraadt Exp $ */ 2c7940187Sniklas 3df930be7Sderaadt /* 4cb7760d1Smillert * Copyright (c) 2010, Oracle America, Inc. 5df930be7Sderaadt * 6cb7760d1Smillert * Redistribution and use in source and binary forms, with or without 7cb7760d1Smillert * modification, are permitted provided that the following conditions are 8cb7760d1Smillert * met: 9df930be7Sderaadt * 10cb7760d1Smillert * * Redistributions of source code must retain the above copyright 11cb7760d1Smillert * notice, this list of conditions and the following disclaimer. 12cb7760d1Smillert * * Redistributions in binary form must reproduce the above 13cb7760d1Smillert * copyright notice, this list of conditions and the following 14cb7760d1Smillert * disclaimer in the documentation and/or other materials 15cb7760d1Smillert * provided with the distribution. 16cb7760d1Smillert * * Neither the name of the "Oracle America, Inc." nor the names of its 17cb7760d1Smillert * contributors may be used to endorse or promote products derived 18cb7760d1Smillert * from this software without specific prior written permission. 19df930be7Sderaadt * 20cb7760d1Smillert * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21cb7760d1Smillert * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22cb7760d1Smillert * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23cb7760d1Smillert * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24cb7760d1Smillert * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25cb7760d1Smillert * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26cb7760d1Smillert * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 27cb7760d1Smillert * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28cb7760d1Smillert * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29cb7760d1Smillert * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30cb7760d1Smillert * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31cb7760d1Smillert * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32df930be7Sderaadt */ 33df930be7Sderaadt 34df930be7Sderaadt /* 358868c5b2Sderaadt * RPC for bootparams service. 36df930be7Sderaadt * There are two procedures: 37df930be7Sderaadt * WHOAMI takes a net address and returns a client name and also a 38df930be7Sderaadt * likely net address for routing 39df930be7Sderaadt * GETFILE takes a client name and file identifier and returns the 40df930be7Sderaadt * server name, server net address and pathname for the file. 41df930be7Sderaadt * file identifiers typically include root, swap, pub and dump 42df930be7Sderaadt */ 43df930be7Sderaadt 44df930be7Sderaadt #ifdef RPC_HDR 45*aea60beeSderaadt %#include <sys/types.h> 46df930be7Sderaadt %#include <rpc/types.h> 47df930be7Sderaadt %#include <sys/time.h> 48df930be7Sderaadt %#include <sys/ucred.h> 49ae5feee3Smillert %#include <errno.h> 50df930be7Sderaadt #endif 51df930be7Sderaadt 52df930be7Sderaadt const MAX_MACHINE_NAME = 255; 53df930be7Sderaadt const MAX_PATH_LEN = 1024; 54df930be7Sderaadt const MAX_FILEID = 32; 55df930be7Sderaadt const IP_ADDR_TYPE = 1; 56df930be7Sderaadt 57df930be7Sderaadt typedef string bp_machine_name_t<MAX_MACHINE_NAME>; 58df930be7Sderaadt typedef string bp_path_t<MAX_PATH_LEN>; 59df930be7Sderaadt typedef string bp_fileid_t<MAX_FILEID>; 60df930be7Sderaadt 61df930be7Sderaadt struct ip_addr_t { 62df930be7Sderaadt char net; 63df930be7Sderaadt char host; 64df930be7Sderaadt char lh; 65df930be7Sderaadt char impno; 66df930be7Sderaadt }; 67df930be7Sderaadt 68df930be7Sderaadt union bp_address switch (int address_type) { 69df930be7Sderaadt case IP_ADDR_TYPE: 70df930be7Sderaadt ip_addr_t ip_addr; 71df930be7Sderaadt }; 72df930be7Sderaadt 73df930be7Sderaadt struct bp_whoami_arg { 74df930be7Sderaadt bp_address client_address; 75df930be7Sderaadt }; 76df930be7Sderaadt 77df930be7Sderaadt struct bp_whoami_res { 78df930be7Sderaadt bp_machine_name_t client_name; 79df930be7Sderaadt bp_machine_name_t domain_name; 80df930be7Sderaadt bp_address router_address; 81df930be7Sderaadt }; 82df930be7Sderaadt 83df930be7Sderaadt struct bp_getfile_arg { 84df930be7Sderaadt bp_machine_name_t client_name; 85df930be7Sderaadt bp_fileid_t file_id; 86df930be7Sderaadt }; 87df930be7Sderaadt 88df930be7Sderaadt struct bp_getfile_res { 89df930be7Sderaadt bp_machine_name_t server_name; 90df930be7Sderaadt bp_address server_address; 91df930be7Sderaadt bp_path_t server_path; 92df930be7Sderaadt }; 93df930be7Sderaadt 94df930be7Sderaadt program BOOTPARAMPROG { 95df930be7Sderaadt version BOOTPARAMVERS { 96df930be7Sderaadt bp_whoami_res BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1; 97df930be7Sderaadt bp_getfile_res BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2; 98df930be7Sderaadt } = 1; 99df930be7Sderaadt } = 100026; 100