ddp.c 1.7 KB
Newer Older
Phil Blundell's avatar
Phil Blundell committed
1
/*
2 3
 *              DDP protocol output functions.
 *              [Not yet input]
Phil Blundell's avatar
Phil Blundell committed
4
 *
5
 *                      Alan Cox  <Alan.Cox@linux.org>
Phil Blundell's avatar
Phil Blundell committed
6
 *
7
 *		$Id: ddp.c,v 1.6 1998/11/19 13:01:55 philip Exp $
8 9 10 11 12 13
 *
 *              This program is free software; you can redistribute it
 *              and/or  modify it under  the terms of  the GNU General
 *              Public  License as  published  by  the  Free  Software
 *              Foundation;  either  version 2 of the License, or  (at
 *              your option) any later version.
Phil Blundell's avatar
Phil Blundell committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 */
#include "config.h"

#if HAVE_AFATALK
#include <asm/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/atalk.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include "net-support.h"
#include "pathnames.h"
31
#include "intl.h"
32
#include "util.h"
Phil Blundell's avatar
Phil Blundell committed
33 34

/* Display a ddp domain address. */
35
static const char *ddp_print(const char *ptr)
Phil Blundell's avatar
Phil Blundell committed
36
{
37 38 39 40
    static char buff[64];
    struct sockaddr_at *sat = (struct sockaddr_at *) (ptr - 2);
    sprintf(buff, "%d/%d", (int) ntohs(sat->sat_addr.s_net), (int) sat->sat_addr.s_node);
    return (buff);
Phil Blundell's avatar
Phil Blundell committed
41 42 43 44
}


/* Display a ddp domain address. */
45
static const char *ddp_sprint(const struct sockaddr_storage *sasp, int numeric)
Phil Blundell's avatar
Phil Blundell committed
46
{
47
    const struct sockaddr *sap = (const struct sockaddr *)sasp;
48
    static char buf[64];
Phil Blundell's avatar
Phil Blundell committed
49

50
    if (sap->sa_family != AF_APPLETALK)
51
	return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
52
    return (ddp_print(sap->sa_data));
Phil Blundell's avatar
Phil Blundell committed
53 54 55
}


56 57 58 59 60 61 62
struct aftype ddp_aftype =
{
    "ddp", NULL, /*"Appletalk DDP", */ AF_APPLETALK, 0,
    ddp_print, ddp_sprint, NULL, NULL,
    NULL /*DDP_rprint */ , NULL, NULL,
    -1,
    "/proc/net/appletalk"
Phil Blundell's avatar
Phil Blundell committed
63 64 65
};

#endif