From d9b9dc0f05d3d51825269d2c2dc0bf06ba3c5bfd Mon Sep 17 00:00:00 2001 From: watanaby Date: Fri, 26 Sep 2014 15:08:21 +0900 Subject: [PATCH] Ver.1.5.33 Added checking of null language string --- opengate/javahtml/success.html | 1 + opengate/opengatesrv/udp-client.c | 127 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 opengate/javahtml/success.html create mode 100644 opengate/opengatesrv/udp-client.c diff --git a/opengate/javahtml/success.html b/opengate/javahtml/success.html new file mode 100644 index 0000000..803ac7c --- /dev/null +++ b/opengate/javahtml/success.html @@ -0,0 +1 @@ +SuccessSuccess \ No newline at end of file diff --git a/opengate/opengatesrv/udp-client.c b/opengate/opengatesrv/udp-client.c new file mode 100644 index 0000000..aa700ff --- /dev/null +++ b/opengate/opengatesrv/udp-client.c @@ -0,0 +1,127 @@ +/************************************************** +opengate Mac addr auth program + + module to control udp client + + As ip address check by database is time consuming procedure, + the recently checked addresses are cached and skiped. + Implemented with HashTable and Queue. + HashTable has recentry checked dataStress and checked time. + If ip is included in table and time is new, ignore checking. + Queue has dataStresses odrered by checked time. + If an old item is found in table, elder items are removed from table. + The queue controls the remove sequence. + + +Copyright (C) 2011 Opengate Project Team +Written by Yoshiaki Watanabe + +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Email: watanaby@is.saga-u.ac.jp +**************************************************/ + +#include "opengatesrv.h" + +/************************************ +send mac address to daemon at db update +************************************/ +int putMacAddressToOpengateMd(char* macAddress){ + char* udpPort; + + udpPort=GetConfValue("OpengateMdPort"); + if(!isNull(udpPort)){ + PutDataToUdpPort("127.0.0.1", udpPort, macAddress); + } + + return TRUE; +} + +/***************************************** +put data to server udp port +*****************************************/ +int putDataToUdpPort(char* udpServerAddr, char* udpServerPort, char* buff){ + + int sockfd; + struct addrinfo hints, *servinfo, *p; + int ret; + int numbytes; + + /* if no buffer return error */ + if (buff==NULL||*buff=='\0') return FALSE; + + /* prepare address hints */ + memset(&hints, 0, sizeof hints); + hints.ai_family = AF_UNSPEC; /* IPv4/IPv6 dual */ + hints.ai_socktype = SOCK_DGRAM; /* UDP */ + + if ((ret = getaddrinfo(udpServerAddr, udpServerPort, &hints, &servinfo))!= 0) { + err_msg("ERR at %s#%d: getaddrinfo: %s",__FILE__,__LINE__, + gai_strerror(ret)); + return FALSE; + } + + /* loop through addresses */ + for(p = servinfo; p != NULL; p = p->ai_next) { + if ((sockfd = socket(p->ai_family, p->ai_socktype, + p->ai_protocol)) == -1) { + err_msg("ERR at %s#%d: socket error: %s",__FILE__,__LINE__, + strerror(errno)); + continue; + } + break; + } + if (p == NULL) { + err_msg("ERR at %s#%d: failed to bind socket",__FILE__,__LINE__); + return FALSE; + } + + /* send data to server */ + if ((numbytes = sendto(sockfd, buff, strlen(buff), 0, + p->ai_addr, p->ai_addrlen)) == -1) { + err_msg("ERR at %s#%d: sendto error: %s",__FILE__,__LINE__, + strerror(errno)); + err_msg("ERR at %s#%d: Check firewall/daemon on [%s] to get udp[%d] packet" + "from here", + __FILE__,__LINE__,udpServerAddr,udpServerPort); + return FALSE; + } + + /* finalize */ + freeaddrinfo(servinfo); + close(sockfd); + + return TRUE; +} + +/********************************** +put out buff to udp addr:port +**********************************/ +int PutDataToUdpPort(char* udpServerAddr, char* udpServerPort,char* buff){ + int ret; + if(debug>1) err_msg("DEBUG:=>putDataToUdpPort(%s)",udpServerAddr, udpServerPort,buff); + ret = putDataToUdpPort(udpServerAddr, udpServerPort,buff); + if(debug>1) err_msg("DEBUG:(%d)<=putDateToUdpPort( )",ret); + return ret; +} + + +int PutMacAddressToOpengateMd(char* macAddress){ + int ret; + if(debug>1) err_msg("DEBUG:=>putMacAddressToOpengateMd(%s)",macAddress); + ret = putMacAddressToOpengateMd(macAddress); + if(debug>1) err_msg("DEBUG:(%d)<=putMacAddressToOpengateMd( )",ret); + return ret; +} -- 2.11.0