~ubuntu-branches/ubuntu/precise/netatalk/precise

« back to all changes in this revision

Viewing changes to libatalk/dsi/dsi_tickle.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Rittau
  • Date: 2004-01-19 12:43:49 UTC
  • Revision ID: james.westby@ubuntu.com-20040119124349-es563jbp0hk0ae51
Tags: upstream-1.6.4
ImportĀ upstreamĀ versionĀ 1.6.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: dsi_tickle.c,v 1.3.8.1 2003/11/18 21:47:41 bfernhomberg 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. well, actually, we might get it during
 
22
 * a SIGHUP. */
 
23
int dsi_tickle(DSI *dsi)
 
24
{
 
25
  char block[DSI_BLOCKSIZ];
 
26
  sigset_t oldset;
 
27
  u_int16_t id;
 
28
  int ret;
 
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
  sigprocmask(SIG_BLOCK, &dsi->sigblockset, &oldset);
 
39
  ret = dsi_stream_write(dsi, block, DSI_BLOCKSIZ) == DSI_BLOCKSIZ;
 
40
  sigprocmask(SIG_SETMASK, &oldset, NULL);
 
41
  return ret;
 
42
}
 
43