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

« back to all changes in this revision

Viewing changes to libatalk/dsi/dsi_opensess.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_opensess.c,v 1.3 2001/06/29 14:14:46 rufustfirefly 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 <string.h>
 
14
#include <sys/types.h>
 
15
 
 
16
#include <atalk/dsi.h>
 
17
 
 
18
/* OpenSession. set up the connection */
 
19
void dsi_opensession(DSI *dsi)
 
20
{
 
21
  u_int32_t i = 0; /* this serves double duty. it must be 4-bytes long */
 
22
 
 
23
  /* parse options */
 
24
  while (i < dsi->cmdlen) {
 
25
    switch (dsi->commands[i++]) {
 
26
    case DSIOPT_ATTNQUANT:
 
27
      memcpy(&dsi->attn_quantum, dsi->commands + i + 1, dsi->commands[i]);
 
28
      dsi->attn_quantum = ntohl(dsi->attn_quantum);
 
29
 
 
30
    case DSIOPT_SERVQUANT: /* just ignore these */
 
31
    default:
 
32
      i += dsi->commands[i] + 1; /* forward past length tag + length */
 
33
      break;
 
34
    }
 
35
  }
 
36
 
 
37
  /* let the client know the server quantum. we don't use the
 
38
   * max server quantum due to a bug in appleshare client 3.8.6. */
 
39
  dsi->header.dsi_flags = DSIFL_REPLY;
 
40
  /* dsi->header.dsi_command = DSIFUNC_OPEN;*/
 
41
  dsi->cmdlen = 2 + sizeof(i); /* length of data. dsi_send uses it. */
 
42
  dsi->commands[0] = DSIOPT_SERVQUANT;
 
43
  dsi->commands[1] = sizeof(i);
 
44
  i = htonl(( dsi->server_quantum < DSI_SERVQUANT_MIN || 
 
45
              dsi->server_quantum > DSI_SERVQUANT_MAX ) ? 
 
46
            DSI_SERVQUANT_DEF : dsi->server_quantum);
 
47
  memcpy(dsi->commands + 2, &i, sizeof(i));
 
48
 
 
49
  dsi_send(dsi);
 
50
}