Tcl UDP

Check-in [00716b4d04]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Nerfed the new interface adjustment code for Windows.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 00716b4d043ec5a0c82281a930a11abd66b916f9
User & Date: tne 2014-10-05 05:25:32
Context
2014-10-05
05:38
Update to the latest TEA Removed the PATH fed into Tclsh calls by the Makefile. Windows 7 puts parethesis in file names, and this sends Make into a tailspin as it tries to compute paths. Anywho, the tclsh should already know it's path check-in: 2716286bc9 user: tne tags: trunk
05:25
Nerfed the new interface adjustment code for Windows. check-in: 00716b4d04 user: tne tags: trunk
2014-09-08
15:58
Removed pkgIndex.tcl from cleanfiles check-in: 90b768a1b3 user: hypnotoad tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/udp_tcl.c.

1041
1042
1043
1044
1045
1046
1047




















1048
1049
1050
1051
1052
1053
1054
....
1057
1058
1059
1060
1061
1062
1063

1064
1065
1066
1067
1068
1069
1070
....
1505
1506
1507
1508
1509
1510
1511

1512
1513

1514
1515
1516
1517
1518
1519
1520
....
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
....
1811
1812
1813
1814
1815
1816
1817

1818
1819
1820
1821
1822
1823
1824
		sendaddrv6.sin6_family = AF_INET6;
		sendaddrv6.sin6_port = statePtr->remoteport;

		written = sendto(statePtr->sock, buf, toWrite, 0, (struct sockaddr *)&sendaddrv6, socksize);
	} else {
          socksize = sizeof(sendaddrv4);
          memset(&sendaddrv4, 0, socksize);




















          struct in_addr remote_addr;

          if(inet_aton(statePtr->remotehost,&remote_addr)==0) {
            name = gethostbyname(statePtr->remotehost);
            if (name == NULL) {
              UDPTRACE("UDP error - gethostbyname");
              return -1;
................................................................................
          } else {
            sendaddrv4.sin_addr=remote_addr;
          }
          sendaddrv4.sin_family = AF_INET;
          sendaddrv4.sin_port = statePtr->remoteport;
          written = sendto(statePtr->sock, buf, toWrite, 0, (struct sockaddr *)&sendaddrv4, socksize);
	}


	if (written < 0) {
		UDPTRACE("UDP error - sendto");
		return -1;
	}

	UDPTRACE("Send %d to %s:%d through %d\n", written, statePtr->remotehost,
................................................................................
{
    UdpState *statePtr = (UdpState *)instanceData;
    CONST84 char * options = "remote mcastadd mcastdrop mcastloop broadcast ttl";
    int r = TCL_OK;
	
    if (!strcmp("-remote", optionName)) {
		r = udpSetRemoteOption(statePtr,interp,(const char *)newValue);

    } else if (!strcmp("-mcastif", optionName)) {
		r = udpSetMulticastIFOption(statePtr,interp,(const char *)newValue);                

    } else if (!strcmp("-mcastadd", optionName)) {
		r = udpSetMulticastAddOption(statePtr, interp, (const char *)newValue);		
    } else if (!strcmp("-mcastdrop", optionName)) {
		r = udpSetMulticastDropOption(statePtr, interp, (const char *)newValue);				
    } else if (!strcmp("-broadcast", optionName)) {
		r = udpSetBroadcastOption(statePtr, interp, (const char*) newValue);		
     } else if (!strcmp("-mcastloop", optionName)) {
................................................................................
	} else {
		Tcl_SetObjResult(interp, Tcl_NewStringObj(newValue,-1));
	}

	return result;
}


/*
 * ----------------------------------------------------------------------
 * udpSetMulticastIFOption --
 *
 *  Specify the default gateway interface for multicast
 *
 * ----------------------------------------------------------------------
................................................................................
        Tcl_SetObjResult(interp, ErrorToObj("error setting -mcastif"));
      }
      return TCL_ERROR;
    }
  }
  return TCL_OK;
}


/*
 * ----------------------------------------------------------------------
 * udpSetMulticastAddOption --
 *
 *  Handle multicast add configuration requests.
 *






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>







 







>

|
>







 







|







 







>







1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
....
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
....
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
....
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
....
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
		sendaddrv6.sin6_family = AF_INET6;
		sendaddrv6.sin6_port = statePtr->remoteport;

		written = sendto(statePtr->sock, buf, toWrite, 0, (struct sockaddr *)&sendaddrv6, socksize);
	} else {
          socksize = sizeof(sendaddrv4);
          memset(&sendaddrv4, 0, socksize);
#ifdef WIN32
	/* MinGW, at least, on Windows doesn't grok aton */
	sendaddrv4.sin_addr.s_addr = inet_addr(statePtr->remotehost);

        if (sendaddrv4.sin_addr.s_addr == -1) {
            name = gethostbyname(statePtr->remotehost);
			if (name == NULL) {
				UDPTRACE("UDP error - gethostbyname");
				return -1;
			}
			memcpy(&sendaddrv4.sin_addr, name->h_addr, sizeof(sendaddrv4.sin_addr));
		}

		sendaddrv4.sin_family = AF_INET;
		sendaddrv4.sin_port = statePtr->remoteport;

		written = sendto(statePtr->sock, buf, toWrite, 0, (struct sockaddr *)&sendaddrv4, socksize);
	}

#else
          struct in_addr remote_addr;

          if(inet_aton(statePtr->remotehost,&remote_addr)==0) {
            name = gethostbyname(statePtr->remotehost);
            if (name == NULL) {
              UDPTRACE("UDP error - gethostbyname");
              return -1;
................................................................................
          } else {
            sendaddrv4.sin_addr=remote_addr;
          }
          sendaddrv4.sin_family = AF_INET;
          sendaddrv4.sin_port = statePtr->remoteport;
          written = sendto(statePtr->sock, buf, toWrite, 0, (struct sockaddr *)&sendaddrv4, socksize);
	}
#endif

	if (written < 0) {
		UDPTRACE("UDP error - sendto");
		return -1;
	}

	UDPTRACE("Send %d to %s:%d through %d\n", written, statePtr->remotehost,
................................................................................
{
    UdpState *statePtr = (UdpState *)instanceData;
    CONST84 char * options = "remote mcastadd mcastdrop mcastloop broadcast ttl";
    int r = TCL_OK;
	
    if (!strcmp("-remote", optionName)) {
		r = udpSetRemoteOption(statePtr,interp,(const char *)newValue);
#ifndef WIN32
    } else if (!strcmp("-mcastif", optionName)) {
		r = udpSetMulticastIFOption(statePtr,interp,(const char *)newValue);
#endif
    } else if (!strcmp("-mcastadd", optionName)) {
		r = udpSetMulticastAddOption(statePtr, interp, (const char *)newValue);		
    } else if (!strcmp("-mcastdrop", optionName)) {
		r = udpSetMulticastDropOption(statePtr, interp, (const char *)newValue);				
    } else if (!strcmp("-broadcast", optionName)) {
		r = udpSetBroadcastOption(statePtr, interp, (const char*) newValue);		
     } else if (!strcmp("-mcastloop", optionName)) {
................................................................................
	} else {
		Tcl_SetObjResult(interp, Tcl_NewStringObj(newValue,-1));
	}

	return result;
}

#ifndef WIN32
/*
 * ----------------------------------------------------------------------
 * udpSetMulticastIFOption --
 *
 *  Specify the default gateway interface for multicast
 *
 * ----------------------------------------------------------------------
................................................................................
        Tcl_SetObjResult(interp, ErrorToObj("error setting -mcastif"));
      }
      return TCL_ERROR;
    }
  }
  return TCL_OK;
}
#endif

/*
 * ----------------------------------------------------------------------
 * udpSetMulticastAddOption --
 *
 *  Handle multicast add configuration requests.
 *