1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
/*
* MacGate - User Space interface to Appletalk-IP decapsulation.
* - Node IP registration and routing daemon.
* Written By: Jay Schulist <Jay.Schulist@spacs.k12.wi.us>
* Copyright (C) 1997-1998 Jay Schulist
*
* NBP service routines used by MacGated
*
* This software may be used and distributed according to the terms
* of the GNU Public License, incorporated herein by reference.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <signal.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netatalk/endian.h>
#include <netatalk/at.h>
#include <atalk/atp.h>
#include <atalk/nbp.h>
#include <linux/if_ether.h>
#include "MacGate.h"
/* Register ipaddr as an IPGATEWAY at port atp_skt (should be 72) */
int NBPRegIPGATEWAY(unsigned long ipaddr, int atp_skt)
{
ATP atp;
atp = atp_open(atp_skt);
if(atp == NULL)
{
syslog(LOG_ERR, "atp_open() failed");
return -1;
}
if(nbp_rgstr(atp_sockaddr(atp),in_ntoa(ipaddr),"IPGATEWAY","*") < 0)
return -1;
else
syslog(LOG_ERR, "%s registered as IPGATEWAY", in_ntoa(ipaddr));
atp_close(atp);
return 0;
}
/* UnRegister ipaddr:IPGATEWAY at port atp_skt (should be 72) */
int NBPUnRegIPGATEWAY(unsigned long ipaddr, int atp_skt)
{
if(nbp_unrgstr(in_ntoa(ipaddr),"IPGATEWAY","*") < 0)
return -1;
else
syslog(LOG_ERR, "Unregistered %s:IPGATEWAY", in_ntoa(ipaddr));
return 0;
}
/* Register ipaddr as an IPADDRESS at port atp_skt (should be 72) */
int NBPRegIPADDRESS(unsigned long ipaddr, int atp_skt)
{
ATP atp;
atp = atp_open(atp_skt);
if(atp == NULL)
{
syslog(LOG_ERR, "atp_open() failed");
return -1;
}
if(nbp_rgstr(atp_sockaddr(atp),in_ntoa(ipaddr),"IPADDRESS","*") < 0)
return -1;
else
syslog(LOG_ERR, "%s registered as IPADDRESS", in_ntoa(ipaddr));
atp_close(atp);
return 0;
}
/* UnRegister ipaddr:IPADDRESS at port atp_skt (should be 72) */
int NBPUnRegIPADDRESS(unsigned long ipaddr, int atp_skt)
{
if(nbp_unrgstr(in_ntoa(ipaddr),"IPADDRESS","*") < 0)
return -1;
else
syslog(LOG_ERR, "Unregistered %s:IPADDRESS", in_ntoa(ipaddr));
return 0;
}
|