60 lines
2.1 KiB
C
60 lines
2.1 KiB
C
/****************************************************************************
|
|
* <Novell-copyright>
|
|
* Copyright (c) 2001 Novell, Inc. All Rights Reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of version 2 of the GNU General Public License
|
|
* as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, contact Novell, Inc.
|
|
*
|
|
* To contact Novell about this file by physical or electronic mail, you
|
|
* may find current contact information at www.novell.com.
|
|
* </Novell-copyright>
|
|
****************************************************************************/
|
|
|
|
#include <arpa/inet.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "../msghttp.h"
|
|
|
|
static int
|
|
CheckAddress(int family, const char *text, int expected)
|
|
{
|
|
struct sockaddr_storage storage;
|
|
void *destination;
|
|
|
|
memset(&storage, 0, sizeof(storage));
|
|
storage.ss_family = family;
|
|
destination = family == AF_INET
|
|
? (void *)&((struct sockaddr_in *)&storage)->sin_addr
|
|
: (void *)&((struct sockaddr_in6 *)&storage)->sin6_addr;
|
|
if (inet_pton(family, text, destination) != 1 ||
|
|
MsgHttpPublicAddress((const struct sockaddr *)&storage) != expected) {
|
|
fprintf(stderr, "unexpected calendar download classification: %s\n",
|
|
text);
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
return !(CheckAddress(AF_INET, "127.0.0.1", 0) &&
|
|
CheckAddress(AF_INET, "10.0.0.1", 0) &&
|
|
CheckAddress(AF_INET, "100.64.0.1", 0) &&
|
|
CheckAddress(AF_INET, "192.0.2.1", 0) &&
|
|
CheckAddress(AF_INET, "93.184.216.34", 1) &&
|
|
CheckAddress(AF_INET6, "::1", 0) &&
|
|
CheckAddress(AF_INET6, "fd00::1", 0) &&
|
|
CheckAddress(AF_INET6, "2606:2800:220:1:248:1893:25c8:1946", 1));
|
|
}
|