Beispiel #1
0
static int ki_registered_flags(sip_msg_t* _m, str* _dtable, str* _uri, int _f)
{
	udomain_t* d;

	if(ul.get_udomain(_dtable->s, &d)<0) {
		LM_ERR("usrloc domain [%s] not found\n", _dtable->s);
		return -1;
	}

	return registered3(_m, d, (_uri && _uri->len>0)?_uri:NULL, _f);
}
Beispiel #2
0
static int w_registered3(struct sip_msg* _m, char* _d, char* _uri, char* _flags)
{
	str uri = {0};
	int flags = 0;
	if(_uri!=NULL && (fixup_get_svalue(_m, (gparam_p)_uri, &uri)!=0 || uri.len<=0))
	{
		LM_ERR("invalid uri parameter\n");
		return -1;
	}
	if(_flags!=NULL && (fixup_get_ivalue(_m, (fparam_t*)_flags, &flags)) < 0)
	{
		LM_ERR("invalid flags parameter\n");
		return -1;
	}
	return registered3(_m, (udomain_t*)_d, (uri.len>0)?&uri:NULL, flags);
}
Beispiel #3
0
void *client() {
	
	int sock;
	struct sockaddr_in server;
	struct sockaddr *serverptr = ( struct sockaddr *) &server;	
	struct hostent *rem;
	
	int input, choice;
	
	if( ( sock = socket ( PF_INET, SOCK_STREAM, 0) ) < 0) {
		perror("socket");
		exit(1);
	}
	
	/* Find server address */
	if (( rem = gethostbyname ( serverName) ) == NULL ) {
		herror("gethostbyname"); 
		exit (1);
	}
	
	server.sin_family = PF_INET;	/* Internet domain */
	memcpy(&server.sin_addr, rem->h_addr, rem->h_length);
	server.sin_port = htons ( portNumber );
	
	if ( connect ( sock, serverptr, sizeof( server ) ) < 0) {
		perror("connect") ;
		exit(1);
	}
		
	printf("Connecting to port %d \n", portNumber);
	
	
	/*Read Menu*/
	if( read(sock, &input, sizeof(int)) < 0 )	/* getting remote input */
	{
		printf("read1\n");
		exit(1);
	}
	
	/*Wait Menu*/
	choice = 1;
	menu3(sock, choice);
	
	
	/*Read Credentials Request*/
	if( read(sock, &input, sizeof(int)) < 0 )	/* getting remote input */
	{
		printf("read1\n");
		exit(1);
	}
	/*Credentials request*/
	cred3(sock);
	
	
	if( read(sock, &input, sizeof(int)) < 0 )	/* getting remote input */
	{
		printf("read1\n");
		exit(1);
	}
	/*Vote subject*/
	if (input == VOTE_SUBJECT) {
		subject3(sock);
		/*Wait Register*/
		if( read(sock, &input, sizeof(int)) < 0 )	/* getting remote input */
		{
			printf("read1\n");
			exit(1);
		}
		registered3(sock);
	}
	else if (input == VOTE_AGAIN) {
		vote_again3(sock);
	}
	
	
	/*Read Menu*/
	if( read(sock, &input, sizeof(int)) < 0 )	/* getting remote input */
	{
		printf("read1\n");
		exit(1);
	}
	/*QUIT*/
	choice = 3;
	menu3(sock, choice);
	
	
	/*Read Quit*/
	if( read(sock, &input, sizeof(int)) < 0 )	/* getting remote input */
	{
		printf("read1\n");
		exit(1);
	}
	
	close(sock);
	
	pthread_exit (NULL) ; 
	
	
}