~ubuntu-branches/ubuntu/precise/libssh/precise

« back to all changes in this revision

Viewing changes to tests/test_tunnel.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2011-06-15 15:48:07 UTC
  • mfrom: (1.1.10 upstream) (4.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20110615154807-3muklcqfftr1vtch
Tags: 0.5.0-2
* debian/patches/0002-Check-for-NULL-pointers-in-string-c.patch:
  Consolidate patch (Should fix previous REJECT)
* Support multiarch spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
                return;
23
23
        }
24
24
        printf("Authenticated\n");
25
 
        CHANNEL *channel=channel_new(session);
26
 
        error=channel_open_forward(channel,"localhost",ECHO_PORT,"localhost",42);
 
25
        CHANNEL *channel=ssh_channel_new(session);
 
26
        error=ssh_channel_open_forward(channel,"localhost",ECHO_PORT,"localhost",42);
27
27
        if(error!=SSH_OK){
28
28
                fprintf(stderr,"Error when opening forward:%s\n",ssh_get_error(session));
29
29
                return;
34
34
        char buffer[20];
35
35
        for(i=0;i<2000;++i){
36
36
                sprintf(string,"%d\n",i);
37
 
                channel_write(channel,string,strlen(string));
 
37
                ssh_channel_write(channel,string,strlen(string));
38
38
                do {
39
 
                        error=channel_poll(channel,0);
 
39
                        error=ssh_channel_poll(channel,0);
40
40
                        //if(error < strlen(string))
41
41
                                //usleep(10);
42
42
                } while(error < strlen(string) && error >= 0);
43
43
                if(error>0){
44
 
                        error=channel_read_nonblocking(channel,buffer,strlen(string),0);
 
44
                        error=ssh_channel_read_nonblocking(channel,buffer,strlen(string),0);
45
45
                        if(error>=0){
46
46
                                if(memcmp(buffer,string,strlen(string))!=0){
47
47
                                        fprintf(stderr,"Problem with answer: wanted %s got %s\n",string,buffer);
58
58
                }
59
59
        }
60
60
        printf("\nChannel test finished\n");
61
 
        channel_close(channel);
62
 
        channel_free(channel);
 
61
        ssh_channel_close(channel);
 
62
        ssh_channel_free(channel);
63
63
}
64
64
 
65
65
int main(int argc, char **argv){