Annotation of researchv10dc/ipc/internet/soreset.c, revision 1.1

1.1     ! root        1: #include <sys/param.h>
        !             2: #include <sys/types.h>
        !             3: #include <sys/stream.h>
        !             4: #include <nlist.h>
        !             5: #include <stdio.h>
        !             6: 
        !             7: #include <sys/inet/in.h>
        !             8: #include <sys/inet/tcp.h>
        !             9: 
        !            10: struct nlist nl[] = {
        !            11:        {"_tcpsocks", 0},
        !            12:        {0, 0},
        !            13: };
        !            14: 
        !            15: int kern_fd;
        !            16: 
        !            17: main(argc, argv)
        !            18: char *argv[];
        !            19: {
        !            20:        char *nuxi, *core;
        !            21:        struct block b;
        !            22:        register i;
        !            23: 
        !            24: struct socket{
        !            25:        struct          tcpcb *so_tcpcb;
        !            26:        struct          queue *so_rq;
        !            27:        struct          queue *so_wq;
        !            28:        int             so_rcount;
        !            29:        int             so_wcount;      /* because q->count is inaccurate */
        !            30:        struct          socket *so_head; /* parent who listened */
        !            31:        int             so_dev;
        !            32:        int             so_state;
        !            33:        int             so_options;
        !            34:        in_addr         so_laddr;
        !            35:        in_addr         so_faddr;
        !            36:        tcp_port        so_lport;
        !            37:        tcp_port        so_fport;
        !            38:        int             so_oobmark;
        !            39:        int             so_delimcnt;    /* to detect logical eof */
        !            40: } so;
        !            41: #define SO_DONTROUTE   0x1
        !            42: #define SO_KEEPALIVE   0x2
        !            43: #define SO_ACCEPTCONN  0x4     /* this is real */
        !            44: 
        !            45: #define SS_OPEN                0x1     /* by user */
        !            46: #define SS_PLEASEOPEN  0x2     /* waiting for user open */
        !            47: #define SS_RCVATMARK   0x4     /* some kind of OOB */
        !            48: #define SS_WAITING     0x8     /* wait for user control */
        !            49: #define        SS_ACTIVE       0x10    /* has tcp action */
        !            50: #define SS_HANGUP      0x20    /* HANGUP on TH_FIN */
        !            51: #define SS_HUNGUP      0x40    /* socket has been hung up (avoid multiple) */
        !            52: #define SS_WCLOSED     0x80    /* write side is closed */
        !            53: 
        !            54: #define        STATE_BITS      "\10WCLOSED\7HUNGUP\6HANGUP\5ACTIVE\4WAITING\3RCVATMARK\2PLEASOPEN\1OPEN"
        !            55:        nuxi = "/unix";
        !            56:        core = "/dev/kmem";
        !            57:        if(argc > 1)
        !            58:                nuxi = argv[1];
        !            59:        if(argc > 2)
        !            60:                core = argv[2];
        !            61:        if((kern_fd = open(core, 2)) < 0){
        !            62:                perror(core);
        !            63:                exit(1);
        !            64:        }
        !            65:        nlist(nuxi, nl);
        !            66:        if(nl[0].n_value == 0){         printf("nlist %s error\n", nuxi);
        !            67:                exit(1);
        !            68:        }
        !            69:        if(strcmp(core, "/dev/kmem"))
        !            70:                nl[0].n_value &= 0xffffff;
        !            71:        lseek(kern_fd, nl[0].n_value, 0);
        !            72:        for (i=0; i<32; i++) {
        !            73:                if(read(kern_fd, &so, sizeof(so)) != sizeof(so)){
        !            74:                        perror("read");
        !            75:                        exit(1);
        !            76:                }
        !            77:                so.so_state = 0;
        !            78:                so.so_options = 0;
        !            79:                so.so_laddr = so.so_faddr = 0;
        !            80:                so.so_lport = so.so_fport = 0;
        !            81:                if (lseek(kern_fd, -sizeof(so), 1) == -1) {
        !            82:                        perror("seek");
        !            83:                        exit(1);
        !            84:                }
        !            85:                if(write(kern_fd, &so, sizeof(so)) != sizeof(so)){
        !            86:                        perror("write");
        !            87:                        exit(1);
        !            88:                }
        !            89:        }
        !            90:        
        !            91: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.