ddns3-client-1.8.orig/0040755000175700001440000000000007636250520013330 5ustar imlusersddns3-client-1.8.orig/GNUmakefile0100644000175700001440000000205107515776110015401 0ustar imlusers# # ddns3 makefile # # Author: Alan Yates # Version: $Id: GNUmakefile,v 1.1.1.1 2002/07/19 11:47:20 alany Exp $ # # tools AR=ar CC=gcc CFLAGS=-Wall -O2# -D_DEBUG RANLIB=ranlib INSTALL=install # install prefix PREFIX=/usr/local # system dependent libraries to link DEFAULT_LIBS=-lcrypt LINUX_LIBS=-lcrypt SOLARIS_LIBS=-lcrypt -lsocket -lnsl -lresolv OPENBSD_LIBS=-lcrypto # compile magic hacks SYSTEM=$(shell uname -s | tr "[A-Z]" "[a-z]") RELEASE=$(shell uname -r) ifeq ($(SYSTEM),linux) LIBS=$(LINUX_LIBS) endif ifeq ($(SYSTEM),sunos) LIBS=$(SOLARIS_LIBS) endif ifeq ($(SYSTEM),openbsd) LIBS=$(OPENBSD_LIBS) endif ifndef LIBS LIBS=$(DEFAULT_LIBS) endif all: ddns3 ddns3: ddns3.c libddns3.a $(CC) $(CFLAGS) $(LIBS) ddns3.c libddns3.a -o ddns3 libddns3.a: sockio.o crypto.o auth.o md5.o ctx.o $(AR) -cr libddns3.a *.o $(RANLIB) libddns3.a install: ddns3 $(INSTALL) -s ddns3 $(PREFIX)/bin/ $(INSTALL) ddns3.1 $(PREFIX)/man/man1/ uninstall: rm -f $(PREFIX)/bin/ddns3 $(PREFIX)/man/man1/ddns3.1 clean: rm -f *.o core *.a ddns3 ddns3-client-1.8.orig/CHANGES0100644000175700001440000000150007515776110014320 0ustar imlusers# # CHANGES # Author: Alan Yates # Version: $Id: CHANGES,v 1.1.1.1 2002/07/19 11:47:20 alany Exp $ # 2002-07-19 * added Andrew King's changes for OpenBSD compile * moved Makefile to GNUmakefile as it uses GNU make specifics 2002-07-11 * added Daniel Potts' patch to compile on 64-bit alphas * changed Makefile to be a bit more sane/conventional * added hacks to autocompile on solaris * added back the manpage, thanks again to Scott Fagg for providing the first one 2001-10-06 * removed -s argument to ar in favour of the more portable use of ranlib * Support for remote as well as local IP guessing * Argument parsing totally re-written to match the Java client * Removal of Scott Fagg's manpage (result of above, hopefully only briefly) * Bugfix in the ddns3_ctx_list() method, second call to it could crash ddns3-client-1.8.orig/COPYING0100644000175700001440000004362107515776110014372 0ustar imlusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy 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. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ddns3-client-1.8.orig/crypto.c0100644000175700001440000000211207515776110015011 0ustar imlusers/* * DDNS v3 Client * * Author: Alan Yates * Version: $Id: crypto.c,v 1.1.1.1 2002/07/19 11:47:20 alany Exp $ */ #define _XOPEN_SOURCE #ifdef WIN32 #include #else #include #endif #include #include #include "md5.h" static char *hex(char *s, int len) { int i; char *buf = (char *) calloc((len * 2) + 1, sizeof(char)); for(i = 0; i < len; i++) sprintf(&(buf[i*2]), "%.2x", s[i] & 0xff); buf[len*2] = 0; return buf; } char *ddns3_crypto_md5hash(char *s, int len) { MD5_CTX context; char *buf = (char *) calloc(MD5_DIGEST_CHARS, sizeof(char)); char *str = (char *) calloc(len, sizeof(char)); memcpy(str, s, len); MD5Init(&context); MD5Update(&context, str, len); MD5Final(buf, &context); free(str); str = hex(buf, MD5_DIGEST_CHARS); free(buf); return str; } #ifndef WIN32 char *ddns3_crypto_crypt(char *key, char *salt) { char *buf = (char *) calloc(14, sizeof(char)); memcpy(buf, crypt(key, salt), 13); buf[13] = 0; return buf; } #endif ddns3-client-1.8.orig/auth.c0100644000175700001440000000620007515776110014434 0ustar imlusers/* * DDNS v3 Client * * Author: Alan Yates * Version: $Id: auth.c,v 1.1.1.1 2002/07/19 11:47:20 alany Exp $ */ #define _XOPEN_SOURCE #ifdef WIN32 #include #include #else #include #endif #include #include "ctx.h" #include "auth.h" #include "crypto.h" #include #include #include static char *ddns3_auth_salts = "abcdefghijklmnopqrstuzwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890./"; static int auth_plaintext(struct ddns3_ctx *c, char *user, char *passwd) { if(!strstr(c->hello, "plaintext")) return -1; sprintf(c->buf, "LOGIN %s %s", user, passwd); return 0; } #ifndef WIN32 static int auth_crypt(struct ddns3_ctx *c, char *user, char *passwd) { char salt[2]; char *hash; if(!strstr(c->hello, "crypt")) return -1; srand(getpid() * time(0)); salt[0] = ddns3_auth_salts[rand() % strlen(ddns3_auth_salts)]; salt[1] = ddns3_auth_salts[rand() % strlen(ddns3_auth_salts)]; hash = ddns3_crypto_crypt(passwd, salt); sprintf(c->buf, "LOGIN %s %s", user, hash); free(hash); return 0; } #endif static int auth_md5(struct ddns3_ctx *c, char *user, char *passwd) { char *hash; if(!strstr(c->hello, "md5")) return -1; hash = ddns3_crypto_md5hash(passwd, strlen(passwd)); sprintf(c->buf, "LOGIN %s %s", user, hash); free(hash); return 0; } static int auth_ddns(struct ddns3_ctx *c, char *user, char *passwd) { char *hash, *p; char buf[4096]; if(!strstr(c->hello, "ddns")) return -1; strcpy(buf, passwd); strcat(buf, ":"); p = strstr(c->hello, "ddns{"); strncat(buf, p+5, 32); hash = ddns3_crypto_md5hash(buf, strlen(buf)); sprintf(c->buf, "LOGIN %s %s", user, hash); free(hash); return 0; } /* FIXME: there is no server support for strong auth yet */ static int auth_strong(struct ddns3_ctx *c, char *user, char *passwd) { char *phash, *uhash, *challenge, *p; char buf[4096]; int i; if(!strstr(c->hello, "ddns")) return -1; /* password hash */ strcpy(buf, passwd); strcat(buf, ":"); p = strstr(c->hello, "ddns{"); strncat(buf, p+5, 32); phash = ddns3_crypto_md5hash(buf, strlen(buf)); /* random challenge */ srand(getpid() * time(0)); for(i = 0; i < 100; i++) buf[i] = rand(); challenge = ddns3_crypto_md5hash(buf, 100); /* username hash */ strcpy(buf, user); strcat(buf, ":"); strncat(buf, challenge, 32); uhash = ddns3_crypto_md5hash(buf, strlen(buf)); sprintf(c->buf, "LOGIN %s %s %s", uhash, phash, challenge); free(uhash); free(phash); free(challenge); return 0; } static struct ddns3_auth known_auths[] = { {"plaintext", auth_plaintext}, #ifndef WIN32 {"crypt", auth_crypt}, #endif {"md5", auth_md5}, {"ddns", auth_ddns}, {"strong", auth_strong}, {0, 0} }; int ddns3_auth_makechallenge(struct ddns3_ctx *c, char *auth, char *user, char *passwd) { int i; int ret = -2; for(i = 0; known_auths[i].name; i++) if(!strcmp(known_auths[i].name, auth)) { ret = known_auths[i].makechallenge(c, user, passwd); break; } if(ret < -1) strcpy(c->buf, "client_error: authentication type unknown to client\n"); else if(ret < 0) strcpy(c->buf, "client_error: authentication type not supported by server\n"); return ret; } ddns3-client-1.8.orig/auth.h0100644000175700001440000000062707515776110014450 0ustar imlusers/* * DDNS v3 Client * * Author: Alan Yates * Version: $Id: auth.h,v 1.1.1.1 2002/07/19 11:47:20 alany Exp $ */ #ifndef _AUTH_H #define _AUTH_H #include "ctx.h" struct ddns3_auth { char *name; int (*makechallenge)(struct ddns3_ctx *c, char *user, char *passwd); }; int ddns3_auth_makechallenge(struct ddns3_ctx *c, char *auth, char *user, char *passwd); #endif /* _AUTH_H */ ddns3-client-1.8.orig/crypto.h0100644000175700001440000000045007515776110015021 0ustar imlusers/* * DDNS v3 Client * * Author: Alan Yates * Version: $Id: crypto.h,v 1.1.1.1 2002/07/19 11:47:20 alany Exp $ */ #ifndef _CRYPTO_H #define _CRYPTO_H char *ddns3_crypto_md5hash(char *s, int len); char *ddns3_crypto_crypt(char *key, char *salt); #endif /* _CRYPTO_H */ ddns3-client-1.8.orig/ctx.c0100644000175700001440000001151507515776110014276 0ustar imlusers/* * DDNS v3 Client * * Author: Alan Yates * Version: $Id: ctx.c,v 1.1.1.1 2002/07/19 11:47:20 alany Exp $ */ #include "ctx.h" #include "sockio.h" #include "auth.h" #ifdef WIN32 #include #else #include #endif #include #include #include #ifdef _DEBUG #define DEBUG(x) x #else #define DEBUG(x) #endif /* _DEBUG */ static int ctxsend(struct ddns3_ctx *c, char *cmd) { int ret; ret = sprintf(c->buf, "%s\r\n", cmd); ret = ddns3_sockio_write(c->sock, c->buf, ret); if(ret < 0) return -1; DEBUG( printf(">>> %s", c->buf); ) return 0; } static int recvline(struct ddns3_ctx *c) { int ret; /* FIXME: we expect atomic line reception, fairly evil stuff */ ret = ddns3_sockio_read(c->sock, c->buf, DDNS3_BUF); if(ret < 0) return -1; c->buf[ret] = 0; DEBUG( printf("<<< %s", c->buf); ) if(!strncmp(c->buf, "+OK", 3)) return T_OK; if(!strncmp(c->buf, "-ERR", 4)) return T_ERR; if(!strncmp(c->buf, "@RET", 4)) return T_RET; if(!strncmp(c->buf, "DDNS", 4)) return T_DDNS; if(!strncmp(&(c->buf[ret-3]), ".\r\n", 3)) return T_DOT; return -1; } static int recvlist(struct ddns3_ctx *c) { int ret, i = 0; char *p1, *p2, **lp = 0; char handle[128], ip[16]; if(c->list) { for(i = 0; c->list[i]; i++) free(c->list[i]); free(c->list); c->list = 0; } /* FIXME: we excpect atomic list reception, evil! */ ret = recvline(c); if(ret != T_DOT) return -1; c->buf[strlen(c->buf) - 3] = 0; /* parse the list we get back, yuck */ i = 0; p2 = c->buf; lp = (char **) realloc(lp, (i + 1) * sizeof(char *)); while((p1 = strtok(p2, "\n"))) { i += 2; lp = (char **) realloc(lp, (i + 1) * sizeof(char *)); sscanf(p1, "%s%s", handle, ip); lp[i-2] = strdup(handle); lp[i-1] = strdup(ip); lp[i] = 0; p2 = 0; } c->list = lp; return 0; } int ddns3_ctx_new(struct ddns3_ctx **c, char *host, int port) { /* allocate context */ *c = (struct ddns3_ctx *) calloc(1, sizeof(struct ddns3_ctx)); if(!(*c)) { perror("calloc()"); return -1; } /* set URL */ sprintf((*c)->buf, "%s:%hd", host, (short) port); (*c)->url = (char *) strdup((*c)->buf); /* initialize sockets */ ddns3_sockio_init(); return 0; } int ddns3_ctx_del(struct ddns3_ctx **c) { int i = 0; char *p; /* just in case */ ddns3_sockio_close((*c)->sock); if((*c)->url) free((*c)->url); if((*c)->hello) free((*c)->hello); if((*c)->list) { for(p = (*c)->list[i]; p; p = (*c)->list[++i]) free(p); free((*c)->list); } free(*c); *c = 0; /* clean up socket library */ ddns3_sockio_cleanup(); return 0; } int ddns3_ctx_connect(struct ddns3_ctx *c) { int ret; /* connect to server */ DEBUG( printf("connect(%s)... ", c->url); ) ret = ddns3_sockio_connect(c->url); if(ret < 0) return -1; c->sock = ret; DEBUG( printf("OK\n"); ) /* grab opening header */ ret = recvline(c); if(ret != T_DDNS) return -1; c->hello = strdup(c->buf); return 0; } int ddns3_ctx_disconnect(struct ddns3_ctx *c) { int ret; /* QUIT */ ret = ctxsend(c, "QUIT"); if(ret < 0) return -1; /* reply */ ret = recvline(c); if(ret != T_OK) return -1; /* close socket */ ddns3_sockio_close(c->sock); return 0; } int ddns3_ctx_login(struct ddns3_ctx *c, char *auth, char *user, char *passwd) { int ret; char buf[4096]; /* build challenge command */ ret = ddns3_auth_makechallenge(c, auth, user, passwd); if(ret < 0) return -1; /* LOGIN */ strcpy(buf, c->buf); ret = ctxsend(c, buf); if(ret < 0) return -1; /* reply */ ret = recvline(c); if(ret != T_OK) return -1; return 0; } int ddns3_ctx_logout(struct ddns3_ctx *c) { int ret; /* LOGOUT */ ret = ctxsend(c, "LOGOUT"); if(ret < 0) return -1; /* reply */ ret = recvline(c); if(ret != T_OK) return -1; return 0; } int ddns3_ctx_list(struct ddns3_ctx *c) { int ret; /* LIST */ ret = ctxsend(c, "LIST"); if(ret < 0) return -1; /* get returned value */ ret = recvline(c); if(ret != T_RET) return -1; ret = recvlist(c); if(ret < 0) return -1; return 0; } int ddns3_ctx_set(struct ddns3_ctx *c, char *handle, char *ip) { int ret; char buf[4096]; /* SET */ ret = sprintf(buf, "SET %s %s", handle, ip); ret = ctxsend(c, buf); if(ret < 0) return -1; /* reply */ ret = recvline(c); if(ret != T_OK) return -1; return 0; } int ddns3_ctx_guess(struct ddns3_ctx *c, char *handle, int type) { int ret, i = 0; char buf[4096], ipbuf[32], *p, *q; /* SET */ switch(type) { case GUESS_LOCAL: ret = ddns3_sockio_getlocalip(c->sock, ipbuf, 32); break; case GUESS_REMOTE: if(!(p = strstr(c->hello, "sourceIP{"))) return -1; if(!(q = strstr(p, "}"))) return -1; for(p += 9; p < q; p++) ipbuf[i++] = *p; ipbuf[i] = 0; break; default: return -1; } ret = sprintf(buf, "SET %s %s", handle, ipbuf); ret = ctxsend(c, buf); if(ret < 0) return -1; /* reply */ ret = recvline(c); if(ret != T_OK) return -1; return 0; } ddns3-client-1.8.orig/ctx.h0100644000175700001440000000164107515776110014302 0ustar imlusers/* * DDNS v3 Client * * Author: Alan Yates * Version: $Id: ctx.h,v 1.1.1.1 2002/07/19 11:47:20 alany Exp $ */ #ifndef _CTX_H #define _CTX_H #define T_OK 1 #define T_ERR 2 #define T_RET 3 #define T_DDNS 4 #define T_DOT 5 #define DDNS3_BUF 4096 #define GUESS_LOCAL 1 #define GUESS_REMOTE 2 struct ddns3_ctx { int sock; char *url; char *hello; char buf[DDNS3_BUF]; char **list; }; int ddns3_ctx_new(struct ddns3_ctx **c, char *host, int port); int ddns3_ctx_del(struct ddns3_ctx **c); int ddns3_ctx_connect(struct ddns3_ctx *c); int ddns3_ctx_disconnect(struct ddns3_ctx *c); int ddns3_ctx_login(struct ddns3_ctx *c, char *auth, char *user, char *passwd); int ddns3_ctx_logout(struct ddns3_ctx *c); int ddns3_ctx_list(struct ddns3_ctx *c); int ddns3_ctx_set(struct ddns3_ctx *c, char *handle, char *ip); int ddns3_ctx_guess(struct ddns3_ctx *c, char *handle, int type); #endif /* _CTX_H */ ddns3-client-1.8.orig/ddns3.10100644000175700001440000000752107636247767014452 0ustar imlusers.TH DDNS3 1 "$Date: 2003/03/20 05:21:59 $" .SH NAME ddns3 \- ddns.nu remote update client .SH SYNOPSIS .B ddns3 --user .I user .B --pass .I password .B [ .I options .B ] .I command .B ... .SH DESCRIPTION .B ddns3 updates IP-Handles on the ddns.nu remote update server. This allows remote automated updates rather than using the website via a browser. .SH OPTIONS .IP "--user user" Specifies the username to authenticate with. .IP "--pass password" Specifies the password to authenticate with. .IP "--host hostname" Override the default server hostname to connect to. The default server hostname is .B ns.ddns.nu. .IP "--port portnumber" Override the default TCP port to connect to. The default TCP port for the ddns3 protocol is .B 2164 .IP "--auth authtype" Specify what type of authentication protocol to use. The available types are: .B plaintext, .B crypt, .B md5, .B ddns, and .B strong. The default type is .B ddns which is secure in the sense that the username is sent in cleartext, but the password is sent hashed in such a manner as to defeat replay attacks by utilising a salt sent from the server. .SH COMMANDS .IP "list" List all IP-Handles and their current values for the account. You may do this multiple times, for example it is perfectly legal (and perhaps even useful) to do a .B list, followed by a .B set, and then another .B list to observe the change. .IP "set handle-name ip-value" Set an IP-Handle named .B handle-name to the IP value .B ip-value. Similar to .B list you can specify as many such operations on the command line as you wish and they will be executed in the order specified. .IP "guess handle-name ip-source" Set the IP-Handle named .B handle-name to the IP value derived from IP seen by the .B ip-source end of the update connection. The .B ip-source is specified as either .B remote or .B local. Again you may specify multiple .B guess commands on the command line and they will be executed in order. Using the .B local option saves you from having to specify the IP on the command line. Local guessing usually gets the IP correct as it takes the local address of the socket making the update connection. With conventional routing arrangements this is likely to be the IP you want. However the .B remote option sets the IP-Handle to the IP that the server sees the connection as originating from. This is most useful if you are running the client from behind a NAT gateway which itself is incapable of running the client. In this case the IP of the NAT gateway is used, rather than the probably martian IP of the host the client is actually executing on. .SH DIAGNOSTICS Useful error messages are produced on stderr, all other runtime output goes to stdout. On runtime exception the return value of the process may be useful in scripting: -1 .RS The usage message was generated by running the command with no arguments. .RE -2 .RS The argument parser didn't like the command line. .RE -3 .RS A connection could not be established with the update server. .RE -4 .RS Authentication failed. .RE -5 .RS Network errors closing the connection (these can often be ignored). .RE -6 .RS Some kind of internal logic error in the process, like a malloc/free failure. .RE The process returns a positive count of the number of commands executed on the server that generated an error, or zero on error free completion of all commands. .SH BUGS The authentication details should be read from a file to avoid their visibility in the process list. There should be support for other ddns3 protocol primitives like .B MOTD and .B HELP for completeness. The java implementation .B jddns3 does this, and is largely command line equivalent. Short network writes are unchecked in at least one place. .SH AUTHOR Alan Yates .SH VERSION $Id: ddns3.1,v 1.2 2003/03/20 05:21:59 alany Exp $ .SH "SEE ALSO" http://www.ddns.nu/ http://www.ddns.nu/files/ddns-v3.txt ddns3-client-1.8.orig/ddns3.c0100644000175700001440000001422207636247767014530 0ustar imlusers/* * DDNS v3 Client * * Author: Alan Yates * Win32 Port: Kieron Briggs * Version: $Id: ddns3.c,v 1.2 2003/03/20 05:21:59 alany Exp $ */ #include #ifdef WIN32 #include #define strcasecmp(x,y) stricmp((x),(y)) else #include #endif #include #include #include "ctx.h" #define ERR_USAGE -1 #define ERR_ARGUMENTS -2 #define ERR_CONNECTION -3 #define ERR_AUTH -4 #define ERR_CLOSING -5 #define ERR_LOGIC -6 struct client_vars { char *host; char *port; char *auth; char *user; char *pass; int debug; } CV; static void help(void) { fprintf(stderr, "\n"); fprintf(stderr, "DDNS Client v3 (c) :: http://www.ddns.nu/\n"); fprintf(stderr, "(c) 1999-2002 Alan Yates \n"); fprintf(stderr, "$Id: ddns3.c,v 1.2 2003/03/20 05:21:59 alany Exp $\n"); fprintf(stderr, "\n"); fprintf(stderr, "Usage: ddns3 [optional args] \n"); fprintf(stderr, "\n"); fprintf(stderr, "Required args\n"); fprintf(stderr, " --user username\n"); fprintf(stderr, " --pass password\n"); fprintf(stderr, "Optional args\n"); fprintf(stderr, " --host server-hostname specify server host\n"); fprintf(stderr, " --port server-tcp-port specify server port\n"); fprintf(stderr, " --debug activate debug mode\n"); fprintf(stderr, " --auth auth-name specify authentication type\n"); fprintf(stderr, "Authentication types:\n"); #ifdef WIN32 fprintf(stderr, " plaintext, md5, ddns (default), strong\n"); #else fprintf(stderr, " plaintext, crypt, md5, ddns (default), strong\n"); #endif fprintf(stderr, "Actions:\n"); fprintf(stderr, " list lists IP-Handles\n"); fprintf(stderr, " set sets an IP-Handle's value\n"); fprintf(stderr, " guess sets an IP-Handle's value\n"); fprintf(stderr, " guessing the IP from the \n"); fprintf(stderr, " end of the connection, ends are\n"); fprintf(stderr, " named 'remote' or 'local'\n"); fprintf(stderr, "\n"); } static int parse_args(int argc, char **argv, char **env) { int i; if(argc == 1) { help(); exit(ERR_USAGE); } for(i = 1; i < argc; i++) { if(!strcmp("--user", argv[i]) && i+1 < argc) { CV.user = argv[++i]; } else if(!strcmp("--pass", argv[i]) && i+1 < argc) { CV.pass = argv[++i]; } else if(!strcmp("--host", argv[i]) && i+1 < argc) { CV.host = argv[++i]; } else if(!strcmp("--port", argv[i]) && i+1 < argc) { CV.port = argv[++i]; } else if(!strcmp("--auth", argv[i]) && i+1 < argc) { CV.auth = argv[++i]; } else if(!strcmp("--debug", argv[i])) { CV.debug = -1; } else if(!strcmp("list", argv[i])) break; else if(!strcmp("set", argv[i])) break; else if(!strcmp("guess", argv[i])) break; else { fprintf(stderr, "unknown or malformed argument: %s\n", argv[i]); exit(ERR_ARGUMENTS); } } return i; } static void defaults(void) { CV.host = "ns.ddns.nu"; CV.port = "5000"; CV.auth = "ddns"; CV.debug = 0; } static void check_args(void) { int err = 0; if(!CV.user) { fprintf(stderr, "client_error: you must specify a username\n"); err ++; } if(!CV.pass) { fprintf(stderr, "client_error: you must specify a password\n"); err ++; } if(err > 0) { fprintf(stderr, "client_exit: argument parsing; %d errors\n", err); exit(ERR_ARGUMENTS); } } static int actions(struct ddns3_ctx *c, int argc, char **argv, int start) { int i, err = 0; for(i = start; i < argc; i++) { if(!strcmp("list", argv[i])) { if(ddns3_ctx_list(c) < 0) { fprintf(stderr, "server_message: %s", c->buf); fprintf(stderr, "client_error: could not get handle list\n"); err++; } else { int j; for(j = 0; c->list[j]; j += 2) { printf("%-20s %s\n", c->list[j], c->list[j+1]); } } } else if(!strcmp("set", argv[i]) && i+2 < argc) { if(ddns3_ctx_set(c, argv[i+1], argv[i+2]) < 0) { fprintf(stderr, "server_message: %s", c->buf); fprintf(stderr, "client_error: could not set handle %s to ip %s, closing\n", argv[i+1], argv[i+2]); err++; } else printf("server_message: %s", c->buf); i += 2; } else if(!strcmp("guess", argv[i]) && i+2 < argc) { int type = -1; if(!strcasecmp("remote", argv[i+2])) type = GUESS_REMOTE; else if(!strcasecmp("local", argv[i+2])) type = GUESS_LOCAL; else { fprintf(stderr, "client_error: invalid guess type: %s\n", argv[i+2]); return ERR_ARGUMENTS; } if(ddns3_ctx_guess(c, argv[i+1], type) < 0) { fprintf(stderr, "server_message: %s", c->buf); fprintf(stderr, "client_error: could not set handle %s by guessing IP, closing\n", argv[i+1]); err++; } else printf("server_message: %s", c->buf); i += 2; } else { fprintf(stderr, "unknown or mangled action: %s\n", argv[i]); return ERR_ARGUMENTS; } } return err; } int main(int argc, char **argv, char **env) { int start, ret; struct ddns3_ctx *c; /* arguments and ugly stuff */ memset(&CV, 0, sizeof(struct client_vars)); defaults(); start = parse_args(argc, argv, env); check_args(); /* now the long and ugly stuff */ /* connect and login to DDNS server */ if(ddns3_ctx_new(&c, CV.host, atoi(CV.port)) < 0) { fprintf(stderr, "client_error: creating ddns3_ctx, exiting\n"); exit(ERR_LOGIC); } if(ddns3_ctx_connect(c) < 0) { fprintf(stderr, "server_message: %s", c->buf); fprintf(stderr, "client_error: could not connect to %s:%d, exiting\n", CV.host, atoi(CV.port)); exit(ERR_CONNECTION); } if(ddns3_ctx_login(c, CV.auth, CV.user, CV.pass) < 0) { fprintf(stderr, "server_message: %s", c->buf); fprintf(stderr, "client_error: could not authenticate\n"); exit(ERR_AUTH); } /* do what we have to */ ret = actions(c, argc, argv, start); /* close connection nicely */ if(ddns3_ctx_logout(c) < 0) { fprintf(stderr, "server_message: %s", c->buf); fprintf(stderr, "client_error: could not logout, giving up clean goodbye, exiting\n"); exit(ERR_CLOSING); } if(ddns3_ctx_disconnect(c) < 0) { fprintf(stderr, "server_message: %s", c->buf); fprintf(stderr, "client_error: disconnect failed, giving up\n"); exit(ERR_CLOSING); } if(ddns3_ctx_del(&c) < 0) { fprintf(stderr, "client_error: could not delete ddns3_ctx, oh well\n"); exit(ERR_LOGIC); } return ret; } ddns3-client-1.8.orig/md5.c0100644000175700001440000002150207515776110014162 0ustar imlusers/* taken from RFC-1321/Appendix A.3 */ /* * MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm */ /* * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights * reserved. * * License to copy and use this software is granted provided that it is * identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" * in all material mentioning or referencing this software or this function. * * License is also granted to make and use derivative works provided that such * works are identified as "derived from the RSA Data Security, Inc. MD5 * Message-Digest Algorithm" in all material mentioning or referencing the * derived work. * * RSA Data Security, Inc. makes no representations concerning either the * merchantability of this software or the suitability of this software for * any particular purpose. It is provided "as is" without express or implied * warranty of any kind. * * These notices must be retained in any copies of any part of this * documentation and/or software. */ #include #include #include "md5.h" /* * Constants for MD5Transform routine. */ #define S11 7 #define S12 12 #define S13 17 #define S14 22 #define S21 5 #define S22 9 #define S23 14 #define S24 20 #define S31 4 #define S32 11 #define S33 16 #define S34 23 #define S41 6 #define S42 10 #define S43 15 #define S44 21 static void MD5Transform(unsigned int[4], unsigned char[64]); static void Encode(unsigned char *, unsigned int*, unsigned int); static void Decode(unsigned int*, unsigned char *, unsigned int); static void MD5_memcpy(unsigned char *, unsigned char *, unsigned int); static void MD5_memset(char *, int, unsigned int); static unsigned char PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* * F, G, H and I are basic MD5 functions. */ #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define I(x, y, z) ((y) ^ ((x) | (~z))) /* * ROTATE_LEFT rotates x left n bits. */ #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) /* * FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. Rotation is * separate from addition to prevent recomputation. */ #define FF(a, b, c, d, x, s, ac) { \ (a) += F ((b), (c), (d)) + (x) + (unsigned int)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ (a) += G ((b), (c), (d)) + (x) + (unsigned int)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ (a) += H ((b), (c), (d)) + (x) + (unsigned int)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ (a) += I ((b), (c), (d)) + (x) + (unsigned int)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } /* * MD5 initialization. Begins an MD5 operation, writing a new context. */ void MD5Init(MD5_CTX * context) { context->count[0] = 0; context->count[1] = 0; context->state[0] = 0x67452301; context->state[1] = 0xefcdab89; context->state[2] = 0x98badcfe; context->state[3] = 0x10325476; } void MD5Update(MD5_CTX * context, unsigned char *input, unsigned int inputLen) { unsigned int i, index, partLen; index = (unsigned int) ((context->count[0] >> 3) & 0x3F); if((context->count[0] += ((unsigned int) inputLen << 3)) < ((unsigned int) inputLen << 3)) context->count[1]++; context->count[1] += ((unsigned int) inputLen >> 29); partLen = 64 - index; if (inputLen >= partLen) { MD5_memcpy(&context->buffer[index], input, partLen); MD5Transform(context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) MD5Transform(context->state, &input[i]); index = 0; } else i = 0; MD5_memcpy(&context->buffer[index], &input[i], inputLen - i); } void MD5Final(unsigned char digest[16], MD5_CTX * context) { unsigned char bits[8]; unsigned int index, padLen; Encode(bits, context->count, 8); index = (unsigned int) ((context->count[0] >> 3) & 0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); MD5Update(context, PADDING, padLen); MD5Update(context, bits, 8); Encode(digest, context->state, 16); MD5_memset((char *) context, 0, sizeof(*context)); } static void MD5Transform(unsigned int state[4], unsigned char block[64]) { unsigned int a = state[0], b = state[1], c = state[2], d = state[3], x[16]; Decode(x, block, 64); /* Round 1 */ FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */ FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */ FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */ FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */ FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */ FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */ FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */ FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */ FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */ FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */ FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ /* Round 2 */ GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */ GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */ GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */ GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */ GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */ GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */ GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */ GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */ GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */ GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */ GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */ GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ /* Round 3 */ HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */ HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */ HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */ HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */ HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */ HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */ HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */ HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */ HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */ HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */ /* Round 4 */ II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */ II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */ II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */ II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */ II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */ II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */ II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */ II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */ II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */ II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */ state[0] += a; state[1] += b; state[2] += c; state[3] += d; MD5_memset((char *) x, 0, sizeof(x)); } /* * Encodes input (unsigned int) into output (unsigned char). Assumes len is a * multiple of 4. */ static void Encode(unsigned char *output, unsigned int *input, unsigned int len) { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) { output[j] = (unsigned char) (input[i] & 0xff); output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff); output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff); output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff); } } /* * Decodes input (unsigned char) into output (unsigned int). Assumes len is a * multiple of 4. */ static void Decode(unsigned int * output, unsigned char *input, unsigned int len) { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) output[i] = ((unsigned int) input[j]) | (((unsigned int) input[j + 1]) << 8) | (((unsigned int) input[j + 2]) << 16) | (((unsigned int) input[j + 3]) << 24); } static void MD5_memcpy(unsigned char *output, unsigned char *input, unsigned int len) { memcpy(output, input, len); } static void MD5_memset(char *output, int value, unsigned int len) { memset(output, value, len); } ddns3-client-1.8.orig/md5.h0100644000175700001440000000070007515776110014164 0ustar imlusers/* * md5.h: MD5 API */ #ifndef _MD5_H #define _MD5_H /* MD5 context. */ typedef struct { unsigned int state[4]; /* state (ABCD) */ unsigned int count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD5_CTX; void MD5Init(MD5_CTX *); void MD5Update(MD5_CTX *, unsigned char *, unsigned int); void MD5Final(unsigned char[16], MD5_CTX *); #define MD5_DIGEST_CHARS 16 #endif ddns3-client-1.8.orig/sockio.c0100644000175700001440000000627107515776110014772 0ustar imlusers/* * DDNS v3 Client * * By: Alan Yates * Date: 27-08-2000 */ #ifdef WIN32 #include #else #include #include #include #include #include #include #include #include #include #endif #include #include "sockio.h" int ddns3_sockio_resolve(char *str, struct sockaddr_in *sai) { struct hostent *he; char buf[500]; char err[100]; short port; int ret, i; for(i = 0; str[i]; i++) if(str[i] == ':') str[i] = ' '; ret = sscanf(str, "%s%hd", buf, &port); if(ret < 2) return -1; if((inet_aton(buf, &sai->sin_addr)) == 0) { if(!(he = gethostbyname(buf))) { //perror("gethostbyname()"); ddns3_sockio_error(err,100); fprintf(stderr,"gethostbyname(): %s\n", err); return -1; } memcpy(&sai->sin_addr.s_addr, he->h_addr, he->h_length); } sai->sin_port = htons(port); sai->sin_family = AF_INET; return 0; } int ddns3_sockio_connect(char *host) { int ret; int sock; struct sockaddr_in sai; char err[100]; sock = socket(PF_INET, SOCK_STREAM, 0); if(sock < 0) { //perror("socket(PF_INET, SOCK_STREAM, 0)"); ddns3_sockio_error(err,100); fprintf(stderr, "socket(): %s\n",err); return -1; } ret = ddns3_sockio_resolve(host, &sai); if(ret < 0) { return -1; } ret = connect(sock, (struct sockaddr *)&sai, sizeof(struct sockaddr_in)); if(ret < 0) { //perror("connect()"); ddns3_sockio_error(err,100); fprintf(stderr, "connect(): %s\n",err); return -1; } return sock; } int ddns3_sockio_write(int sock, char *buf, int len) { int ret; char err[100]; /* FIXME: we pretend short writes never happen! */ ret = send(sock, buf, len, 0); if(ret < 0) { //perror("write()"); ddns3_sockio_error(err,100); fprintf(stderr, "send(): %s\n", err); } return ret; } int ddns3_sockio_read(int sock, char *buf, int len) { int ret; char err[100]; ret = recv(sock, buf, len, 0); if(ret < 0){ //perror("read()"); ddns3_sockio_error(err,100); fprintf(stderr, "recv(): %s\n", err); } return ret; } int ddns3_sockio_close(int sock) { #ifdef WIN32 closesocket(sock); #else close(sock); #endif return 0; } int ddns3_sockio_init(void) { #ifdef WIN32 WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD( 1, 1 ); err = WSAStartup( wVersionRequested, &wsaData ); if ( err != 0 ) { /* Tell the user that we could not find a usable */ /* WinSock DLL. */ return -1; } #endif return 0; } int ddns3_sockio_cleanup(void) { #ifdef WIN32 WSACleanup(); #endif return 0; } int ddns3_sockio_error(char *buf, int len) { int code; #ifdef WIN32 code = WSAGetLastError(); sprintf(buf,"%d",code); #else code = errno; sprintf(buf,"%s",strerror(code)); #endif return code; } int ddns3_sockio_getlocalip(int sock, char *buf, int len) { int ret; char err[100]; struct sockaddr_in sai; int sailen = sizeof(struct sockaddr_in); ret = getsockname(sock, (struct sockaddr *)&sai, &sailen); if(ret < 0) { ddns3_sockio_error(err,100); fprintf(stderr, "getsockname(): %s\n", err); } if(!buf || len < 16) return -1; return sprintf(buf, "%s", inet_ntoa(sai.sin_addr)); } ddns3-client-1.8.orig/sockio.h0100644000175700001440000000104007515776110014764 0ustar imlusers/* * DDNS v3 Client * * Author: Alan Yates * Version: $Id: sockio.h,v 1.1.1.1 2002/07/19 11:47:20 alany Exp $ */ #ifndef _SOCKIO_H #define _SOCKIO_H int ddns3_sockio_connect(char *host); int ddns3_sockio_write(int sock, char *buf, int len); int ddns3_sockio_read(int sock, char *buf, int len); int ddns3_sockio_close(int sock); int ddns3_sockio_init(void); int ddns3_sockio_cleanup(void); int ddns3_sockio_error(char *buf, int len); int ddns3_sockio_getlocalip(int sock, char *buf, int len); #endif /* _SOCKIO_H */