1/* 2 * $Id: dsi_tickle.c,v 1.8 2009-10-25 06:13:11 didg Exp $ 3 * 4 * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu) 5 * All rights reserved. See COPYRIGHT. 6 */ 7 8#ifdef HAVE_CONFIG_H 9#include "config.h" 10#endif /* HAVE_CONFIG_H */ 11 12#include <stdio.h> 13#include <sys/types.h> 14#include <string.h> 15#include <signal.h> 16 17#include <atalk/dsi.h> 18#include <netatalk/endian.h> 19 20/* server generated tickles. as this is only called by the tickle handler, 21 * we don't need to block signals. */ 22int dsi_tickle(DSI *dsi) 23{ 24 char block[DSI_BLOCKSIZ]; 25 u_int16_t id; 26 27 if ((dsi->flags & DSI_SLEEPING) || dsi->in_write) 28 return 1; 29 30 id = htons(dsi_serverID(dsi)); 31 32 memset(block, 0, sizeof(block)); 33 block[0] = DSIFL_REQUEST; 34 block[1] = DSIFUNC_TICKLE; 35 memcpy(block + 2, &id, sizeof(id)); 36 /* code = len = reserved = 0 */ 37 38 return dsi_stream_write(dsi, block, DSI_BLOCKSIZ, DSI_NOWAIT); 39} 40 41