Tcl UDP

Check-in [92858ed557]
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:Added support for IP_MULTICAST_LOOP for kostix.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 92858ed557912cc5c7783598031a2efb4ff545aa
User & Date: patthoyts 2007-03-30 11:09:44
Context
2007-03-30
21:22
Upgraded TEA to 3.6 and update the version to 1.0.9. Regenerated configure. Improved the error reporting by making use of strerror() if present. check-in: 3c1551e84a user: patthoyts tags: trunk
11:09
Added support for IP_MULTICAST_LOOP for kostix. check-in: 92858ed557 user: patthoyts tags: trunk
2007-01-31
13:23
Made the HP-UX patch more specific as if affected AIX builds (from Jeff Hobbs) check-in: b74a7f57a9 user: patthoyts tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.






1
2
3
4
5
6
7




2007-01-31  Pat Thoyts  <[email protected]>

	* generic/udp_tcl.c: Turns out the HP-UX patch break buiding on
	AIX so made the check more specific (from Jeff Hobbs again).

2007-01-21  Pat Thoyts  <[email protected]>

>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2007-03-30  Pat Thoyts  <[email protected]>

	* generic/udp_tcl.c: Added support for IP_MULTICAST_LOOP for
	Konstantin Khomoutov to control multicast loopback transmission.

2007-01-31  Pat Thoyts  <[email protected]>

	* generic/udp_tcl.c: Turns out the HP-UX patch break buiding on
	AIX so made the check more specific (from Jeff Hobbs again).

2007-01-21  Pat Thoyts  <[email protected]>

Changes to generic/udp_tcl.c.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
....
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
....
1296
1297
1298
1299
1300
1301
1302














1303
1304
1305
1306
1307
1308
1309
....
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
....
1400
1401
1402
1403
1404
1405
1406

















1407
1408
1409
1410
1411
1412
1413
 *
 * Copyright (c) 1999-2000 by Columbia University; all rights reserved
 * Copyright (c) 2003-2005 Pat Thoyts <[email protected]>
 *
 * Written by Xiaotao Wu
 * Last modified: 11/03/2000
 *
 * $Id: udp_tcl.c,v 1.35 2007/01/31 13:23:10 patthoyts Exp $
 ******************************************************************************/

#if defined(_DEBUG) && !defined(DEBUG)
#define DEBUG
#endif

#include "udp_tcl.h"
................................................................................
 * ----------------------------------------------------------------------
 */
static int 
udpGetOption(ClientData instanceData, Tcl_Interp *interp,
             CONST84 char *optionName, Tcl_DString *optionValue)
{
    UdpState *statePtr = (UdpState *)instanceData;
    CONST84 char * options[] = { "myport", "remote", "peer", "mcastgroups", "broadcast", "ttl", NULL};
    int r = TCL_OK;

    if (optionName == NULL) {
	Tcl_DString ds;
	const char **p;
	
	Tcl_DStringInit(&ds);
................................................................................
                UDPTRACE("UDP error - getsockopt\n");
                Tcl_SetResult(interp, "error in getsockopt", TCL_STATIC);
                r = TCL_ERROR;
            } else {
                Tcl_DStringSetLength(&ds, TCL_INTEGER_SPACE);
                sprintf(Tcl_DStringValue(&ds), "%d", tmp);
            }















        } else if (!strcmp("-ttl", optionName)) {
          
            unsigned int tmp = 0;
            socklen_t optlen = sizeof(unsigned int);
	    int cmd = IP_TTL;
	    if (statePtr->multicast > 0)
................................................................................
 * ----------------------------------------------------------------------
 */
static int
udpSetOption(ClientData instanceData, Tcl_Interp *interp,
             CONST84 char *optionName, CONST84 char *newValue)
{
    UdpState *statePtr = (UdpState *)instanceData;
    CONST84 char * options = "remote mcastadd mcastdrop broadcast ttl";
    int r = TCL_OK;

    if (!strcmp("-remote", optionName)) {

        Tcl_Obj *valPtr;
        int len;

................................................................................
                UDPTRACE("UDP error - setsockopt\n");
                Tcl_SetObjResult(interp, Tcl_NewStringObj(errBuf, -1));
                r = TCL_ERROR;
            } else {
                Tcl_SetObjResult(interp, Tcl_NewIntObj(tmp));
            }
        }

















    } else if (!strcmp("-ttl", optionName)) {

        unsigned int tmp = 0;
	int cmd = IP_TTL;
	if (statePtr->multicast > 0)
	    cmd = IP_MULTICAST_TTL;
        r = Tcl_GetInt(interp, newValue, &tmp);






|







 







|







 







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







 







|







 







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







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
....
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
....
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
....
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
....
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
 *
 * Copyright (c) 1999-2000 by Columbia University; all rights reserved
 * Copyright (c) 2003-2005 Pat Thoyts <[email protected]>
 *
 * Written by Xiaotao Wu
 * Last modified: 11/03/2000
 *
 * $Id: udp_tcl.c,v 1.36 2007/03/30 11:09:44 patthoyts Exp $
 ******************************************************************************/

#if defined(_DEBUG) && !defined(DEBUG)
#define DEBUG
#endif

#include "udp_tcl.h"
................................................................................
 * ----------------------------------------------------------------------
 */
static int 
udpGetOption(ClientData instanceData, Tcl_Interp *interp,
             CONST84 char *optionName, Tcl_DString *optionValue)
{
    UdpState *statePtr = (UdpState *)instanceData;
    CONST84 char * options[] = { "myport", "remote", "peer", "mcastgroups", "mcastloopback", "broadcast", "ttl", NULL};
    int r = TCL_OK;

    if (optionName == NULL) {
	Tcl_DString ds;
	const char **p;
	
	Tcl_DStringInit(&ds);
................................................................................
                UDPTRACE("UDP error - getsockopt\n");
                Tcl_SetResult(interp, "error in getsockopt", TCL_STATIC);
                r = TCL_ERROR;
            } else {
                Tcl_DStringSetLength(&ds, TCL_INTEGER_SPACE);
                sprintf(Tcl_DStringValue(&ds), "%d", tmp);
            }

	} else if (!strcmp("-mcastloopback", optionName)) {

            unsigned char tmp = 0;
            socklen_t optlen = sizeof(unsigned char);
            if (getsockopt(statePtr->sock, IPPROTO_IP, IP_MULTICAST_LOOP, 
                           (char *)&tmp, &optlen)) {
                UDPTRACE("UDP error - getsockopt\n");
                Tcl_SetResult(interp, "error in getsockopt", TCL_STATIC);
                r = TCL_ERROR;
            } else {
                Tcl_DStringSetLength(&ds, TCL_INTEGER_SPACE);
                sprintf(Tcl_DStringValue(&ds), "%d", (int)tmp);
            }

        } else if (!strcmp("-ttl", optionName)) {
          
            unsigned int tmp = 0;
            socklen_t optlen = sizeof(unsigned int);
	    int cmd = IP_TTL;
	    if (statePtr->multicast > 0)
................................................................................
 * ----------------------------------------------------------------------
 */
static int
udpSetOption(ClientData instanceData, Tcl_Interp *interp,
             CONST84 char *optionName, CONST84 char *newValue)
{
    UdpState *statePtr = (UdpState *)instanceData;
    CONST84 char * options = "remote mcastadd mcastdrop mcastloopback broadcast ttl";
    int r = TCL_OK;

    if (!strcmp("-remote", optionName)) {

        Tcl_Obj *valPtr;
        int len;

................................................................................
                UDPTRACE("UDP error - setsockopt\n");
                Tcl_SetObjResult(interp, Tcl_NewStringObj(errBuf, -1));
                r = TCL_ERROR;
            } else {
                Tcl_SetObjResult(interp, Tcl_NewIntObj(tmp));
            }
        }
    } else if (!strcmp("-mcastloopback", optionName)) {

        int tmp = 1;
        r = Tcl_GetInt(interp, newValue, &tmp);
        if (r == TCL_OK) {
	    unsigned char ctmp = (unsigned char)tmp;
            if (setsockopt(statePtr->sock, IPPROTO_IP, IP_MULTICAST_LOOP,
                           (const char *)&ctmp, sizeof(unsigned char))) {
                sprintf(errBuf, "%s", "udp - setsockopt");
                UDPTRACE("UDP error - setsockopt\n");
                Tcl_SetObjResult(interp, Tcl_NewStringObj(errBuf, -1));
                r = TCL_ERROR;
            } else {
                Tcl_SetObjResult(interp, Tcl_NewIntObj(tmp));
            }
        }

    } else if (!strcmp("-ttl", optionName)) {

        unsigned int tmp = 0;
	int cmd = IP_TTL;
	if (statePtr->multicast > 0)
	    cmd = IP_MULTICAST_TTL;
        r = Tcl_GetInt(interp, newValue, &tmp);