# 2.11BSD#431 - /usr/src/ucb/talk/ctl.c

##### Functions

    open_ctl          X
    open_sockt        X
    print_addr        X

##### Variables

    ctl_addr          X
    ctl_sockt         X
    daemon_addr       X
    daemon_port       X
    his_machine_addr  X
    invitation_waitingX
    my_addr           X
    my_machine_addr   X
    sockt             X

       1: /*
       2:  * Copyright (c) 1983 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #ifndef lint
       8: static char sccsid[] = "@(#)ctl.c	5.2 (Berkeley) 3/13/86";
       9: #endif not lint
      10:
      11: /*
      12:  * This file handles haggling with the various talk daemons to
      13:  * get a socket to talk to. sockt is opened and connected in
      14:  * the progress
      15:  */
      16:
      17: #include "talk_ctl.h"
      18:
      19: struct  sockaddr_in daemon_addr = { AF_INET };
      20: struct  sockaddr_in ctl_addr = { AF_INET };
      21: struct  sockaddr_in my_addr = { AF_INET };
      22:
      23:     /* inet addresses of the two machines */
      24: struct  in_addr my_machine_addr;
      25: struct  in_addr his_machine_addr;
      26:
      27: u_short daemon_port;    /* port number of the talk daemon */
      28:
      29: int ctl_sockt;
      30: int sockt;
      31: int invitation_waiting = 0;
      32:
      33: CTL_MSG msg;
      34:
      35: open_sockt()
      36: {
      37:     int length;
      38:
      39:     my_addr.sin_addr = my_machine_addr;
      40:     my_addr.sin_port = 0;
      41:     sockt = socket(AF_INET, SOCK_STREAM, 0);
      42:     if (sockt <= 0)
      43:         p_error("Bad socket");
      44:     if (bind(sockt, &my_addr, sizeof(my_addr)) != 0)
      45:         p_error("Binding local socket");
      46:     length = sizeof(my_addr);
      47:     if (getsockname(sockt, &my_addr, &length) == -1)
      48:         p_error("Bad address for socket");
      49: }
      50:
      51: /* open the ctl socket */
      52: open_ctl()
      53: {
      54:     int length;
      55:
      56:     ctl_addr.sin_port = 0;
      57:     ctl_addr.sin_addr = my_machine_addr;
      58:     ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0);
      59:     if (ctl_sockt <= 0)
      60:         p_error("Bad socket");
      61:     if (bind(ctl_sockt, &ctl_addr, sizeof(ctl_addr), 0) != 0)
      62:         p_error("Couldn't bind to control socket");
      63:     length = sizeof(ctl_addr);
      64:     if (getsockname(ctl_sockt, &ctl_addr, &length) == -1)
      65:         p_error("Bad address for ctl socket");
      66: }
      67:
      68: /* print_addr is a debug print routine */
      69: print_addr(addr)
      70:     struct sockaddr_in addr;
      71: {
      72:     int i;
      73:
      74:     printf("addr = %x, port = %o, family = %o zero = ",
      75:         addr.sin_addr, addr.sin_port, addr.sin_family);
      76:     for (i = 0; i<8;i++)
      77:     printf("%o ", (int)addr.sin_zero[i]);
      78:     putchar('\n');
      79: }

#### Defined functions

open_ctl defined in line 52; used 1 times

- in /usr/src/ucb/talk/talk.c line 40

open_sockt defined in line 35; used 2 times

- in /usr/src/ucb/talk/look_up.c line 48
- in /usr/src/ucb/talk/talk.c line 41

print_addr defined in line 69; never used

#### Defined variables

ctl_addr defined in line 20; used 6 times

- in line 56-64(6)

ctl_sockt defined in line 29; used 4 times

- in line 58-64(4)

daemon_addr defined in line 19; never used
daemon_port defined in line 27; never used
his_machine_addr defined in line 25; never used
invitation_waiting defined in line 31; never used
my_addr defined in line 21; used 6 times

- in line 39-47(6)

my_machine_addr defined in line 24; used 2 times

- in line 39, 57

sccsid defined in line 8; never used
sockt defined in line 30; used 4 times

- in line 41-47(4)

Last modified: 1987-02-17 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1094 |