11592Srgrimes/* 21592Srgrimes * Copyright (c) 1996 31592Srgrimes * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 41592Srgrimes * 51592Srgrimes * Redistribution and use in source and binary forms, with or without 61592Srgrimes * modification, are permitted provided that the following conditions 71592Srgrimes * are met: 81592Srgrimes * 1. Redistributions of source code must retain the above copyright 91592Srgrimes * notice, this list of conditions and the following disclaimer. 101592Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111592Srgrimes * notice, this list of conditions and the following disclaimer in the 121592Srgrimes * documentation and/or other materials provided with the distribution. 131592Srgrimes * 3. All advertising materials mentioning features or use of this software 141592Srgrimes * must display the following acknowledgement: 151592Srgrimes * This product includes software developed by Bill Paul. 161592Srgrimes * 4. Neither the name of the author nor the names of any co-contributors 171592Srgrimes * may be used to endorse or promote products derived from this software 181592Srgrimes * without specific prior written permission. 191592Srgrimes * 201592Srgrimes * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 21262435Sbrueffer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221592Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231592Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE 241592Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251592Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261592Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271592Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281592Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291592Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301592Srgrimes * SUCH DAMAGE. 311592Srgrimes */ 321592Srgrimes 331592Srgrimes#include <sys/cdefs.h> 341592Srgrimes__FBSDID("$FreeBSD: releng/11.0/usr.sbin/ypserv/yp_svc_udp.c 114601 2003-05-03 21:06:42Z obrien $"); 351592Srgrimes 361592Srgrimes#include <rpc/rpc.h> 3727074Ssteve#include <rpc/svc_dg.h> 381592Srgrimes#include "yp_extern.h" 3927074Ssteve 401592Srgrimes#define su_data(xprt) ((struct svc_dg_data *)(xprt->xp_p2)) 4169226Skris 4269226Skris/* 431592Srgrimes * We need to be able to manually set the transaction ID in the 441592Srgrimes * UDP transport handle, but the standard library offers us no way 451592Srgrimes * to do that. Hence we need this garbage. 461592Srgrimes */ 471592Srgrimes 481592Srgrimesunsigned long 491592Srgrimessvcudp_get_xid(SVCXPRT *xprt) 501592Srgrimes{ 511592Srgrimes struct svc_dg_data *su; 521592Srgrimes 531592Srgrimes if (xprt == NULL) 541592Srgrimes return(0); 551592Srgrimes su = su_data(xprt); 561592Srgrimes return(su->su_xid); 5769226Skris} 581592Srgrimes 591592Srgrimesunsigned long 601592Srgrimessvcudp_set_xid(SVCXPRT *xprt, unsigned long xid) 611592Srgrimes{ 621592Srgrimes struct svc_dg_data *su; 631592Srgrimes unsigned long old_xid; 641592Srgrimes 651592Srgrimes if (xprt == NULL) 661592Srgrimes return(0); 671592Srgrimes su = su_data(xprt); 681592Srgrimes old_xid = su->su_xid; 691592Srgrimes su->su_xid = xid; 701592Srgrimes return(old_xid); 711592Srgrimes} 721592Srgrimes