File: sdpdemo.c

package info (click to toggle)
uclmmbase 1.2.16.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, jessie, jessie-kfreebsd, lenny, squeeze, wheezy
  • size: 1,460 kB
  • ctags: 1,276
  • sloc: ansic: 11,847; sh: 2,734; makefile: 249
file content (69 lines) | stat: -rw-r--r-- 1,215 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * sdpdemo: A simple sdp application that recieves SAP/SDP data.
 *
 * (c) 2002 Argonne National Laboratory/University of Chicago
 */

#include <sys/time.h>

#include <ctype.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include "uclconf.h"
#include "config_unix.h"
#include "config_win32.h"
#include "debug.h"
#include "memory.h"
#include "sap.h"
#include "sdp.h"

static void
sap_handler(sap_packet *packet)
{
  sdp *session = NULL;
  char *new_payload = NULL;

  print_sap_packet(packet); 

  session = sdp_parse(packet->payload);

  printf("Original Packet: \n++++\n%s++++\n", session->original);

  sdp_print(session);

  new_payload = sdp_make(session);

  if(strcmp(packet->payload, new_payload) != 0)
    printf("The two sdp payloads are different!\n");

  xfree(new_payload);

  sdp_free(session);

  /* This is causing a seg fault, and a memory leak */
  /*  xfree(packet); */
}


int
main()
{
  struct sap *session = NULL;
  struct timeval timeout;

  session = sap_init("224.2.127.254", 9875, 127, sap_handler);

  timeout.tv_sec = 0;
  timeout.tv_usec = 0;

  while(1) 
    sap_recv(session, &timeout);

  sap_done(session);

  return 0;
}