MCPcopy Create free account
hub / github.com/F-Stack/f-stack / AliasHandleSkinny

Function AliasHandleSkinny

freebsd/netinet/libalias/alias_skinny.c:303–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303static void
304AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *lnk)
305{
306 size_t hlen, tlen, dlen;
307 struct tcphdr *tc;
308 u_int32_t msgId, t, len, lip;
309 struct skinny_header *sd;
310 size_t orig_len, skinny_hdr_len = sizeof(struct skinny_header);
311 ConvDirection direction;
312
313 lip = -1;
314 tc = (struct tcphdr *)ip_next(pip);
315 hlen = (pip->ip_hl + tc->th_off) << 2;
316 tlen = ntohs(pip->ip_len);
317 dlen = tlen - hlen;
318
319 sd = (struct skinny_header *)tcp_next(tc);
320
321 /*
322 * XXX This direction is reserved for future use. I still need to
323 * handle the scenario where the call manager is on the inside, and
324 * the calling phone is on the global outside.
325 */
326 if (ntohs(tc->th_dport) == la->skinnyPort) {
327 direction = ClientToServer;
328 } else if (ntohs(tc->th_sport) == la->skinnyPort) {
329 direction = ServerToClient;
330 } else {
331#ifdef LIBALIAS_DEBUG
332 fprintf(stderr,
333 "PacketAlias/Skinny: Invalid port number, not a Skinny packet\n");
334#endif
335 return;
336 }
337
338 orig_len = dlen;
339 /*
340 * Skinny packets can contain many messages. We need to loop
341 * through the packet using len to determine message boundaries.
342 * This comes into play big time with port messages being in the
343 * same packet as register messages. Also, open receive channel
344 * acks are usually buried in a packet some 400 bytes long.
345 */
346 while (dlen >= skinny_hdr_len) {
347 len = (sd->len);
348 msgId = (sd->msgId);
349 t = len;
350
351 if (t > orig_len || t > dlen) {
352#ifdef LIBALIAS_DEBUG
353 fprintf(stderr,
354 "PacketAlias/Skinny: Not a skinny packet, invalid length \n");
355#endif
356 return;
357 }
358 switch (msgId) {
359 case REG_MSG: {
360 struct RegisterMessage *reg_mesg;

Callers 1

protohandlerFunction · 0.85

Calls 6

ip_nextFunction · 0.85
tcp_nextFunction · 0.85
alias_skinny_reg_msgFunction · 0.85
alias_skinny_port_msgFunction · 0.85
alias_skinny_startmediaFunction · 0.85

Tested by

no test coverage detected