mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-03 21:43:32 +00:00 
			
		
		
		
	msc: Add msc ip-tos NR option for the BSC
Allow to set the TOS field via the VTY interface. The SO_PRIORITY was not used as it has no effect on the packets being sent (in contrast to the documentation).
This commit is contained in:
		@@ -32,6 +32,7 @@ struct bsc_msc_connection {
 | 
				
			|||||||
	int is_authenticated;
 | 
						int is_authenticated;
 | 
				
			||||||
	const char *ip;
 | 
						const char *ip;
 | 
				
			||||||
	int port;
 | 
						int port;
 | 
				
			||||||
 | 
						int prio;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void (*connection_loss) (struct bsc_msc_connection *);
 | 
						void (*connection_loss) (struct bsc_msc_connection *);
 | 
				
			||||||
	void (*connected) (struct bsc_msc_connection *);
 | 
						void (*connected) (struct bsc_msc_connection *);
 | 
				
			||||||
@@ -39,7 +40,7 @@ struct bsc_msc_connection {
 | 
				
			|||||||
	struct timer_list timeout_timer;
 | 
						struct timer_list timeout_timer;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct bsc_msc_connection *bsc_msc_create(const char *ip, int port);
 | 
					struct bsc_msc_connection *bsc_msc_create(const char *ip, int port, int prio);
 | 
				
			||||||
int bsc_msc_connect(struct bsc_msc_connection *);
 | 
					int bsc_msc_connect(struct bsc_msc_connection *);
 | 
				
			||||||
void bsc_msc_schedule_connect(struct bsc_msc_connection *);
 | 
					void bsc_msc_schedule_connect(struct bsc_msc_connection *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -677,6 +677,7 @@ struct gsm_network {
 | 
				
			|||||||
	struct {
 | 
						struct {
 | 
				
			||||||
		enum rrlp_mode mode;
 | 
							enum rrlp_mode mode;
 | 
				
			||||||
	} rrlp;
 | 
						} rrlp;
 | 
				
			||||||
 | 
						int msc_prio;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SMS_HDR_SIZE	128
 | 
					#define SMS_HDR_SIZE	128
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -163,6 +163,13 @@ int bsc_msc_connect(struct bsc_msc_connection *con)
 | 
				
			|||||||
	/* make it non blocking */
 | 
						/* make it non blocking */
 | 
				
			||||||
	setnonblocking(fd);
 | 
						setnonblocking(fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* set the socket priority */
 | 
				
			||||||
 | 
						ret = setsockopt(fd->fd, IPPROTO_IP, IP_TOS,
 | 
				
			||||||
 | 
								 &con->prio, sizeof(con->prio));
 | 
				
			||||||
 | 
						if (ret != 0)
 | 
				
			||||||
 | 
							LOGP(DMSC, LOGL_ERROR, "Failed to set prio to %d. %s\n",
 | 
				
			||||||
 | 
							     con->prio, strerror(errno));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memset(&sin, 0, sizeof(sin));
 | 
						memset(&sin, 0, sizeof(sin));
 | 
				
			||||||
	sin.sin_family = AF_INET;
 | 
						sin.sin_family = AF_INET;
 | 
				
			||||||
	sin.sin_port = htons(con->port);
 | 
						sin.sin_port = htons(con->port);
 | 
				
			||||||
@@ -200,7 +207,7 @@ int bsc_msc_connect(struct bsc_msc_connection *con)
 | 
				
			|||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct bsc_msc_connection *bsc_msc_create(const char *ip, int port)
 | 
					struct bsc_msc_connection *bsc_msc_create(const char *ip, int port, int prio)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct bsc_msc_connection *con;
 | 
						struct bsc_msc_connection *con;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -212,6 +219,7 @@ struct bsc_msc_connection *bsc_msc_create(const char *ip, int port)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	con->ip = ip;
 | 
						con->ip = ip;
 | 
				
			||||||
	con->port = port;
 | 
						con->port = port;
 | 
				
			||||||
 | 
						con->prio = prio;
 | 
				
			||||||
	write_queue_init(&con->write_queue, 100);
 | 
						write_queue_init(&con->write_queue, 100);
 | 
				
			||||||
	con->write_queue.except_cb = bsc_msc_except;
 | 
						con->write_queue.except_cb = bsc_msc_except;
 | 
				
			||||||
	return con;
 | 
						return con;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1110,7 +1110,7 @@ int main(int argc, char** argv)
 | 
				
			|||||||
		return -4;
 | 
							return -4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* connect to the MSC */
 | 
						/* connect to the MSC */
 | 
				
			||||||
	nat->msc_con = bsc_msc_create(nat->msc_ip, nat->msc_port);
 | 
						nat->msc_con = bsc_msc_create(nat->msc_ip, nat->msc_port, 0);
 | 
				
			||||||
	if (!nat->msc_con) {
 | 
						if (!nat->msc_con) {
 | 
				
			||||||
		fprintf(stderr, "Creating a bsc_msc_connection failed.\n");
 | 
							fprintf(stderr, "Creating a bsc_msc_connection failed.\n");
 | 
				
			||||||
		exit(1);
 | 
							exit(1);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user