int remoteLogLevel=-1;
/*BRCM end*/
+/*==== Add by Andrew ====*/
+/*==== Porting by Andy ====*/
+int isWanUp();
+/*==== end ====*/
+
/* Path for the file where all log messages are written */
#define __LOG_FILE "/var/log/messages"
/*BRCM end*/
}
+/*==== add by Andrew ====*/
+/*==== Porting by Andy ====*/
+int isWanUp()
+{
+ char data[10];
+ int res = 0;
+
+ FILE* fp = fopen("/var/wanStatus", "r");
+ if ( fp != NULL ) {
+ fgets(data, 10, fp);
+ fclose(fp);
+ }
+
+ if(data[0] == '6') res = 1;
+ return res;
+}
+
+static void Connect2RemoteServ(int sig)
+{
+ struct sockaddr_in remoteaddr;
+ struct hostent *hostinfo=NULL;
+ int len = sizeof(remoteaddr);
+
+ if(remotefd>0) {
+ close(remotefd);
+ remotefd = -1;
+ }
+
+ if(!RemoteHost || !strcmp(RemoteHost, ""))
+ return;
+
+ hostinfo = xgethostbyname(RemoteHost);
+
+ if(!hostinfo)
+ return;
+
+ memset(&remoteaddr, 0, len);
+ remotefd = socket(AF_INET, SOCK_DGRAM, 0);
+
+ if (remotefd < 0) {
+ bb_perror_msg("cannot create socket");
+ return;
+ }
+
+ remoteaddr.sin_family = AF_INET;
+ remoteaddr.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
+ remoteaddr.sin_port = htons(RemotePort);
+
+ /*
+ Since we are using UDP sockets, connect just sets the default host and port
+ for future operations
+ */
+ if((connect(remotefd, (struct sockaddr *) &remoteaddr, len)) != 0){
+ close(remotefd);
+ remotefd = -1;
+ }
+ return;
+}
+/*==== end ====*/
+
static void quit_signal(int sig)
{
/*BRCM begin */
{
memset(&remoteaddr, 0, sizeof(remoteaddr));
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
+ int len = sizeof(remoteaddr);
if (remotefd < 0) {
/* BRCM begin */
remoteaddr.sin_family = AF_INET;
remoteaddr.sin_addr = *(struct in_addr *) *(xgethostbyname(RemoteHost))->h_addr_list;
remoteaddr.sin_port = htons(RemotePort);
+/*==== Modified by Andrew ====*/
+/*==== Porting by Wilson ====*/
+ //if(!isWanUp()) {
+ // close(remotefd);
+ // remotefd = -1;
+ // return;
+ //}
+
+ //if ( 0 != (connect(remotefd, (struct sockaddr *) &remoteaddr, len))){
+ //error_msg_and_die("cannot connect to remote host %s:%d", RemoteHost, RemotePort);
+ //}
+ if((connect(remotefd, (struct sockaddr *) &remoteaddr, len)) != 0){
+ close(remotefd);
+ remotefd = -1;
+ }
+/*==== end ====*/
}
#endif
signal(SIGINT, quit_signal);
signal(SIGTERM, quit_signal);
signal(SIGQUIT, quit_signal);
- signal(SIGHUP, SIG_IGN);
+/*==== Modified by Andrew ====*/
+/*==== Porting by Andy ====*/
+ //signal (SIGHUP, SIG_IGN);
+ signal (SIGHUP, Connect2RemoteServ);
+/*==== end ====*/
signal(SIGCHLD, SIG_IGN);
#ifdef SIGCLD
signal(SIGCLD, SIG_IGN);
/* change to priority emerg to be consistent with klogd */
/* logMessage(LOG_SYSLOG | LOG_INFO, "syslogd started: " BB_BANNER); */
- logMessage (LOG_SYSLOG | LOG_EMERG, "BCM96345 started: " BB_BANNER);
+ logMessage (LOG_SYSLOG | LOG_EMERG, "BCM63XX started: " BB_BANNER);
sprintf (pidfilename, "%s%s.pid", _PATH_VARRUN, "syslogd");
if ((pidfile = fopen (pidfilename, "w")) != NULL) {