diff options
Diffstat (limited to 'src/libgsmd')
| -rw-r--r-- | src/libgsmd/libgsmd.c | 19 | 
1 files changed, 16 insertions, 3 deletions
| diff --git a/src/libgsmd/libgsmd.c b/src/libgsmd/libgsmd.c index 1626b04..03642ea 100644 --- a/src/libgsmd/libgsmd.c +++ b/src/libgsmd/libgsmd.c @@ -64,7 +64,7 @@ static int lgsm_open_backend(struct lgsm_handle *lh, const char *device)  {  	int rc; -	if (!strcmp(device, LGSMD_DEVICE_GSMD)) { +	if (!strncmp(device, LGSMD_DEVICE_GSMD, strlen(LGSMD_DEVICE_GSMD))) {  		struct sockaddr_un sun;  		/* use unix domain socket to gsm daemon */ @@ -74,7 +74,8 @@ static int lgsm_open_backend(struct lgsm_handle *lh, const char *device)  		memset(&sun, 0, sizeof(sun));  		sun.sun_family = AF_UNIX; -		memcpy(sun.sun_path, GSMD_UNIX_SOCKET, sizeof(GSMD_UNIX_SOCKET)); +		sun.sun_path[0] = '\0'; +		strncpy(sun.sun_path+1, device, sizeof(sun.sun_path)-1);  		rc = connect(lh->fd, (struct sockaddr *)&sun, sizeof(sun));  		if (rc < 0) { @@ -184,6 +185,19 @@ struct lgsm_handle *lgsm_init(const char *device)  	return lh;  } +struct lgsm_handle *lgsm_init_inst(unsigned int instance) +{ +	struct lgsm_handle *lh = malloc(sizeof(*lh)); +	char buf[32]; +	if (instance == 0) +		snprintf(buf, sizeof(buf), "gsmd"); +	else +		snprintf(buf, sizeof(buf), "gsmd.%u", instance); + +	return lgsm_init(buf); +} + +  int lgsm_exit(struct lgsm_handle *lh)  {  	free(lh); @@ -191,7 +205,6 @@ int lgsm_exit(struct lgsm_handle *lh)  	return 0;  } -  static u_int16_t next_msg_id;  int lgsm_send(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) | 
