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