Skip to content

Commit

Permalink
Allow proto modules to populate its name
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Jun 24, 2016
1 parent 1569a73 commit 00d052c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
17 changes: 7 additions & 10 deletions net/trans.c
Expand Up @@ -41,12 +41,12 @@
struct proto_info protos[PROTO_LAST - PROTO_NONE] = {

{ }, /* PROTO_NONE */
{ .name = "udp", .port = 5060 }, /* PROTO_UDP */
{ .name = "tcp", .port = 5060 }, /* PROTO_TCP */
{ .name = "tls", .port = 5061 }, /* PROTO_TLS */
{ .name = "sctp", .port = 5060 }, /* PROTO_SCTP */
{ .name = "ws", .port = 80 }, /* PROTO_WS */
{ .name = "wss", .port = 443 }, /* PROTO_WSS */
{ .name = "udp", .default_rfc_port = 5060 }, /* PROTO_UDP */
{ .name = "tcp", .default_rfc_port = 5060 }, /* PROTO_TCP */
{ .name = "tls", .default_rfc_port = 5061 }, /* PROTO_TLS */
{ .name = "sctp", .default_rfc_port = 5060 }, /* PROTO_SCTP */
{ .name = "ws", .default_rfc_port = 80 }, /* PROTO_WS */
{ .name = "wss", .default_rfc_port = 443 }, /* PROTO_WSS */
/* populate here for other protos - not necessary right now */
};

Expand Down Expand Up @@ -104,13 +104,10 @@ int trans_load(void)
found_proto = 1;
/* copy necessary info */
protos[pi.id].id = pi.id;
protos[pi.id].name = pi.name;
protos[pi.id].default_port = pi.default_port;
protos[pi.id].tran = pi.tran;
protos[pi.id].net = pi.net;
/*
* XXX: make sure you never overwrite port or name
* should we put it in a separate structure?
*/
}
}
if (found_proto)
Expand Down
2 changes: 1 addition & 1 deletion net/trans.h
Expand Up @@ -35,7 +35,7 @@ struct proto_info {
char *name;

/* the default port according to RFC */
unsigned short port;
unsigned short default_rfc_port;

/* proto as ID */
enum sip_protos id;
Expand Down
2 changes: 1 addition & 1 deletion parser/parse_uri.h
Expand Up @@ -69,7 +69,7 @@ static inline unsigned short get_uri_port(struct sip_uri* _uri,

/* known port? */
if ((port=_uri->port_no)==0)
port = protos[proto].default_port;
port = protos[proto].default_rfc_port;

if (_proto) *_proto = proto;

Expand Down

0 comments on commit 00d052c

Please sign in to comment.