Browse code

- added ROUND4 for *cloner2 (tm)

Andrei Pelinescu-Onciul authored on 15/01/2002 22:34:51
Showing 3 changed files
... ...
@@ -53,7 +53,7 @@ ARCH = $(shell uname -s)
53 53
 
54 54
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
55 55
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
56
-	-DBRUT_HACK #-DVQ_MALLOC 
56
+	-DBRUT_HACK -DVQ_MALLOC 
57 57
 	#-DEXTRA_DEBUG -DBRUT_HACK \
58 58
 	#-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
59 59
 	  #-DDBG_QM_MALLOC #-DVQ_MALLOC #-DNO_DEBUG
... ...
@@ -7,6 +7,8 @@
7 7
 #include "../../dprint.h"
8 8
 #include "../../mem/mem.h"
9 9
 
10
+#define ROUND4(s) ((s)%4)?((s)+4)/4*4:(s)
11
+
10 12
 char*   translate_pointer( char* new_buf , char *org_buf , char* p);
11 13
 struct via_body* via_body_cloner( char* new_buf , char *org_buf , struct via_body *org_via);
12 14
 struct hdr_field* header_cloner( struct sip_msg *new_msg , struct sip_msg *org_msg, struct hdr_field *hdr);
... ...
@@ -484,29 +486,29 @@ struct sip_msg*  sip_msg_cloner_2( struct sip_msg *org_msg )
484 486
 
485 487
 
486 488
    /*computing the length of entire sip_msg structure*/
487
-   len = sizeof( struct sip_msg );
489
+   len = ROUND4(sizeof( struct sip_msg ));
488 490
    /*we will keep only the original msg*/
489
-   len += org_msg->len;
491
+   len += ROUND4(org_msg->len);
490 492
    /*the new uri (if any)*/
491 493
    if (org_msg->new_uri.s && org_msg->new_uri.len)
492
-      len+= org_msg->new_uri.len;
494
+      len+= ROUND4(org_msg->new_uri.len);
493 495
    /*all the headers*/
494 496
    for( hdr=org_msg->headers ; hdr ; hdr=hdr->next )
495 497
    {
496
-      /*sze of header struct*/
497
-      len += sizeof( struct hdr_field);
498
+      /*size of header struct*/
499
+      len += ROUND4(sizeof( struct hdr_field));
498 500
       switch (hdr->type)
499 501
       {
500 502
          case HDR_CSEQ:
501
-                   len+=sizeof(struct cseq_body);
503
+                   len+=ROUND4(sizeof(struct cseq_body));
502 504
                    break;
503 505
          case HDR_VIA:
504 506
                    for (via=(struct via_body*)hdr->parsed;via;via=via->next)
505 507
                    {
506
-                      len+=sizeof(struct via_body);
508
+                      len+=ROUND4(sizeof(struct via_body));
507 509
                       /*via param*/
508 510
                       for(prm=via->param_lst;prm;prm=prm->next)
509
-                         len+=sizeof(struct via_param );
511
+                         len+=ROUND4(sizeof(struct via_param ));
510 512
                    }
511 513
                    break;
512 514
       }
... ...
@@ -524,22 +526,24 @@ struct sip_msg*  sip_msg_cloner_2( struct sip_msg *org_msg )
524 526
    new_msg = (struct sip_msg*)p;
525 527
    /*sip msg structure*/
526 528
    memcpy( new_msg , org_msg , sizeof(struct sip_msg) );
527
-   p += sizeof(struct sip_msg);
529
+   p += ROUND4(sizeof(struct sip_msg));
528 530
    new_msg->add_rm = new_msg->repl_add_rm = 0;
529 531
    /*new_uri*/
530 532
    if (org_msg->new_uri.s && org_msg->new_uri.len)
531 533
    {
532 534
       new_msg->new_uri.s = p;
533 535
       memcpy( p , org_msg->new_uri.s , org_msg->new_uri.len);
534
-      p += org_msg->new_uri.len;
536
+      p += ROUND4(org_msg->new_uri.len);
535 537
    }
536 538
    /*message buffers(org and scratch pad)*/
537 539
    memcpy( p , org_msg->orig , org_msg->len);
538 540
    new_msg->orig = new_msg->buf = p;
539
-   p += new_msg->len;
541
+   p += ROUND4(new_msg->len);
540 542
    /*unparsed and eoh pointer*/
541
-   new_msg->unparsed = translate_pointer( new_msg->buf , org_msg->buf , org_msg->unparsed );
542
-   new_msg->eoh = translate_pointer( new_msg->buf , org_msg->buf , org_msg->eoh );
543
+   new_msg->unparsed = translate_pointer( new_msg->buf , 
544
+							org_msg->buf , org_msg->unparsed );
545
+   new_msg->eoh = translate_pointer( new_msg->buf ,
546
+							org_msg->buf , org_msg->eoh );
543 547
    /* first line, updating the pointers*/
544 548
    if ( org_msg->first_line.type==SIP_REQUEST )
545 549
    {
... ...
@@ -561,7 +565,7 @@ struct sip_msg*  sip_msg_cloner_2( struct sip_msg *org_msg )
561 565
    {
562 566
       new_hdr = (struct hdr_field*)p;
563 567
       memcpy(new_hdr, hdr, sizeof(struct hdr_field) );
564
-      p += sizeof( struct hdr_field);
568
+      p += ROUND4(sizeof( struct hdr_field));
565 569
       new_hdr->name.s =  translate_pointer( new_msg->buf , org_msg->buf , hdr->name.s );
566 570
       new_hdr->body.s =  translate_pointer( new_msg->buf , org_msg->buf , hdr->body.s );
567 571
 
... ...
@@ -593,7 +597,7 @@ struct sip_msg*  sip_msg_cloner_2( struct sip_msg *org_msg )
593 597
                    break;
594 598
          case HDR_CSEQ:
595 599
                    new_hdr->parsed = p;
596
-                   p +=sizeof(struct cseq_body);
600
+                   p +=ROUND4(sizeof(struct cseq_body));
597 601
                    memcpy( new_hdr->parsed , hdr->parsed , sizeof(struct cseq_body) );
598 602
                    ((struct cseq_body*)new_hdr->parsed)->number.s =  translate_pointer( new_msg->buf , org_msg->buf , ((struct cseq_body*)hdr->parsed)->number.s );
599 603
                    ((struct cseq_body*)new_hdr->parsed)->method.s =  translate_pointer( new_msg->buf , org_msg->buf , ((struct cseq_body*)hdr->parsed)->method.s );
... ...
@@ -641,7 +645,7 @@ struct via_body* via_body_cloner_2( char* new_buf , char *org_buf , struct via_b
641 645
     /* clones the via_body structure */
642 646
     new_via = (struct via_body*)(*p);
643 647
     memcpy( new_via , org_via , sizeof( struct via_body) );
644
-    (*p) += sizeof( struct via_body );
648
+    (*p) += ROUND4(sizeof( struct via_body ));
645 649
 
646 650
     /* hdr (str type) */
647 651
     new_via->hdr.s = translate_pointer( new_buf , org_buf , org_via->hdr.s );
... ...
@@ -668,7 +672,7 @@ struct via_body* via_body_cloner_2( char* new_buf , char *org_buf , struct via_b
668 672
        {
669 673
            new_vp = (struct via_param*)(*p);
670 674
            memcpy( new_vp , vp , sizeof(struct via_param));
671
-           (*p) += sizeof(struct via_param);
675
+           (*p) += ROUND4(sizeof(struct via_param));
672 676
            new_vp->name.s = translate_pointer( new_buf , org_buf , vp->name.s );
673 677
            new_vp->value.s = translate_pointer( new_buf , org_buf , vp->value.s );
674 678
 
... ...
@@ -1,4 +1,4 @@
1 1
 #!/bin/sh
2 2
 
3
-ipcrm -s `ipcs -s |grep $(whoami) | awk '{ print $2; }'`
4
-ipcrm -m `ipcs -m | grep $(whoami) |awk '{ print $2; }'` 
3
+ipcrm sem `ipcs -s |grep $(whoami) | awk '{ print $2; }'`
4
+ipcrm shm `ipcs -m | grep $(whoami) |awk '{ print $2; }'`