]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/recv-announce.cc
4 * $Id: recv-announce.cc,v 1.19 1998/07/20 17:20:01 wessels Exp $
6 * DEBUG: section 0 Announcement Server
7 * AUTHOR: Harvest Derived
9 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
10 * --------------------------------------------------------
12 * Squid is the result of efforts by numerous individuals from the
13 * Internet community. Development is led by Duane Wessels of the
14 * National Laboratory for Applied Network Research and funded by
15 * the National Science Foundation.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
34 * Copyright (c) 1994, 1995. All rights reserved.
36 * The Harvest software was developed by the Internet Research Task
37 * Force Research Group on Resource Discovery (IRTF-RD):
39 * Mic Bowman of Transarc Corporation.
40 * Peter Danzig of the University of Southern California.
41 * Darren R. Hardy of the University of Colorado at Boulder.
42 * Udi Manber of the University of Arizona.
43 * Michael F. Schwartz of the University of Colorado at Boulder.
44 * Duane Wessels of the University of Colorado at Boulder.
46 * This copyright notice applies to software in the Harvest
47 * ``src/'' directory only. Users should consult the individual
48 * copyright notices in the ``components/'' subdirectories for
49 * copyright information about other software bundled with the
50 * Harvest source code distribution.
54 * The Harvest software may be used and re-distributed without
55 * charge, provided that the software origin and research team are
56 * cited in any use of the system. Most commonly this is
57 * accomplished by including a link to the Harvest Home Page
58 * (http://harvest.cs.colorado.edu/) from the query page of any
59 * Broker you deploy, as well as in the query result pages. These
60 * links are generated automatically by the standard Broker
61 * software distribution.
63 * The Harvest software is provided ``as is'', without express or
64 * implied warranty, and with no support nor obligation to assist
65 * in its use, correction, modification or enhancement. We assume
66 * no liability with respect to the infringement of copyrights,
67 * trade secrets, or any patents, and are not responsible for
68 * consequential damages. Proper use of the Harvest software is
69 * entirely the responsibility of the user.
73 * Users may make derivative works from the Harvest software, subject
74 * to the following constraints:
76 * - You must include the above copyright notice and these
77 * accompanying paragraphs in all forms of derivative works,
78 * and any documentation and other materials related to such
79 * distribution and use acknowledge that the software was
80 * developed at the above institutions.
82 * - You must notify IRTF-RD regarding your distribution of
83 * the derivative work.
85 * - You must clearly notify users that your are distributing
86 * a modified version and not the original Harvest software.
88 * - Any derivative product is also subject to these copyright
89 * and use restrictions.
91 * Note that the Harvest software is NOT in the public domain. We
92 * retain copyright, as specified above.
94 * HISTORY OF FREE SOFTWARE STATUS
96 * Originally we required sites to license the software in cases
97 * where they were going to build commercial products/services
98 * around Harvest. In June 1995 we changed this policy. We now
99 * allow people to use the core Harvest software (the code found in
100 * the Harvest ``src/'' directory) for free. We made this change
101 * in the interest of encouraging the widest possible deployment of
102 * the technology. The Harvest software is really a reference
103 * implementation of a set of protocols and formats, some of which
104 * we intend to standardize. We encourage commercial
105 * re-implementations of code complying to this set of standards.
112 #include <sys/types.h>
113 #include <sys/socket.h>
114 #include <netinet/in.h>
115 #include <arpa/inet.h>
120 #define RECV_BUF_SIZE 8192
122 extern void xmemcpy(void *from
, void *to
, int len
);
125 * This program must be run from inetd. First add something like this
128 * cached_announce 3131/udp # cache announcements
130 * And then add something like this to /etc/inetd/conf:
132 * cached_announce dgram udp wait cached /tmp/recv-announce recv-announce /tmp/recv-announce.log
135 * A single instance of this process will continue to handle incoming
136 * requests. If it dies, or is killed, inetd should restart it when the
137 * next message arrives.
142 * usage: recv-announce logfile
157 main(int argc
, char *argv
[])
159 char buf
[RECV_BUF_SIZE
];
160 struct sockaddr_in R
;
162 struct hostent
*hp
= NULL
;
163 char logfile
[BUFSIZ
];
166 for (len
= 0; len
< 32; len
++) {
167 signal(len
, sig_handle
);
172 strcpy(logfile
, argv
[1]);
174 strcpy(logfile
, "/tmp/recv-announce.log");
177 if (open(logfile
, O_WRONLY
| O_CREAT
| O_APPEND
, 0660) < 0) {
186 memset(buf
, '\0', RECV_BUF_SIZE
);
187 memset(&R
, '\0', len
= sizeof(R
));
189 if (recvfrom(0, buf
, RECV_BUF_SIZE
, 0, &R
, &len
) < 0) {
193 xmemcpy(ip
, &R
.sin_addr
.s_addr
, 4);
194 hp
= gethostbyaddr(ip
, 4, AF_INET
);
195 printf("==============================================================================\n");
196 printf("Received from %s [%s]\n",
197 inet_ntoa(R
.sin_addr
),
198 (hp
&& hp
->h_name
) ? hp
->h_name
: "Unknown");