Search on this blog

Showing posts with label Forwarded. Show all posts
Showing posts with label Forwarded. Show all posts

Thursday, November 5, 2009

Nice forward: 12 Ways to Know That You Love Someone

Hi………..

12 Ways to Know That You Love Someone

TWELVE:
You talk with him/her late at night and when you go to bed you still think of him/her.

ELEVEN:
You walk really slowly when you are with him/her.

TEN:
You don't feel Ok when he/she is far away.

NINE:
You smile when you hear his/her voice..

EIGHT:
When you look at him/her, you do not see other people around you. You see only him/her.

SIX:
He/She is everything you want to think.

FIVE:
You realize that you smile every time you look at him/her.

FOUR:
You would do anything to see him/her.

THREE:
While you have been reading this, there was a person in your mind all the time.

TWO:
You've been so busy thinking of that person that you didn't notice that number 7 is missing.

ONE:
You are going to check above if that's true and now you are silently laughing to yourself.
Read full history - Nice forward: 12 Ways to Know That You Love Someone

Monday, April 13, 2009

TOLL FREE NOS. IN INDIA

Airlines
Indian Airlines - 1800 180 1407
Jet Airways - 1800 22 5522
SpiceJet - 1800 180 3333
Air India -- 1800 22 7722
KingFisher - 1800 180 0101

Banks
ABN AMRO - 1800 11 2224
Canara Bank - 1800 44 6000
Citibank - 1800 44 2265
Corporatin Bank - 1800 443 555
Development Credit Bank - 1800 22 5769
HDFC Bank - 1800 227 227
ICICI Bank - 1800 333 499
ICICI Bank NRI - 1800 22 4848
IDBI Bank - 1800 11 6999
Indian Bank - 1800 425 1400
ING Vysya - 1800 44 9900
Kotak Mahindra Bank - 1800 22 6022
Lord Krishna Bank - 1800 11 2300
Punjab National Bank - 1800 122 222
State Bank of India - 1800 44 1955
Syndicate Bank - 1800 44 6655

Automobiles
Mahindra Scorpio - 1800 22 6006
Maruti - 1800 111 515
Tata Motors - 1800 22 5552
Windshield Experts - 1800 11 3636

Computers/IT
Adrenalin - 1800 444 445
AMD - 1800 425 6664
Apple Computers - 1800 444 683
Canon - 1800 333 366
Cisco Systems - 1800 221 777
Compaq - HP - 1800 444 999
Data One Broadband - 1800 424 1800
Dell - 1800 444 026
Epson - 1800 44 0011
eSys - 3970 0011
Genesis Tally Academy - 1800 444 888
HCL - 1800 180 8080
IBM - 1800 443 333
Lexmark - 1800 22 4477
Marshal's Point - 1800 33 4488
Microsoft - 1800 111 100
Microsoft Virus Update - 1901 333 334
Seagate - 1800 180 1104
Symantec - 1800 44 5533
TVS Electronics - 1800 444 566
WeP Peripherals - 1800 44 6446
Wipro - 1800 333 312
xerox - 1800 180 1225
Zenith - 1800 222 004



Indian Railway General Enquiry 131
Indian Railway Central Enquiry 131
Indian Railway Reservation 131
Indian Railway Railway Reservation Enquiry 1345,1335,1330
Indian Railway Centralised Railway Enquiry 1330/1/2/3/4/5/6/7/8/9


Couriers/Packers & Movers
ABT Courier - 1800 44 8585
AFL Wizz - 1800 22 9696
Agarwal Packers & Movers - 1800 11 4321
Associated Packers P Ltd - 1800 21 4560
DHL - 1800 111 345
FedEx - 1800 22 6161
Goel Packers & Movers - 1800 11 3456
UPS - 1800 22 7171

Home Appliances
Aiwa/Sony - 1800 11 1188
Anchor Switches - 1800 22 7979
Blue Star - 1800 22 2200
Bose Audio - 1800 11 2673
Bru Coffee Vending Machines - 1800 44 7171
Daikin Air Conditioners - 1800 444 222
DishTV - 1800 12 3474
Faber Chimneys - 1800 21 4595
Godrej - 1800 22 5511
Grundfos Pumps - 1800 33 4555
LG - 1901 180 9999
Philips - 1800 22 4422
Samsung - 1800 113 444
Sanyo - 1800 11 0101
Voltas - 1800 33 4546
WorldSpace Satellite Radio - 1800 44 5432

Investments/ Finance
CAMS - 1800 44 2267
Chola Mutual Fund - 1800 22 2300
Easy IPO's - 3030 5757
Fidelity Investments - 1800 180 8000
Franklin Templeton Fund - 1800 425 4255
J M Morgan Stanley - 1800 22 0004
Kotak Mutual Fund - 1800 222 626
LIC Housing Finance - 1800 44 0005
SBI Mutual Fund - 1800 22 3040
Sharekhan - 1800 22 7500
Tata Mutual Fund - 1800 22 0101

Travel
Club Mahindra Holidays - 1800 33 4539
Cox & Kings - 1800 22 1235
God TV Tours - 1800 442 777
Kerala Tourism - 1800 444 747
Kumarakom Lake Resort - 1800 44 5030
Raj Travels & Tours - 1800 22 9900
Sita Tours - 1800 111 911
SOTC Tours - 1800 22 3344



Healthcare
Best on Health - 1800 11 8899
Dr Batras - 1800 11 6767
GlaxoSmithKline - 1800 22 8797
Johnson & Johnson - 1800 22 8111
Kaya Skin Clinic - 1800 22 5292
LifeCell - 1800 44 5323
Manmar Technologies - 1800 33 4420
Pfizer - 1800 442 442
Roche Accu-Chek - 1800 11 45 46
Rudraksha - 1800 21 4708
Varilux Lenses - 1800 44 8383
VLCC - 1800 33 1262

Insurance
AMP Sanmar - 1800 44 2200
Aviva - 1800 33 2244
Bajaj Allianz - 1800 22 5858
Chola MS General Insurance - 1800 44 5544
HDFC Standard Life - 1800 227 227
LIC - 1800 33 4433
Max New York Life - 1800 33 5577
Royal Sundaram - 1800 33 8899
SBI Life Insurance - 1800 22 9090

Hotel Reservations
GRT Grand - 1800 44 5500
InterContinental Hotels Group - 1800 111 000
Marriott - 1800 22 0044
Sarovar Park Plaza - 1800 111 222
Taj Holidays - 1800 111 825

Tele-shopping
Asian Sky Shop - 1800 22 1800
Jaipan Teleshoppe - 1800 11 5225
Tele Brands - 1800 11 8000
VMI Teleshopping - 1800 447 777
WWS Teleshopping - 1800 220 777

Others
Domino's Pizza - 1800 111 123

Cell Phones
BenQ - 1800 22 08 08
Bird CellPhones - 1800 11 7700
Motorola MotoAssist - 1800 11 1211
Nokia - 3030 3838
Sony Ericsson - 3901 1111
Read full history - TOLL FREE NOS. IN INDIA

Monday, April 6, 2009

Italian Love

An 18 year old Italian girl tells her Mom that she is pregnant.

Shouting, cursing, crying, the mother says, 'who was the pig that did this to you? I want to know!'
The girl picks up the phone and makes a call. Half an hour later, a Ferrari stops in front of their house.
A mature and distinguished man with grey hair and impeccably dressed in an Armani suit steps out of the
Ferrari and enters the house.

He sits in the living room with the father, mother, and the girl and tells them: 'Good morning, your daughter
has informed me of the problem. I can't marry her because of my personal family situation but I'll take charge.
I will pay all costs and provide for your daughter for the rest of her life. Additionally, if a girl is born, I will bequeath
a Ferrari, 2 retail stores, a townhouse, a beach front villa, and a $2,000,000 bank account. If a boy is born, my legacy
will be a couple of factories and a $4,000,000 bank account. If twins, they will receive a factory and $2,000,000 each.

However, if there is a miscarriage, what do you suggest I do?'
At this point, the father, who had remained silent, places a hand firmly on the man's shoulder and tells him,
'You try again.'
Read full history - Italian Love

Wednesday, April 1, 2009

DO NOT DRINK & DRIVE

I was walking around in a Big Bazar store making shopping, when I saw a Cashier talking to a boy couldn't have been more than 5 or 6 years old.
The Cashier said, 'I'm sorry, but you don't have enough money to buy this doll. Then the little boy turned to me and asked: ''Uncle, are you sure I don't have enough money?''
I counted his cash and replied: ''You know that you don't have enough money to buy the doll , my dear.'' The little boy was still holding the doll in his hand.
Finally, I walked toward him and I asked him who he wished to give this doll to. 'It's the doll that my sister loved most and wanted so much. I wanted to Gift her for her BIRTHDAY.
I have to give the doll to my mummy so that she can give it to my sister when she goes there.' His eyes were so sad while saying this. 'My Sister has gone to be with God . Daddy says that Mummy is going to see God very soon too, so I thought that she could take the doll with her to give it to my sister.''
My heart nearly stopped. The little boy looked up at me and said: 'I told daddy to tell mummy not to go yet. I need her to wait until I come back from the mall.' Then he showed me a very nice photo of him where he was laughing. He then told me 'I want mummy to take my picture with her so my sister won't forget me.' 'I love my mummy and I wish she doesn't have to leave me, but daddy says that she has to go to be with my little sister.' Then he looked again at the doll with sad eyes, very quietly.
I quickly reached for my wallet and said to the boy. 'Suppose we check again, just in case you do have enough money for the doll?'' 'OK' he said, 'I hope I do have enough.' I added some of my money to his without him seeing and we started to count it. There was enough for the doll and even some spare money.
The little boy said: 'Thank you God for giving me enough money!' Then he looked at me and added, 'I asked last night before I went to sleep for God to make sure I had enough money to buy this doll, so that mummy could give It to my sister. He heard me!'' 'I also wanted to have enough money to buy a white rose for my mummy, but I didn't dare to ask God for too much. But He gave me enough to buy the doll and a white rose. My mommy loves white roses.'
I finished my shopping in a totally different state from when I started. I couldn't get the little boy out of my mind. Then I remembered a local news paper article two days ago, which mentioned a drunk man in a truck, who hit a car occupied by a young woman and a little girl. The little girl died right away, and the mother was left in a critical state.
The family had to decide whether to pull the plug on the life-sustaining machine, because the young woman would not be able to recover from the coma.. Was this the family of the little boy?
Two days after this encounter with the little boy, I read in the newspaper that the young woman had passed away. I couldn't stop myself as I bought a bunch of white roses and I went to the funeral home where the body of the young woman was exposed for people to see and make last wishes before her burial. She was there, in her coffin, holding a beautiful white rose in her hand with the photo of the little boy and the doll placed over her chest. I left the place, teary-eyed, feeling that my life had been changed forever..
The love that the little boy had for his mother and his sister is still, to this day, hard to imagine. And in a fraction of a second, a drunk driver had taken all this away from him.
Please DO NOT DRINK & DRIVE.
Read full history - DO NOT DRINK & DRIVE

Thursday, March 26, 2009

someday


Some day, someone will come into ur life

&

Love You da way You always wanted....

If your someday was yesterday, learn.

If your someday is tomorrow, hope..

If your someday is today, cherish!!!
Read full history - someday

Wednesday, March 25, 2009

How Much Does a Girl Love!!!

There was once this guy who was very much in love with his girl.
This romantic guy folded 1,000 pieces of paper cranes as a
gift to his girl.

Although, at that time he was just a small fry in his company, his
future doesn't seem too bright, they were very happy together. Until one day,
his girl told him she was going to Paris and will never come back. She also told
him that she cannot visualize any future for the both of them, so they went their own ways
there and then...
Heartbroken, the guy agreed. But when he regained his confidence, he
worked hard day and night, slogging his body and mind just to make something out of
himself.

Finally with all the hard work and the help of friends, this guy had
set up his own company ..
You never fail until you stop trying. One rainy day, while this guy was
driving, he saw an elderly
couple sharing an umbrella in the rain walking to some destination. Even
with the umbrella, they
were still drenched. It didn't take him long to realize they were his
girl's parents. With a heart
in getting back at them, he drove slowly beside the couple, wanting them
to spot him in his luxury
sedan. He wanted them to know that he wasn't the same any more; he had
his own company, car, condo, etc.
He made it! What he saw next confused him, the couple was walking
towards a cemetery, and so he got out
of his car and followed...and he saw his girl, a photograph of her
smiling sweetly as ever at him from
her tombstone and he saw his paper cranes right beside her...

Her parents saw him. He asked them why this had happened. They
explained, she did not leave for France at all.
She was ill with cancer. She had believed that he will make it someday,
but she did not want to be
his obstacle... therefore she had chosen to leave him. Just because
someone doesn't love you the way you
want them to, doesn't mean they don't love you with all they have. She
had wanted her parents to put
his paper cranes beside her, because, if the day comes when fate brings
him to her again...he can take some
of those back with him... Once you have loved, you will always love. For
what's in your mind may escape but what's in your heart will remain forever.

The guy just wept.....The worst way to miss someone is to be sitting
right beside her knowing you can't have her,
see her or be with her ever again.........hope you understand. Find
time to realise that there is one person
who means so much to you, for you might wake up one morning losing that
person who you thought meant nothing to you.
Read full history - How Much Does a Girl Love!!!

Friday, March 13, 2009

What 'Pujo' means to a Bengali by Vir Sanghvi


Most modern Indian cities strive to rise above ethnicity.

Tell anybody who lives in Bombay that he lives in a Maharashtrian city and (unless of course, you are speaking to Bal Thackeray) he will take immediate offence. We are cosmopolitan, he will say indigenously. Tell a Delhiwalla that his is a Punjabi city (which, in many ways, it is) and he will respond with much self-righteous nonsense about being the nation's capital, about the international composition of the city's elite etc. And tell a Bangalorean that he lives in a Kannadiga city and you'll get lots of techno-gaff about the internet revolution and about how Bangalore is even more cosmopolitan than Bombay.

But, the only way to understand what Calcutta is about is recognize that the city is essentially Bengali. What's more, no Bengali minds you saying that. Rather, he is proud of the fact. Calcutta's strengths and weaknesses mirror those of the Bengali character. It has the drawbacks: the sudden passions, the cheerful chaos, the utter contempt for mere commerce, the fiery response to the smallest provocation.

And it has the strengths (actually, I think of the drawbacks as strengths in their own way). Calcutta embodies the Bengali love of culture; the triumph of intellectualism over greed; the complete transparency of all emotions, the disdain with which hypocrisy and insincerity are treated; the warmth of genuine humanity; and the supremacy of emotion over all other aspects of human existence.

That's why Calcutta is not for everyone. You want your cities clean and green; stick to Delhi. You want your cities, rich and impersonal; go to Bombay. You want them high-tech and full of draught beer; Bangalore's your place. But if you want a city with a soul: come to Calcutta.

When I look back on the years I've spent in Calcutta - and I come back so many times each year that I often feel I've never been away - I don't remember the things that people remember about cities. When I think of London, I think of the vast open spaces of Hyde Park. When I think of New York, I think of the frenzy of Times Square. When I think of Tokyo, I think of the bright lights of Shinjiku. And when I think of Paris, I think of the Champs Elysee. But when I think of Calcutta, I never think of any one place. I don't focus on the greenery of the maidan, the beauty of the Victoria Memorial, the bustle of Burra Bazar or the splendour of the new Howrah 'Bridge'. I think of people.

Because, finally, a city is more than bricks and mortars, street lights and tarred roads. A city is the sum of its people. And who can ever forget - or replicate - the people of Calcutta?

When I first came to live here, I was told that the city would grow on me. What nobody told me was that the city would change my life. It was in Calcutta that I learnt about true warmth; about simple human decency; about love and friendship; about emotions and caring; about truth and honesty. I learnt other things too. Coming from Bombay as I did, it was a revelation to live in a city where people judged each other on the things that really mattered; where they recognized that being rich did not make you a better person - in fact, it might have the opposite effect. I learnt also that if life is about more than just money, it is about the things that other cities ignore; about culture, about ideas, about art, and about passion. In Bombay, a man with a relatively low income will salt some of it away for the day when he gets a stock market tip. In Calcutta, a man with exactly the same income will not know the difference between a debenture and a dividend. But he will spend his money on the things that matter. Each morning, he will read at least two newspapers and develop sharply etched views on the state of the world.

Each evening, there will be fresh (ideally, fresh-water or river) fish on his table. His children will be encouraged to learn to dance or sing. His family will appreciate the power of poetry. And for him, religion and culture will be in inextricably bound together.

Ah religion! Tell outsiders about the importance of Puja in Calcutta and they'll scoff. Don't be silly, they'll say. Puja is a religious festival. And Bengal has voted for the CPM since 1977. How can godless Bengal be so hung up on a religions festival? I never know how to explain them that to a Bengali, religion consists of much more than shouting Jai Shri Ram or pulling down somebody's mosque. It has little to do with meaningless ritual or sinister political activity.

The essence of Puja is that all the passions of Bengal converge: emotion, culture, the love of life, the warmth of being together, the joy of celebration, the pride in artistic expression and yes, the cult of the goddess.

It may be about religion. But is about much more than just worship. In which other part of India would small, not particularly well-off localities, vie with each other to produce the best pandals? Where else could puja pandals go beyond religion to draw inspiration from everything else? In the years I lived in Calcutta, the pandals featured Amitabh Bachchan, Princes Diana and even Saddam Hussain! Where else would children cry with the sheer emotional power of Dashami, upset that the Goddess had left their homes? Where else would the whole city gooseflesh when the dhakis first begin to beat their drums? Which other Indian festival - in any part of the country - is so much about food, about going from one roadside stall to another, following your nose as it trails the smells of cooking?

To understand Puja, you must understand Calcutta. And to understand Calcutta, you must understand the Bengali. It's not easy.

Certainly, you can't do it till you come and live here, till you let Calcutta suffuse your being, invade your bloodstream and steal your soul. But once you have, you'll love Calcutta forever. Wherever you go, a bit of Calcutta will go with you. I know, because it's happened to me. And every Puja, I am overcome by the magic of Bengal. It's a feeling that'll never go away.
Read full history - What 'Pujo' means to a Bengali by Vir Sanghvi

Forwarded mail: No subject

Ok this one is a mail forwarded by my friend, I thought of sharing this with you people...


AMAR KACHHE ROMANCE MANE VIETNAM ER MATITE AMARICA
R BOMA BORSONER SOMOY SOBUJ GHASS AKRE PORE THAKA.......


comrade mane pasapasi thaka
comrade mane sathi
comrade mane natun prithibi
natun ekta jati...

I haven't added any photo here bcoz I don't want to be in argument...
Read full history - Forwarded mail: No subject

Tuesday, February 17, 2009

Here i am sitting in my office @ night.

Here i am sitting in my office @ night
Thinking hard about life
How it changed from a maverick collage life to strict professional life...

How tiny pocket money changed to huge monthly paychecks
but then why it gives less happiness.

How a few local denim jeans changed to new branded wardrobe
but then why there are less people to use them

How a single plate of samosa changed to a full Pizza or burger
But then why there is less hunger..

Here i am sitting in my office @ night
Thinking hard about life
How it changed..

How a bike always in reserve changed to bike always on
but then why there are less places to go on

How a small coffee shop changed to cafe coffee day
but then why its feels like shop is far away..

How a limited prepaid card changed to postpaid package
but then why there are less calls & more messages

Here i am sitting in my office @ night
Thinking hard about life
How it changed...

How a general class journey changed to Flight journey
But then why there are less vacations for enjoyment.

How a old assembled desktop changed to new branded laptop
but then why there is less time to put it on.

How a small bunch of friends changed to office mate
But then why we always feel lonely n miss those college frnz..

Here i am sitting in my office @ night
Thinking hard about life
How it changed.. How it changed..
Read full history - Here i am sitting in my office @ night.

Thursday, February 5, 2009

Recent Stock Market Joke



1. The US has made a new weapon that destroys people but keeps the building standing. It's called the stock market - Jay Leno
2. Do you have any idea how cheap stocks are?? Wall Street is now being called Wal Mart Street -Jay Leno
3. The difference between a pigeon and a London investment banker. The pigeon can still make a deposit on a BMW
4. What's the difference between a guy who lost everything in Las Vegas and an investment banker? A tie
5. The problem with investment bank balance sheet is that on the left side nothing's right and on the right side nothing's left.
6. Bush was asked about the credit crunch. He said it was his favourite candy bar - Jay Leno
7. President Bush's response to the liquidity crunch was to meet some small business owners in San Antonio last week. The small business owners are General Motors, General Electric and Century 21. - Jay Leno
8. What worries me most about the credit crunch, is that if one of my cheques is returned stamped 'insufficient funds. I won't know whether that refers to mine or the banks.

NEW STOCK MARKET TERMS

CEO --Chief Embezzlement Officer.
CFO -- Corporate Fraud Officer.
BULL MARKET -- A random market movement causing an investor to mistake himself for a financial genius.
BEAR MARKET -- A 6 to 18 month period when the kids get no allowance, the wife gets no jewelry.
VALUE INVESTING -- The art of buying low and selling lower.
BROKER -- What my broker has made me.
STANDARD & POOR -- Your life in a nutshell.
STOCK ANALYST -- Idiot who just downgraded your stock.
STOCK SPLIT -- When your ex-wife and her lawyer split your assets equally between themselves.
FINANCIAL PLANNER -- A guy whose phone has been disconnected.
MARKET CORRECTION -- The day after you buy stocks.
CASH FLOW-- The movement your money makes as it disappears down the toilet.
YAHOO -- What you yell after selling it to some poor sucker for $240 per share.
WINDOWS -- What you jump out of when you're the sucker who bought Yahoo @ $240 per share.
INSTITUTIONAL INVESTOR -- Past year investor who's now locked up in a nuthouse.
PROFIT -- An archaic word no longer in use.
Read full history - Recent Stock Market Joke

Wednesday, February 4, 2009

What is recession?

This Story is about a man who once upon a time was selling Hotdogs by the roadside.
He was illiterate, so he never read newspapers.
He was hard of hearing, so he never listened to the radio.
His eyes were weak, so he never watched television.
But enthusiastically, he sold lots of hotdogs.
He was smart enough to offer some attractive schemes to increase his sales.
His sales and profit went up.
He ordered more a more raw material and buns and use to sale more.
He recruited few more supporting staff to serve more customers.
He started offering home deliveries. Eventually he got himself a bigger and better stove.
As his business was growing, the son, who had recently graduated from College, joined his father.


Then something strange happened.
The son asked, "Dad, aren't you aware of the great recession that is coming our way?"
The father replied, "No, but tell me about it." The son said, "The international situation is terrible.
The domestic situation is even worse. We should be prepared for the coming bad times."
The man thought that since his son had been to college, read the papers, listened to the radio and watched TV.
He ought to know and his advice should not be taken lightly.
So the next day onwards, the father cut down the his raw material order and buns, took down the colourful signboard,
removed all the special schemes he was offering to the customers and was no longer as enthusiastic.
He reduced his staff strength by giving layoffs.
Very soon, fewer and fewer people bothered to stop at his hotdog stand.
And his sales started coming down rapidly, same is the profit.
The father said to his son, "Son, you were right".
"We are in the middle of a recession and crisis. I am glad you warned me ahead of time."



Moral of The Story: It's all in your MIND! And we actually FUEL this recession much more than we think.
Read full history - What is recession?

Thursday, January 15, 2009

How many of us have non veg in Nandini?


A forwarded but important mail...

Hi guys,
How many of us eat at Nadhini restaurants? Many? And how many of us
know it and trust it? Many of us, I think. So I think the email I got
from my friend Sandip is going to be something of a shocker.

"I found this in his home delivered chicken biriyani yesterday. I held
it in my hand, and almost put it in my mouth cos it was well cooked and
resembled a chicken piece :-) and then I just yelled my guts out !
Biriyani from Nandhini Palace / Nandhana Palace (domlur branch),
Bangalore. Sorry if you're grossed out, but had to let you know."

What is even more disgusting perhaps is that as an apology, the
Nandhini guys sent over a basket of fruit and a 2009 diary. My friend
wants to press charges and take this to the newspapers but the
restaurant guys are begging and pleading with him not to. What's more
there is the fear that these are powerful guys who can hurt him or
maybe even kill him if he tarnishes their reputation.

The Health Ministry will not act so as citizens, we must at least raise
awareness and not let this be hushed up. Please forward this email to
whomever you can to let them know. Please be careful when eating out
and if the picture isn't enough to dissuade you from eating at Nandhini,
I don't know what will.
Read full history - How many of us have non veg in Nandini?

Wednesday, January 14, 2009

A good quote

History is not only important events and important people. It is recorded with songs and painted on canvas.
It is told in stories. It lives in snapshots.
Read full history - A good quote

Friday, January 9, 2009

Raju Raju


Raju Raju sat on the wall
Raju Raju had a great fall
Balance sheet died
Shareholders cried
Raju Raju made a big fraud


Raju Raju
Yes baba
Cheating us
No baba
Telling Lies
No baba
Open the balance sheet
HA HA HA
Read full history - Raju Raju

Thursday, January 8, 2009

Nice forward: 12 Ways to Know That You Love Someone


Hi………..



12 Ways to Know That You Love Someone

TWELVE:
You talk with him/her late at night and when you go to bed you still think of him/her.

ELEVEN:
You walk really slowly when you are with him/her.

TEN:
You don't feel Ok when he/she is far away.

NINE:
You smile when you hear his/her voice..

EIGHT:
When you look at him/her, you do not see other people around you. You see only him/her.

SIX:
He/She is everything you want to think.

FIVE:
You realize that you smile every time you look at him/her.

FOUR:
You would do anything to see him/her.

THREE:
While you have been reading this, there was a person in your mind all the time.

TWO:
You've been so busy thinking of that person that you didn't notice that number 7 is missing.

ONE:
You are going to check above if that's true and now you are silently laughing to yourself.
Read full history - Nice forward: 12 Ways to Know That You Love Someone

Wednesday, January 7, 2009

An example SMS Server component

Cracked code which helps you in understanding how Mobile SMS SERVER GATEWAY/CENTER works???? - An excellent code.

/*****************************************************************************
* smsc_smpp.c - Short Message Peer to Peer Provisioning Protocol 3.3
* Mikael Gueck for WapIT Ltd.
*/
 
#include "errno.h"
#include "stdarg.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "unistd.h"
#include "sys/time.h"
#include "sys/types.h"
#include "sys/socket.h"
#include "netinet/in.h"
 
#include "smsc.h"
#include "smsc_smpp.h"
#include "octstr.h"
#include "wapitlib.h"
 
SMSCenter *smpp_open(char *host, int port, char *system_id, char *password, char* system_type, char *address_range) {
 
        SMSCenter *smsc = NULL;
        struct smpp_pdu *pdu = NULL;
        struct smpp_pdu_bind_receiver *bind_receiver = NULL;
        struct smpp_pdu_bind_transmitter *bind_transmitter = NULL;
 
        smsc = smscenter_construct();
        if(smsc==NULL) goto error;
 
        smsc->type = SMSC_TYPE_SMPP_IP;
        sprintf(smsc->name, "SMPP:%s:%i:%s:%s", host, port, system_id, system_type);
        smsc->latency = 100*1000;
 
        smsc->hostname = strdup(host);
        smsc->port = port;
 
        smsc->smpp_system_id = (system_id != NULL) ? strdup(system_id) : NULL;
        smsc->smpp_system_type = (system_type != NULL) ? strdup(system_type) : NULL;
        smsc->smpp_password = (password != NULL) ? strdup(password) : NULL;
        smsc->smpp_address_range = (address_range != NULL) ? strdup(address_range) : NULL;
 
        /* Create FIFO stacks */
        smsc->unsent_mt = fifo_new();
        if(smsc->unsent_mt == NULL) goto error;
 
        smsc->sent_mt = fifo_new();
        if(smsc->sent_mt == NULL) goto error;
 
        smsc->delivered_mt = fifo_new();
        if(smsc->delivered_mt == NULL) goto error;
 
        smsc->received_mo = fifo_new();
        if(smsc->received_mo == NULL) goto error;
 
        smsc->fifo_t_in = fifo_new();
        if(smsc->fifo_t_in == NULL) goto error;
 
        smsc->fifo_t_out = fifo_new();
        if(smsc->fifo_t_out == NULL) goto error;
 
        smsc->fifo_r_in = fifo_new();
        if(smsc->fifo_r_in == NULL) goto error;
 
        smsc->fifo_r_out = fifo_new();
        if(smsc->fifo_r_out == NULL) goto error;
 
        /* Create buffers */
        smsc->data_t = data_new();
        if(smsc->data_t == NULL) goto error;
        
        smsc->data_r = data_new();
        if(smsc->data_r == NULL) goto error;
 
        /* Open the transmitter connection */
        smsc->fd_t = tcpip_connect_to_server(smsc->hostname, smsc->port);
        if(smsc->fd_t == -1) goto error;
        debug(0, "smsc->fd_t == %i", smsc->fd_t);
        debug(0, "smsc->hostname == %s", smsc->hostname);
        debug(0, "smsc->port == %i", smsc->port);
        smsc->smpp_t_state = SMPP_STATE_CONNECTED;
 
        /* Open the receiver connection */
        smsc->fd_r = tcpip_connect_to_server(smsc->hostname, smsc->port);
        if(smsc->fd_r == -1) goto error;
        debug(0, "smsc->fd_r == %i", smsc->fd_t);
        debug(0, "smsc->hostname == %s", smsc->hostname);
        debug(0, "smsc->port == %i", smsc->port);
        smsc->smpp_r_state = SMPP_STATE_CONNECTED;
 
        /* Push a BIND_RECEIVER PDU on the [smsc->unsent] stack. */
        pdu = pdu_new();
        if(pdu == NULL) goto error;
        pdu->id = SMPP_BIND_RECEIVER;
        smsc->seq_r = 1;
        pdu->sequence_no = 1;
        bind_receiver = malloc(sizeof(struct smpp_pdu_bind_receiver));
        if(bind_receiver==NULL) goto error;
        memset(bind_receiver, 0, sizeof(struct smpp_pdu_bind_receiver));
        strncpy(bind_receiver->system_id, system_id, 16);
        strncpy(bind_receiver->password, password, 9);
        strncpy(bind_receiver->system_type, system_type, 13);
        strncpy(bind_receiver->address_range, address_range, 41);
        pdu->message_body = bind_receiver;
        fifo_push(smsc->fifo_r_out, pdu);
        
        /* Push a BIND_TRANSMITTER PDU on the [smsc->unsent] stack. */
        pdu = pdu_new();
        if(pdu == NULL) goto error;
        pdu->id = SMPP_BIND_TRANSMITTER;
        smsc->seq_t = 1;
        pdu->sequence_no = 1;
        bind_transmitter = malloc(sizeof(struct smpp_pdu_bind_transmitter));
        if(bind_transmitter==NULL) goto error;
        memset(bind_transmitter, 0, sizeof(struct smpp_pdu_bind_transmitter));
        strncpy(bind_transmitter->system_id, system_id, 16);
        strncpy(bind_transmitter->password, password, 9);
        strncpy(bind_transmitter->system_type, system_type, 13);
        strncpy(bind_transmitter->address_range, address_range, 41);
        pdu->message_body = bind_transmitter;
        fifo_push(smsc->fifo_t_out, pdu);
 
        /* Done, return */
        return smsc;
 
error:
        error(0, "smpp_open: could not open");
        pdu_free(pdu);
 
        /* Destroy FIFO stacks. */
        fifo_free(smsc->unsent_mt);
        fifo_free(smsc->sent_mt);
        fifo_free(smsc->delivered_mt);
        fifo_free(smsc->received_mo);
        fifo_free(smsc->fifo_t_in);
        fifo_free(smsc->fifo_t_out);
        fifo_free(smsc->fifo_r_in);
        fifo_free(smsc->fifo_r_out);
 
        /* Destroy buffers */
        data_free(smsc->data_t);
        data_free(smsc->data_r);
 
        smscenter_destruct(smsc);
        return NULL;
}
 
int smpp_reopen(SMSCenter *smsc) {
 
        struct smpp_pdu *pdu = NULL;
        struct smpp_pdu_bind_receiver *bind_receiver = NULL;
        struct smpp_pdu_bind_transmitter *bind_transmitter = NULL;
 
        if(smsc==NULL) goto error;
 
        /* Destroy FIFO stacks. */
        fifo_free(smsc->unsent_mt);
        fifo_free(smsc->sent_mt);
        fifo_free(smsc->delivered_mt);
        fifo_free(smsc->received_mo);
        fifo_free(smsc->fifo_t_in);
        fifo_free(smsc->fifo_t_out);
        fifo_free(smsc->fifo_r_in);
        fifo_free(smsc->fifo_r_out);
 
        /* Destroy buffers */
        data_free(smsc->data_t);
        data_free(smsc->data_r);
 
        /* Close sockets */
        close(smsc->fd_t);
        close(smsc->fd_r);
 
        /* Create FIFO stacks */
        smsc->unsent_mt = fifo_new();
        if(smsc->unsent_mt == NULL) goto error;
 
        smsc->sent_mt = fifo_new();
        if(smsc->sent_mt == NULL) goto error;
 
        smsc->delivered_mt = fifo_new();
        if(smsc->delivered_mt == NULL) goto error;
 
        smsc->received_mo = fifo_new();
        if(smsc->received_mo == NULL) goto error;
 
        smsc->fifo_t_in = fifo_new();
        if(smsc->fifo_t_in == NULL) goto error;
 
        smsc->fifo_t_out = fifo_new();
        if(smsc->fifo_t_out == NULL) goto error;
 
        smsc->fifo_r_in = fifo_new();
        if(smsc->fifo_r_in == NULL) goto error;
 
        smsc->fifo_r_out = fifo_new();
        if(smsc->fifo_r_out == NULL) goto error;
 
        /* Create buffers */
        smsc->data_t = data_new();
        if(smsc->data_t == NULL) goto error;
        
        smsc->data_r = data_new();
        if(smsc->data_r == NULL) goto error;
 
        /* Open the transmitter connection */
        smsc->fd_t = tcpip_connect_to_server(smsc->hostname, smsc->port);
        if(smsc->fd_t == -1) goto error;
        smsc->smpp_t_state = SMPP_STATE_CONNECTED;
 
        /* Open the receiver connection */
        smsc->fd_r = tcpip_connect_to_server(smsc->hostname, smsc->port);
        if(smsc->fd_r == -1) goto error;
        smsc->smpp_r_state = SMPP_STATE_CONNECTED;
 
        /* Push a BIND_RECEIVER PDU on the [smsc->unsent] stack. */
        pdu = pdu_new();
        if(pdu == NULL) goto error;
        pdu->id = SMPP_BIND_RECEIVER;
        smsc->seq_r = 1;
        pdu->sequence_no = 1;
        bind_receiver = malloc(sizeof(struct smpp_pdu_bind_receiver));
        if(bind_receiver==NULL) goto error;
        memset(bind_receiver, 0, sizeof(struct smpp_pdu_bind_receiver));
        strncpy(bind_receiver->system_id, smsc->smpp_system_id, 16);
        strncpy(bind_receiver->password, smsc->smpp_password, 9);
        strncpy(bind_receiver->system_type, smsc->smpp_system_type, 13);
        strncpy(bind_receiver->address_range, smsc->smpp_address_range, 41);
        pdu->message_body = bind_receiver;
        fifo_push(smsc->fifo_r_out, pdu);
        
        /* Push a BIND_TRANSMITTER PDU on the [smsc->unsent] stack. */
        pdu = pdu_new();
        if(pdu == NULL) goto error;
        pdu->id = SMPP_BIND_TRANSMITTER;
        smsc->seq_t = 1;
        pdu->sequence_no = 1;
        bind_transmitter = malloc(sizeof(struct smpp_pdu_bind_transmitter));
        if(bind_transmitter==NULL) goto error;
        memset(bind_transmitter, 0, sizeof(struct smpp_pdu_bind_transmitter));
        strncpy(bind_transmitter->system_id, smsc->smpp_system_id, 16);
        strncpy(bind_transmitter->password, smsc->smpp_password, 9);
        strncpy(bind_transmitter->system_type, smsc->smpp_system_type, 13);
        strncpy(bind_transmitter->address_range, smsc->smpp_address_range, 41);
        pdu->message_body = bind_transmitter;
        fifo_push(smsc->fifo_t_out, pdu);
 
        /* Done, return */
        return 1;
 
error:
        error(0, "smpp_reopen: could not open");
 
        pdu_free(pdu);
 
        /* Destroy FIFO stacks. */
        fifo_free(smsc->unsent_mt);
        fifo_free(smsc->sent_mt);
        fifo_free(smsc->delivered_mt);
        fifo_free(smsc->received_mo);
        fifo_free(smsc->fifo_t_in);
        fifo_free(smsc->fifo_t_out);
        fifo_free(smsc->fifo_r_in);
        fifo_free(smsc->fifo_r_out);
 
        /* Destroy buffers */
        data_free(smsc->data_t);
        data_free(smsc->data_r);
 
        smscenter_destruct(smsc);
 
        return -1;
}
 
 
int smpp_close(SMSCenter *smsc) {
 
        struct smpp_pdu *pdu = NULL;
 
        /* Push a UNBIND PDU on the [smsc->fifo_r_out] stack. */
        pdu = pdu_new();
        if(pdu == NULL) goto error;
        pdu->id = SMPP_UNBIND;
        pdu->length = 16;
        pdu->status = 0;
        pdu->sequence_no = 1;
        pdu->message_body = NULL;
        fifo_push(smsc->fifo_r_out, pdu);
        
        /* Push a UNBIND PDU on the [smsc->fifo_t_out] stack. */
        pdu = pdu_new();
        if(pdu == NULL) goto error;
        pdu->id = SMPP_UNBIND;
        pdu->length = 16;
        pdu->status = 0;
        pdu->sequence_no = 1;
        pdu->message_body = NULL;
        fifo_push(smsc->fifo_t_out, pdu);
 
        /* Write out the UNBIND PDUs. */
        smpp_pending_smsmessage(smsc);
 
        /* Wait a while. */
        usleep(100);
 
        /* Check states */
 
#if 0
/*  XXX LATER, WHEN THIS IS IMPLEMENTED IN SMSGATEWAY.C XXX */
        /* If states are BOUND then push UNBIND messages to
           fifostack and return a failure. */
 
        if(smsc->smpp_t_state == 1)
               return 0;
 
        if(smsc->smpp_r_state == 1)
               return 0;
#endif
 
        /* Close transmitter connection. */
        close(smsc->fd_t);
 
        /* Close receiver connection. */
        close(smsc->fd_r);
 
        /* Destroy FIFO stacks. */
        fifo_free(smsc->unsent_mt);
        fifo_free(smsc->sent_mt);
        fifo_free(smsc->delivered_mt);
        fifo_free(smsc->received_mo);
        fifo_free(smsc->fifo_t_in);
        fifo_free(smsc->fifo_t_out);
        fifo_free(smsc->fifo_r_in);
        fifo_free(smsc->fifo_r_out);
 
        /* Destroy buffers */
        data_free(smsc->data_t);
        data_free(smsc->data_r);
 
        return 0;
 
error:
        return -1;
}
 
int smpp_submit_smsmessage(SMSCenter *smsc, SMSMessage *msg) {
 
        struct smpp_pdu *pdu = NULL;
        struct smpp_pdu_submit_sm *submit_sm = NULL;
 
        /* Validate *msg. */
        if(smsc == NULL) goto error;
        if(msg == NULL) goto error;
 
        /* If we cannot really send yet, push message to
           smsc->unsent_mt where it will stay until
           smpp_pdu_act_bind_transmitter_resp is called. */
 
        if( smsc->smpp_t_state != SMPP_STATE_BOUND ) {
               fifo_push_smsmessage(smsc->unsent_mt, msg);
               return 1;
        }
 
        /* Push a SUBMIT_SM PDU on the smsc->fifo_t_out fifostack. */
        pdu = pdu_new();
        if(pdu == NULL) goto error;
        memset(pdu, 0, sizeof(struct smpp_pdu));
 
        submit_sm = malloc(sizeof(struct smpp_pdu_submit_sm));
        if(submit_sm == NULL) goto error;
        memset(submit_sm, 0, sizeof(struct smpp_pdu_submit_sm));
 
        strncpy(submit_sm->source_addr, msg->sender, 21);
        submit_sm->source_addr_npi = GSM_ADDR_NPI_UNKNOWN;
        submit_sm->source_addr_ton = GSM_ADDR_TON_NETWORKSPECIFIC;
 
        /* Notice that the +2 is to get rid of the 00 start. */
        strncat(submit_sm->dest_addr, msg->receiver+2, 21);
        submit_sm->dest_addr_npi = GSM_ADDR_NPI_E164;
        submit_sm->dest_addr_ton = GSM_ADDR_TON_INTERNATIONAL;
 
        submit_sm->data_coding = 3;
 
        submit_sm->sm_length = octstr_len(msg->text);
        octstr_get_many_chars(submit_sm->short_message, msg->text, 0, 160);
        charset_iso_to_smpp(submit_sm->short_message);
 
        pdu->id = SMPP_SUBMIT_SM;
        pdu->status = 0;
        pdu->sequence_no = smsc->seq_t++;
        pdu->message_body = submit_sm;
        pdu->length = 16 + 
               strlen(submit_sm->service_type) + 1 +
               1 + 1 +
               strlen(submit_sm->source_addr) + 1 +
               1 + 1 +
               strlen(submit_sm->dest_addr) + 1 +
               1 + 1 + 1 +
               strlen(submit_sm->schedule_delivery_time) + 1 +
               strlen(submit_sm->validity_period) + 1 +
               1 + 1 + 1 + 1 + 1 +
               strlen(submit_sm->short_message) + 1;
 
        fifo_push(smsc->fifo_t_out, pdu);
 
        return 0;
 
error:
        return -1;
}
 
 
int smpp_receive_smsmessage(SMSCenter *smsc, SMSMessage **msg) {
 
        SMSMessage *newmsg = NULL;
        char *newnum = NULL;
 
        /* Pop a SMSMessage message from the MSG_MO stack. */
        if( fifo_pop_smsmessage(smsc->received_mo, &newmsg) == 1 ) {
 
               /* Change the number format on msg->sender. */
               newnum = malloc(strlen(newmsg->sender)+3);
               if(newnum==NULL) goto error;
               memset(newnum, 0, strlen(newmsg->sender)+3);
               strcpy(newnum, "00");
               strcat(newnum, newmsg->sender);
               free(newmsg->sender);
               newmsg->sender = newnum;
 
               *msg = newmsg;
 
               return 1;
        }
        
        return 0;
error:
        error(errno, "smpp_receive_smsmessage: error");
        return -1;
}
 
int smpp_pending_smsmessage(SMSCenter *smsc) {
 
        Octstr *data = NULL;
        smpp_pdu *pdu = NULL;
        int ret = 0, funcret = 0;
 
        /* Process the MT messages. */
 
        /* Send whatever we need to send */
        while( fifo_pop(smsc->fifo_t_out, &pdu) == 1 ) {
               /* Encode the PDU to raw data. */
               if( pdu_encode(pdu, &data) == 1 ) {
                       /* Send the PDU data. */
                       ret = data_send(smsc->fd_t, data);
                       data_free(data);
                       if(ret==-1) break;
               }
               pdu_free(pdu);
               if(ret==-1) break;
        }
 
        /* Receive raw data */
        ret = data_receive(smsc->fd_t, smsc->data_t);
        if(ret == -1) {
               warning(0, "smpp_pending_smsmessage: reopening connections");
               smpp_reopen(smsc);
        }
 
        /* Interpret the raw data */
        while( data_pop(smsc->data_t, &data) == 1 ) { 
               /* Decode the PDU from raw data. */
               if( (ret = pdu_decode(&pdu, data)) ) {
                       /* Act on PDU. */
                       pdu->fd = smsc->fd_t;
                       ret = pdu_act(smsc, pdu);
                       pdu_free(pdu);
               }
               data_free(data);
        }
 
        /* Process the MO messages. */
 
        ret = data_receive(smsc->fd_r, smsc->data_r);
        if(ret == -1) {
               warning(0, "smpp_pending_smsmessage: reopening connections");
               smpp_reopen(smsc);
        }
 
        while( fifo_pop(smsc->fifo_r_out, &pdu) == 1 ) {
               /* Encode the PDU to raw data. */
               if( (ret = pdu_encode(pdu, &data)) ) {
                       /* Send the PDU data. */
                       ret = data_send(smsc->fd_r, data);
                       data_free(data);
                       if(ret==-1) break;
               }
               pdu_free(pdu);
               if(ret==-1) break;
        }
 
        while( data_pop(smsc->data_r, &data) == 1 ) {
               /* Decode the PDU from raw data. */
               if( (ret = pdu_decode(&pdu, data)) ) {
                       /* Act on PDU. */
                       pdu->fd = smsc->fd_r;
                       ret = pdu_act(smsc, pdu);
                       pdu_free(pdu);
               }
               data_free(data);
        }
 
        /* Signal that we got a MO message */
        if(smsc->received_mo->left != NULL) funcret = 1;
 
        /* If it's been a "long time" (defined elsewhere) since
           the last message, actively check the link status by
           sending a LINK_STATUS pdu to the SMSC, thereby 
           (maybe) resetting the close-if-no-traffic timer.
           Note: in practise we won't need this. */
 
        /* XXX DO IT */
 
        return funcret;
}
 
static smpp_pdu* pdu_new(void) {
 
        struct smpp_pdu *newpdu = NULL;
 
        newpdu = malloc(sizeof(struct smpp_pdu));
        memset(newpdu, 0, sizeof(struct smpp_pdu));
 
        return newpdu;
}
 
static int pdu_free(smpp_pdu *pdu) {
 
        if(pdu == NULL) return 0;
 
        smsmessage_destruct(pdu->smsmsg);
        free(pdu->message_body);
        free(pdu);
 
        return 1;
}
 
static Octstr* data_new(void) {
 
        struct Octstr *newstr = NULL;
 
        newstr = octstr_create_empty();
 
        return newstr;
}
 
static int data_free(Octstr *str) {
 
        if(str == NULL) return 0;
 
        octstr_destroy(str);
 
        return 1;
}
 
static fifostack* fifo_new(void) {
 
        struct fifostack *newfifo = NULL;
 
        newfifo = malloc(sizeof(struct fifostack));
        if(newfifo == NULL) goto error;
        memset(newfifo, 0, sizeof(struct fifostack));
 
        return newfifo;
 
error:
        error(0, "fifo_new: memory allocation error");
        return NULL;
}
 
static void fifo_free(fifostack *fifo) {
 
        struct smpp_pdu *pdu = NULL;
 
        if(fifo == NULL) return;
 
        /* Drain the leftover PDUs to the bit sink. */
        while( fifo_pop(fifo, &pdu) == 1 )  {
               pdu_free(pdu);
               pdu = NULL;
        }
 
        free(fifo);
 
        return;
}
 
static int fifo_push(fifostack *fifo, smpp_pdu *pdu) {
 
        if(fifo == NULL) {
               error(0, "fifo_push: NULL input");
               goto error;
        }
 
        if(pdu == NULL) {
               error(0, "fifo_push: NULL input");
               goto error;
        }
 
        /* If fifostack is completely empty. */
        if( (fifo->left == NULL) && (fifo->right == NULL) ) {
               fifo->left = pdu;
               fifo->right = pdu;
               pdu->left = NULL;
               pdu->right = NULL;
               goto a_ok;
        }
 
        /* Ok, insert the pdu on the left side. */
        pdu->left = NULL;
        (fifo->left)->left = pdu;
        fifo->left = pdu;
 
a_ok:
        return 1;
error:
        error(0, "fifo_push: error");
        return -1;
 
}
 
static int fifo_pop(fifostack *fifo, smpp_pdu **pdu) {
 
        if(fifo == NULL) {
               error(0, "fifo_pop: NULL input");
               goto error;
        }
 
        if(pdu == NULL) {
               error(0, "fifo_pop: NULL input");
               goto error;
        }
 
        /* If fifostack is completely empty. */
        if( (fifo->left == NULL) && (fifo->right == NULL) ) {
               goto no_msgs;
        }
 
        /* Drop a message from the right side. */
        *pdu = fifo->right;
 
        /* If this was the last PDU and the fifostack is now empty. */
        if(fifo->right->left == NULL) {
               fifo->right = NULL;
               fifo->left = NULL;
        } else {
               /* Set the new right edge. */
               fifo->right = (fifo->right)->left;
               /* Terminate. */
               (fifo->right)->right = NULL;
        }
 
        return 1;
 
no_msgs:
        return 0;
 
error:
        error(0, "fifo_pop: returing error");
        return -1;
}
 
static int fifo_push_smsmessage(fifostack *fifo, SMSMessage *msg) {
 
        struct smpp_pdu *pdu = NULL;
 
        pdu = pdu_new();
        if(pdu == NULL) goto error;
        memset(pdu, 0, sizeof(struct smpp_pdu));
        
        pdu->smsmsg = msg;
        fifo_push(fifo, pdu);
 
        return 1;
 
error:
        error(0, "fifo_push_smsmessage: returning error");
        return -1;
}
 
static int fifo_pop_smsmessage(fifostack *fifo, SMSMessage **msg) {
 
        struct smpp_pdu *pdu = NULL;
        int ret;
 
        ret = fifo_pop(fifo, &pdu);
        if(ret == 0) goto no_msg;
        if(ret <>
 
        *msg = pdu->smsmsg;
        if(*msg == NULL) goto error;
 
        pdu->smsmsg = NULL;
        pdu_free(pdu);
 
        return 1;
 
no_msg:
        return 0;
 
error:
        error(0, "fifo_pop_smsmessage: returning error");
        return -1;
}
 
 
/******************************************************************************
* data_pop
*
*  from: The Octstr to cut from
*  to: The Octstr to create and paste to
*
* Description:
*  
* Returns:
*  1 if a PDU was found
*  0 if no PDU found
* -1 if an error occurred
*
*/
static int data_pop(Octstr *from, Octstr **to) {
 
        int32 quadoct;
        int32 realint;
        unsigned int olen = 0;
 
        olen = octstr_len(from);
 
        /* Check if [from] has enough data to contain a PDU (>=16 octets) */
        if(olen <>
 
        /* Read the length (4 first octets) */
        octstr_get_many_chars((char*)&quadoct, from, 0, 4);
 
        /* Translate the length XXX MAKE THIS INTO 1 FUNCTION */
        realint = ntohl(quadoct);
 
        /* Check if we have [length] octets of data */
        if(olen <>
 
        /* Cut the PDU out, move data to fill the hole. */
        *to = octstr_copy(from, 0, realint);
        if(*to == NULL) goto error;
        octstr_delete(from, 0, realint);
 
        /* Okay, done */
        return 1;
 
no_msg:
        *to = NULL;
        return -1;
 
error:
        error(0, "data_pop: ERROR!!!");
        *to = NULL;
        return -1;
}
 
/******************************************************************************
* data_receive
*
*  fd: the File Descriptor to read from
*  to: The Octstr to append to
*
* Description:
*  Receive data from [fd] and append it to [to].
*  
* Returns:
*  1 if a PDU was found
*  0 if no PDU found
* -1 if an error occurred
*
*/
static int data_receive(int fd, Octstr *to) {
 
        size_t length;
        char   data[1024];
        Octstr *newstr = NULL;
 
        fd_set rf;
        struct timeval tox;
        int ret;
 
        memset(&data, 0, sizeof(data));
 
        FD_ZERO(&rf);
        FD_SET(fd, &rf);
        tox.tv_sec = 0;
        tox.tv_usec = 100;
        ret = select(FD_SETSIZE, &rf, NULL, NULL, &tox);
 
        if (ret == 0) {
               goto no_data;
        } else if (ret <>
               if(errno == EBADF) {
                       error(errno, "data_receive: select failed");
               }
               goto error;
        }
 
        /* Create temp data structures. */
        length = read(fd, &data, sizeof(data)-1);
 
        if(length == -1) {
/*             if(errno==EWOULDBLOCK) return -1; */
               goto error;
        } else if(length == 0) {
               debug(0, "soketti <%i> kloused", fd);
               goto error;
        }
 
        newstr = octstr_create_from_data(data, length);
        
        if(newstr == NULL) goto error;
        octstr_insert(to, newstr, octstr_len(to));
 
        /* Okay, done */
        return 1;
 
no_data:
        return 0;
 
error:
        debug(0, "data_receive: error");
        return -1;
}
 
/******************************************************************************
* data_send
*
*  fd: the File Descriptor to write to
*  to: The Octstr to get the data from
*
* Description:
*  Write all the data from [from] to [fd].
*  
* Returns:
*  1 if a PDU was found
*  0 if no PDU found
* -1 if an error occurred
*
*/
static int data_send(int fd, Octstr *from) {
 
        size_t length, curl, written = 0;
        char *willy = NULL;
 
        debug(0, "data_send: starting");
 
        /* Create temp data structures. */
        length = octstr_len(from);
        if(length <= 0) return 0;
 
        willy = malloc(length);
        if(willy == NULL) goto error;
 
        octstr_get_many_chars(willy, from, 0, length);
 
        /* Write to socket */
        for(;;) {
               if(written >= length) break;
               curl = write(fd, willy+written, length-written);
               if(curl == -1) {
                       if(errno==EAGAIN) continue;
                       if(errno==EINTR) continue;
                       if(errno==EBADF) {
                               error(errno, "data_send: write(2) failed");
                       }
                       goto error;
               } else if(curl == 0) {
                       goto socket_b0rken;
               }
               written += curl;
        }
 
        /* Okay, done */
        free(willy);
        return 1;
 
socket_b0rken:
        debug(0, "data_send: broken socket!!!");
        free(willy);
        return -1;
 
error:
        debug(0, "data_send: ERROR!!!");
        free(willy);
        return -1;
}
 
/* Append a single octet of data. Update where to reflect the
   next byte to write to, decrease left by the number of
   bytes written. */
static int smpp_append_oct(char** where, int* left, uint32_t data) {
 
/* Change this to reflect differences in endianness and
   bytenesses. */
#if BYTE_ORDER == LITTLE_ENDIAN
        memcpy(*where, &data, 1);
        *where += 1;
#elif BYTE_ORDER == BIG_ENDIAN
        memcpy(*where, (&data)+3, 1);
        *where += 1;
#else
        /* We have to write another section here for PDPs :) */
        error(0, "smpp_append_oct: wrong endianness.");
#endif
 
        return 1;
}
 
static int smpp_read_oct(char** where, int* left, Octet* data) {
        return -1;
        smpp_read_oct(where, left, data);
}
 
static int smpp_append_cstr(char** where, int* left, char* data) {
 
        memcpy(*where, data, strlen(data)+1);
        *where += (strlen(data) + 1);
 
        return 1;
}
 
static int smpp_read_cstr(char** where, int* left, char** data) {
        return -1;
        smpp_read_cstr(where, left, data);
}
 
static int smpp_append_int32(char** where, int* left, int32 data) {
        return -1;
        smpp_append_int32(where, left, data);
}
 
static int smpp_read_int32(char** where, int* left, int32* data) {
        return -1;
        smpp_read_int32(where, left, data);
}
 
 
/******************************************************************************
* pdu_act
*
*  Decide what to do with a PDU once we have managed to obtain one.
*
* Refer to:
*  SMPP 3.3 specification section 5.5.2
*
* Returns:
*  1 if a PDU was found
*  0 if no PDU found
* -1 if an error occurred
*
*/
static int pdu_act(SMSCenter *smsc, smpp_pdu *pdu) {
 
        int ret = -1;
 
        switch(pdu->id) {
 
        case SMPP_BIND_RECEIVER_RESP:
               ret = pdu_act_bind_receiver_resp(smsc, pdu);
               break;
 
        case SMPP_BIND_TRANSMITTER_RESP:
               ret = pdu_act_bind_transmitter_resp(smsc, pdu);
               break;
 
        case SMPP_UNBIND_RESP:
               ret = pdu_act_unbind_resp(smsc, pdu);
               break;
 
        case SMPP_SUBMIT_SM_RESP:
               ret = pdu_act_submit_sm_resp(smsc, pdu);
               break;
 
        case SMPP_SUBMIT_MULTI_RESP:
               ret = pdu_act_submit_multi_resp(smsc, pdu);
               break;
 
        case SMPP_DELIVER_SM:
               ret = pdu_act_deliver_sm(smsc, pdu);
               break;
 
        case SMPP_QUERY_SM_RESP:
               ret = pdu_act_query_sm_resp(smsc, pdu);
               break;
 
        case SMPP_CANCEL_SM_RESP:
               ret = pdu_act_cancel_sm_resp(smsc, pdu);
               break;
 
        case SMPP_REPLACE_SM_RESP:
               ret = pdu_act_replace_sm_resp(smsc, pdu);
               break;
 
        case SMPP_ENQUIRE_LINK:
               ret = pdu_act_enquire_link(smsc, pdu);
               break;
 
        case SMPP_ENQUIRE_LINK_RESP:
               ret = pdu_act_enquire_link_resp(smsc, pdu);
               break;
 
        case SMPP_GENERIC_NAK:
               ret = pdu_act_generic_nak(smsc, pdu);
               break;
 
/*      case SMPP_QUERY_LAST_MSGS_RESP:
               ret = pdu_act_query_last_msgs_resp(smsc, pdu);
               break;
 
        case SMPP_QUERY_MSG_DETAILS_RESP:
               ret = pdu_act_query_msg_details_resp(smsc, pdu);
               break;
*/
        }
 
        return ret;
}
 
 
/******************************************************************************
* pdu_decode
*
* Description:
*  Decode given raw data into a brand new SMPP PDU.
*
* Returns:
*  1 if a PDU was created
*  0 if no PDU could be created
* -1 if an error occurred
*
*/
static int pdu_decode(smpp_pdu **pdu, Octstr *from) {
 
        int ret;
        struct smpp_pdu *newpdu;
 
        newpdu = pdu_new();
 
        /* Decode the header */
        ret = pdu_header_decode(newpdu, from);
 
        switch(newpdu->id) {
        
        case SMPP_BIND_RECEIVER_RESP:
               ret = pdu_decode_bind(newpdu, from);
               break;
 
        case SMPP_BIND_TRANSMITTER_RESP:
               ret = pdu_decode_bind(newpdu, from);
               break;
 
        case SMPP_UNBIND_RESP:
               ret = pdu_decode_bind(newpdu, from);
               break;
 
        case SMPP_DELIVER_SM:
               ret = pdu_decode_deliver_sm(newpdu, from);
               break;
 
        case SMPP_SUBMIT_SM_RESP:
               ret = pdu_decode_submit_sm_resp(newpdu, from);
               break;
#if 0
 
        case SMPP_SUBMIT_MULTI_RESP:
               ret = pdu_decode_submit_multi_resp(smsc, pdu);
               break;
 
        case SMPP_QUERY_SM_RESP:
               ret = pdu_decode_query_sm_resp(smsc, pdu);
               break;
 
/*
        case SMPP_QUERY_LAST_MSGS_RESP:
               ret = pdu_decode_query_last_msgs_resp(smsc, pdu);
               break;
 
        case SMPP_QUERY_MSG_DETAILS_RESP:
               ret = pdu_decode_query_msg_details_resp(smsc, pdu);
               break;
*/
 
        case SMPP_CANCEL_SM_RESP:
               ret = pdu_decode_cancel_sm_resp(smsc, pdu);
               break;
 
        case SMPP_REPLACE_SM_RESP:
               ret = pdu_decode_replace_sm_resp(smsc, pdu);
               break;
 
        case SMPP_ENQUIRE_LINK:
               ret = pdu_decode_enquire_link(smsc, pdu);
               break;
 
        case SMPP_ENQUIRE_LINK_RESP:
               ret = pdu_decode_enquire_link_resp(smsc, pdu);
               break;
 
        case SMPP_GENERIC_NAK:
               ret = pdu_decode_generic_nak(smsc, pdu);
               break;
#endif
        }
 
        *pdu = newpdu;
 
        return 1;
 
}
 
/******************************************************************************
* pdu_encode
*
* Description:
*  Encode a given SMPP PDU structure to raw data.
*
* Returns:
*  1 if PDU was translated to raw data
*  0 if PDU couldn't be translated
* -1 if an error occurred
*
*/
static int pdu_encode(smpp_pdu *pdu, Octstr **rawdata) {
 
        struct Octstr *body = NULL, *header = NULL, *whole = NULL;
        int ret;
 
        switch(pdu->id) {
 
        case SMPP_BIND_RECEIVER:
               ret = pdu_encode_bind(pdu, &body);
               break;
 
        case SMPP_BIND_RECEIVER_RESP:
               ret = pdu_encode_bind(pdu, &body);
               break;
 
        case SMPP_BIND_TRANSMITTER:
               ret = pdu_encode_bind(pdu, &body);
               break;
 
        case SMPP_BIND_TRANSMITTER_RESP:
               ret = pdu_encode_bind(pdu, &body);
               break;
 
        case SMPP_UNBIND_RESP:
               ret = pdu_encode_bind(pdu, &body);
               break;
 
        case SMPP_DELIVER_SM_RESP:
               ret = pdu_encode_deliver_sm_resp(pdu, &body);
               break;
 
        case SMPP_SUBMIT_SM:
               ret = pdu_encode_submit_sm(pdu, &body);
               break;
 
#if 0
        case SMPP_SUBMIT_MULTI:
               ret = pdu_encode_submit_multi(pdu, &body);
               break;
 
        case SMPP_QUERY_SM:
               ret = pdu_encode_query_sm(pdu, &body);
               break;
 
/*
        case SMPP_QUERY_LAST_MSGS:
               ret = pdu_encode_query_last_msgs(pdu, &body);
               break;
 
        case SMPP_QUERY_MSG_DETAILS:
               ret = pdu_encode_query_msg_details(pdu, &body);
               break;
*/
 
        case SMPP_CANCEL_SM:
               ret = pdu_encode_cancel_sm(pdu, &body);
               break;
 
        case SMPP_REPLACE_SM:
               ret = pdu_encode_replace_sm(pdu, &body);
               break;
 
        case SMPP_ENQUIRE_LINK:
               ret = pdu_encode_enquire_link(pdu, &body);
               break;
 
        case SMPP_ENQUIRE_LINK_RESP:
               ret = pdu_encode_enquire_link_resp(pdu, &body);
               break;
 
        case SMPP_GENERIC_NAK:
               ret = pdu_encode_generic_nak(pdu, &body);
               break;
#endif
 
        }
 
        pdu_header_encode(pdu, &header);
 
        whole = octstr_cat(header, body);
 
        octstr_destroy(header);
        octstr_destroy(body);
 
        *rawdata = whole;
 
        return 1;
}
 
 
static int pdu_header_decode(smpp_pdu *pdu, Octstr *str) {
 
        uint32_t header[4];
 
        if(pdu == NULL) goto error;
        if(str == NULL) goto error;
 
        /* Read the header */
        octstr_get_many_chars((char*)&header, str, 0, sizeof(header));
 
        pdu->length = ntohl(header[0]);
        pdu->id     = ntohl(header[1]);
        pdu->status = ntohl(header[2]);
        pdu->sequence_no = ntohl(header[3]);
 
        return 1;
 
error:
        return -1;
}
 
static int pdu_header_encode(smpp_pdu *pdu, Octstr **rawdata) {
 
        uint32_t length, id, status, seq;
 
        Octstr *newdata = NULL;
        char temp[16], *tempptr;
 
        memset(temp, 0, sizeof(temp));
 
        tempptr = temp;
 
        length = htonl(pdu->length);
        id     = htonl(pdu->id);
        status = htonl(pdu->status);
        seq    = htonl(pdu->sequence_no);
 
        memcpy(tempptr, &length, 4);
        tempptr += 4;
        
        memcpy(tempptr, &id, 4);
        tempptr += 4;
 
        memcpy(tempptr, &status, 4);
        tempptr += 4;
 
        memcpy(tempptr, &seq, 4);
        tempptr += 4;
 
        newdata = octstr_create_from_data(temp, sizeof(temp));
 
        *rawdata = newdata;
 
        return 1;
}
 
static int pdu_decode_bind(smpp_pdu *pdu, Octstr *str) {
 
        return 1;
}
 
static int pdu_encode_bind(smpp_pdu *pdu, Octstr **str) {
 
        int length = 0;
        char *data = NULL, *where = NULL;
        Octstr *body_encoded;
        int left;
        
        struct smpp_pdu_bind_receiver *bind_receiver;
        struct smpp_pdu_bind_receiver_resp *bind_receiver_resp;
        struct smpp_pdu_bind_transmitter *bind_transmitter;
        struct smpp_pdu_bind_transmitter_resp *bind_transmitter_resp;
 
        switch(pdu->id) {
 
        case SMPP_BIND_RECEIVER:
               bind_receiver = (smpp_pdu_bind_receiver*) pdu->message_body;
               length = strlen(bind_receiver->system_id) + 1 +
                        strlen(bind_receiver->password) + 1 +
                        strlen(bind_receiver->system_type) + 1 +
                        1 + 1 + 1 +
                        strlen(bind_receiver->address_range) + 1;
               data = malloc(length);
               if(data == NULL) goto error;
               memset(data, 0, length);
               where = data;
 
               smpp_append_cstr(&where, &left, bind_receiver->system_id);
               smpp_append_cstr(&where, &left, bind_receiver->password);
               smpp_append_cstr(&where, &left, bind_receiver->system_type);
               smpp_append_oct(&where, &left, bind_receiver->interface_version);
               smpp_append_oct(&where, &left, bind_receiver->addr_ton);
               smpp_append_oct(&where, &left, bind_receiver->addr_npi);
               smpp_append_cstr(&where, &left, bind_receiver->address_range);
 
               break;
 
        case SMPP_BIND_RECEIVER_RESP:
               length = strlen(bind_receiver_resp->system_id) + 1;
               data = malloc(length);
               if(data == NULL) goto error;
               memset(data, 0, length);
               where = data;
 
               smpp_append_cstr(&where, &left, bind_receiver_resp->system_id);
 
               break;
 
        case SMPP_BIND_TRANSMITTER:
               bind_transmitter = (smpp_pdu_bind_transmitter*) pdu->message_body;
               length = strlen(bind_transmitter->system_id) + 1 +
                        strlen(bind_transmitter->password) + 1 +
                        strlen(bind_transmitter->system_type) + 1 +
                        1 + 1 + 1 +
                        strlen(bind_transmitter->address_range) + 1;
 
               data = malloc(length);
               if(data == NULL) goto error;
               memset(data, 0, length);
               where = data;
 
               smpp_append_cstr(&where, &left, bind_transmitter->system_id);
               smpp_append_cstr(&where, &left, bind_transmitter->password);
               smpp_append_cstr(&where, &left, bind_transmitter->system_type);
               smpp_append_oct(&where, &left, bind_transmitter->interface_version);
               smpp_append_oct(&where, &left, bind_transmitter->addr_ton);
               smpp_append_oct(&where, &left, bind_transmitter->addr_npi);
                smpp_append_cstr(&where, &left, bind_transmitter->address_range);
 
               break;
 
        case SMPP_BIND_TRANSMITTER_RESP:
               bind_transmitter_resp = (smpp_pdu_bind_transmitter_resp*) pdu->message_body;
               length = strlen(bind_transmitter_resp->system_id) + 1;
               data = malloc(length);
               if(data == NULL) goto error;
 
               smpp_append_cstr(&where, &left, bind_transmitter_resp->system_id);
 
               break;
 
        case SMPP_UNBIND:
               data = NULL;
               length = 0;
               break;
 
        case SMPP_UNBIND_RESP:
               data = NULL;
               length = 0;
               break;
 
        }
 
        pdu->length = length + 16;
 
        body_encoded = octstr_create_from_data(data, length);
 
        *str = body_encoded;
 
        free(data);
 
        return 1;
error:
        return -1;
}
 
/******************************************************************************
* PDUs
*  BIND_TRANSMITTER, BIND_TRANSMITTER_RESP
*/
static int pdu_act_bind_transmitter_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
        struct smpp_pdu *newpdu = NULL;
        struct smpp_pdu_submit_sm *submit_sm = NULL;
        SMSMessage *msg = NULL;
 
        /* Validate *msg. */
        if(smsc == NULL) goto error;
        if(pdu == NULL) goto error;
 
        smsc->smpp_t_state = SMPP_STATE_BOUND;
 
        /* Process any messages that were sent through the HTTP
           interface while the transmitter connection was not
           bound. */
        while( fifo_pop_smsmessage(smsc->unsent_mt, &msg) == 1 ) {
 
               /* Push a SUBMIT_SM PDU on the smsc->fifo_t_out fifostack. */
               newpdu = pdu_new();
               if(newpdu == NULL) goto error;
               memset(newpdu, 0, sizeof(struct smpp_pdu));
 
               submit_sm = malloc(sizeof(struct smpp_pdu_submit_sm));
               if(submit_sm == NULL) goto error;
               memset(submit_sm, 0, sizeof(struct smpp_pdu_submit_sm));
 
               strncpy(submit_sm->source_addr, msg->sender, 21);
               submit_sm->source_addr_npi = GSM_ADDR_NPI_UNKNOWN;
               submit_sm->source_addr_ton = GSM_ADDR_TON_NETWORKSPECIFIC;
 
               /* Notice that the +2 is to get rid of the 00 start. */
               strncat(submit_sm->dest_addr, msg->receiver+2, 21);
               submit_sm->dest_addr_npi = GSM_ADDR_NPI_E164;
               submit_sm->dest_addr_ton = GSM_ADDR_TON_INTERNATIONAL;
 
               submit_sm->data_coding = 3;
 
               submit_sm->sm_length = octstr_len(msg->text);
               octstr_get_many_chars(submit_sm->short_message, msg->text, 0, 160);
               charset_iso_to_smpp(submit_sm->short_message);
 
               newpdu->id = SMPP_SUBMIT_SM;
               newpdu->status = 0;
               newpdu->sequence_no = smsc->seq_t++;
               newpdu->message_body = submit_sm;
               newpdu->length = 16 + 
                       strlen(submit_sm->service_type) + 1 +
                       1 + 1 +
                       strlen(submit_sm->source_addr) + 1 +
                       1 + 1 +
                       strlen(submit_sm->dest_addr) + 1 +
                       1 + 1 + 1 +
                       strlen(submit_sm->schedule_delivery_time) + 1 +
                       strlen(submit_sm->validity_period) + 1 +
                       1 + 1 + 1 + 1 + 1 +
                       strlen(submit_sm->short_message) + 1;
 
               fifo_push(smsc->fifo_t_out, newpdu);
 
        }
 
        return 0;
 
error:
        return -1;
}
 
/******************************************************************************
* PDUs
*  BIND_RECEIVER, BIND_RECEIVER_RESP
*/
static int pdu_act_bind_receiver_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
        smsc->smpp_r_state = SMPP_STATE_BOUND;
 
        return 1;
}
 
/******************************************************************************
* PDUs
*  UNBIND, UNBIND_RESP
*/
static int pdu_act_unbind_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
/*      debug(0, "pdu_act_unbind_resp: start"); */
 
        /* Remove the status flag CAN_RECEIVE or CAN_SEND */
 
        return -1;
}
 
/******************************************************************************
* PDUs
*  SUBMIT_SM, SUBMIT_SM_RESP
*/
static int pdu_act_submit_sm_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
        debug(0, "pdu_act_submit_sm_resp: start");
 
        /* Mark message the SUBMIT_SM_RESP refers to as 
           acknowledged and remove it from smsc->smpp_fifostack. */
 
        debug(0, "pdu->length == %08x", pdu->length);
        debug(0, "pdu->id == %08x", pdu->id);
        debug(0, "pdu->status == %08x", pdu->status);
        debug(0, "pdu->sequence_no == %08x", pdu->sequence_no);
 
        return -1;
}
 
static int pdu_encode_submit_sm(smpp_pdu* pdu, Octstr** str) {
 
        struct smpp_pdu_submit_sm *submit_sm = NULL;
 
        int32 length;
        int left;
        char *data = NULL, *where = NULL;
        Octstr *newstr = NULL;
 
        submit_sm = (struct smpp_pdu_submit_sm*) pdu->message_body;
 
        length = strlen(submit_sm->service_type) + 1 +
                1 + 1 +
                strlen(submit_sm->source_addr) + 1 +
                1 + 1 +
                strlen(submit_sm->dest_addr) + 1 +
                1 + 1 + 1 +
                strlen(submit_sm->schedule_delivery_time) + 1 +
                strlen(submit_sm->validity_period) + 1 +
                1 + 1 + 1 + 1 + 1 +
                strlen(submit_sm->short_message) + 1;
 
        data = malloc(length);
        if(data == NULL) goto error;
        memset(data, 0, length);
        where = data;
 
        smpp_append_cstr(&where, &left, submit_sm->service_type);
        smpp_append_oct(&where, &left, submit_sm->source_addr_ton);
        smpp_append_oct(&where, &left, submit_sm->source_addr_npi);
        smpp_append_cstr(&where, &left, submit_sm->source_addr);
        smpp_append_oct(&where, &left, submit_sm->dest_addr_ton);
        smpp_append_oct(&where, &left, submit_sm->dest_addr_npi);
        smpp_append_cstr(&where, &left, submit_sm->dest_addr);
        smpp_append_oct(&where, &left, submit_sm->esm_class);
        smpp_append_oct(&where, &left, submit_sm->protocol_id);
        smpp_append_oct(&where, &left, submit_sm->priority_flag);
        smpp_append_cstr(&where, &left, submit_sm->schedule_delivery_time);
        smpp_append_cstr(&where, &left, submit_sm->validity_period);
        smpp_append_oct(&where, &left, submit_sm->registered_delivery_flag);
        smpp_append_oct(&where, &left, submit_sm->replace_if_present_flag);
        smpp_append_oct(&where, &left, submit_sm->data_coding);
        smpp_append_oct(&where, &left, submit_sm->sm_default_msg_id);
        smpp_append_oct(&where, &left, submit_sm->sm_length);
        smpp_append_cstr(&where, &left, submit_sm->short_message);
 
        newstr = octstr_create_from_data(data, length);
 
        *str = newstr;
 
        return 1;
error:
        return -1;
}
 
static int pdu_decode_submit_sm_resp(smpp_pdu* pdu, Octstr* str) {
        return -1;
}
 
 
 
/******************************************************************************
* PDUs
*  SUBMIT_MULTI, SUBMIT_SM_MULTI_RESP
*/
static int pdu_act_submit_multi_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
        debug(0, "pdu_act_submit_multi_resp: start");
 
        /* Mark messages reffer to by the SUBMIT_MULTI_RESP as
           acknowledged and remove them from smsc->fifostack. */
 
        return -1;
}
 
/******************************************************************************
* PDUs
*  DELIVER_SM, DELIVER_SM_RESP
*/
static int pdu_act_deliver_sm(SMSCenter *smsc, smpp_pdu *pdu) {
 
        struct smpp_pdu *newpdu = NULL;
        struct smpp_pdu_deliver_sm *deliver_sm = NULL;
        struct smpp_pdu_deliver_sm_resp *deliver_sm_resp = NULL;
 
        SMSMessage *smsmsg = NULL;
 
        /* If DELIVER_SM was sent to acknowledge that the terminal
           has received the message, ignore. */
        deliver_sm = (struct smpp_pdu_deliver_sm*) pdu->message_body;
        if(deliver_sm==NULL) goto error;
 
        /* Convert message from the Default Charset to ISO-8859-1. */
        charset_smpp_to_iso(deliver_sm->short_message);
 
        /* Convert the PDU into a SMSMessage structure. */
        smsmsg = smsmessage_construct(
               deliver_sm->source_addr, 
               deliver_sm->dest_addr,
               octstr_create(deliver_sm->short_message));
 
        /* Push the SMSMessage structure on the smsc->received_mo fifostack. */
        fifo_push_smsmessage(smsc->received_mo, smsmsg);
 
        /* Push a DELIVER_SM_RESP structure on the smsc->fifo_r_out fifostack. */
        newpdu = pdu_new();
        if(newpdu == NULL) goto error;
        memset(newpdu, 0, sizeof(struct smpp_pdu));
 
        deliver_sm_resp = malloc(sizeof(struct smpp_pdu_deliver_sm_resp));
        if(deliver_sm_resp == NULL) goto error;
        memset(deliver_sm_resp, 0, sizeof(struct smpp_pdu_deliver_sm_resp));
 
        newpdu->length = 17;
        newpdu->id = SMPP_DELIVER_SM_RESP;
        newpdu->status = 0;
        newpdu->sequence_no = pdu->sequence_no;
        newpdu->message_body = deliver_sm_resp;
 
        fifo_push(smsc->fifo_r_out, newpdu);
 
        return 1;
 
error:
        return -1;
}
 
static int pdu_encode_deliver_sm_resp(smpp_pdu *pdu, Octstr **str) {
 
        Octstr *newstr = NULL;
        struct smpp_pdu_deliver_sm_resp *deliver_sm_resp = NULL;
        char data;
 
        deliver_sm_resp = (struct smpp_pdu_deliver_sm_resp*) pdu->message_body;
 
        /* As specified in SMPP 3.3 / 6.3.3.2 */
        data = '\0';
 
        newstr = octstr_create_from_data(&data, 1);
 
        *str = newstr;
 
        return 1;
}
 
static int pdu_decode_deliver_sm(smpp_pdu* pdu, Octstr* str) {
 
        char *start, *end, *buff;
        struct smpp_pdu_deliver_sm *deliver_sm;
        Octet oct;
 
        if(pdu==NULL) goto error;
        if(str==NULL) goto error;
 
        if(octstr_len(str) <>
               warning(0, "pdu_decode_deliver_sm: incorrect input");
               goto error;
        }
 
        deliver_sm = malloc(sizeof(struct smpp_pdu_deliver_sm));
        if(deliver_sm==NULL) goto error;
        memset(deliver_sm, 0, sizeof(struct smpp_pdu_deliver_sm));
        pdu->message_body = deliver_sm;
 
        buff = malloc(octstr_len(str));
        if(buff == NULL) goto error;
 
        octstr_get_many_chars(buff, str, 0, octstr_len(str));
        start = buff + 16;
 
        end = start + strlen(start);
        strncpy(deliver_sm->service_type, start, 6);
        start = end+1;
 
        strncpy(&oct, start, 1);
        deliver_sm->source_addr_ton = oct;
        start++;
 
        strncpy(&oct, start, 1);
        deliver_sm->source_addr_npi = oct;
        start++;
 
        end = start + strlen(start);
        strncpy(deliver_sm->source_addr, start, 21);
        start = end+1;
 
        strncpy(&oct, start, 1);
        deliver_sm->dest_addr_ton = oct;
        start++;
 
        strncpy(&oct, start, 1);
        deliver_sm->dest_addr_npi = oct;
        start++;
 
        end = start + strlen(start);
        strncpy(deliver_sm->dest_addr, start, 21);
        start = end+1;
 
        strncpy(&oct, start, 1);
        deliver_sm->esm_class = oct;
        start++;
 
        strncpy(&oct, start, 1);
        deliver_sm->protocol_id = oct;
        start++;
 
        strncpy(&oct, start, 1);
        deliver_sm->priority_flag = oct;
        start++;
 
        end = start + strlen(start);
        strncpy(deliver_sm->schedule_delivery_time, start, 17);
        start = end+1;
 
        end = start + strlen(start);
        strncpy(deliver_sm->validity_period, start, 17);
        start = end+1;
 
        strncpy(&oct, start, 1);
        deliver_sm->registered_delivery_flag = oct;
        start++;
 
        strncpy(&oct, start, 1);
        deliver_sm->replace_if_present_flag = oct;
        start++;
 
        strncpy(&oct, start, 1);
        deliver_sm->data_coding = oct;
        start++;
 
        strncpy(&oct, start, 1);
        deliver_sm->sm_default_msg_id = oct;
        start++;
 
        strncpy(&oct, start, 1);
        deliver_sm->sm_length = oct;
        start++;
 
        /* Make sure that the upcoming SMPP 3.4 implementation
           won't break our application with the new definition
           of max short_message size. */
        end = start + strlen(start);
        strncpy(deliver_sm->short_message, start, 
               (deliver_sm->sm_length > sizeof(deliver_sm->short_message)) ? 
                       sizeof(deliver_sm->short_message) : deliver_sm->sm_length);
        start = end+1;
 
        free(buff);
 
        debug(0, "pdu->service_type == %s", deliver_sm->service_type);
        
        debug(0, "pdu->source_addr_ton == %i", deliver_sm->source_addr_ton);
        debug(0, "pdu->source_addr_npi == %i", deliver_sm->source_addr_npi);
        debug(0, "pdu->source_addr == %s", deliver_sm->source_addr);
        
        debug(0, "pdu->dest_addr_ton == %i", deliver_sm->dest_addr_ton);
        debug(0, "pdu->dest_addr_npi == %i", deliver_sm->dest_addr_npi);
        debug(0, "pdu->dest_addr == %s", deliver_sm->dest_addr);
        
        debug(0, "pdu->esm_class == %i", deliver_sm->esm_class);
        debug(0, "pdu->protocol_id == %i", deliver_sm->protocol_id);
        debug(0, "pdu->priority_flag == %i", deliver_sm->priority_flag);
        
        debug(0, "pdu->schedule_delivery_time == %s", deliver_sm->schedule_delivery_time);
        debug(0, "pdu->validity_period == %s", deliver_sm->validity_period);
 
        debug(0, "pdu->registered_delivery_flag == %i", deliver_sm->registered_delivery_flag);
        debug(0, "pdu->replace_if_present_flag == %i", deliver_sm->replace_if_present_flag);
        debug(0, "pdu->data_coding == %i", deliver_sm->data_coding);
        debug(0, "pdu->sm_default_msg_id == %i", deliver_sm->sm_default_msg_id);
        debug(0, "pdu->sm_length == %i", deliver_sm->sm_length);
 
        start = malloc( 4 );
        end = malloc( (deliver_sm->sm_length*3) + 1 );
        if(start == NULL) goto error;
        if(end == NULL) goto error;
        memset(end, 0, (deliver_sm->sm_length*3) + 1);
        for(oct=0; oct <>sm_length; oct++) {
               sprintf(start, "%02x ", (unsigned char) deliver_sm->short_message[oct]);
               strcat(end, start);
        }
        debug(0, "pdu->short_message == %s", end);
 
        free(start);
        free(end);     
 
        return 1;
 
error:
        return -1;
}
 
/******************************************************************************
* PDUs
*  QUERY_SM, QUERY_SM_RESP
*/
static int pdu_act_query_sm_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
        /* Ignore, this version doesn't send messages which
           get these responses. */
 
        return -1;
}
 
#if 0
static int pdu_act_query_last_msgs_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
        /* Ignore, this version doesn't send messages which
           get these responses. */
 
        return -1;
}
        
static int pdu_act_query_msg_details_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
        /* Ignore, this version doesn't send messages which
           get these responses. */
 
        return -1;
}
#endif
 
static int pdu_act_cancel_sm_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
        /* Ignore, this version doesn't send messages which
           get these responses. */
 
        return -1;
}
 
static int pdu_act_replace_sm_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
        /* Ignore, this version doesn't send messages which
           get these responses. */
 
        return -1;
}
 
static int pdu_act_enquire_link(SMSCenter *smsc, smpp_pdu *pdu) {
 
        struct smpp_pdu *newpdu = NULL;
 
        /* Push a ENQUIRE_LINK_RESP on the appropriate fifostack. */
        newpdu = pdu_new();
        if(newpdu==NULL) goto error;
        memset(newpdu, 0, sizeof(struct smpp_pdu));
 
        newpdu->message_body = NULL;
        newpdu->length = 16;
        newpdu->id = SMPP_ENQUIRE_LINK_RESP;
        newpdu->status = 0;
 
        if(pdu->fd == smsc->fd_t) {
               newpdu->sequence_no = smsc->seq_t++;
               fifo_push(smsc->fifo_t_out, newpdu);
        } else if(pdu->fd == smsc->fd_r) {
               newpdu->sequence_no = smsc->seq_r++;
               fifo_push(smsc->fifo_r_out, newpdu);
        }
 
        return 1;
 
error:
        return -1;
}
 
static int pdu_act_enquire_link_resp(SMSCenter *smsc, smpp_pdu *pdu) {
 
        /* Reset the status flag CAN_SEND or CAN_RECEIVE  */
 
        return 1;
}
 
static int pdu_act_generic_nak(SMSCenter *smsc, smpp_pdu *pdu) {
 
        error(0, "pdu_act_generic_nak: SOMETHING IS DREADFULLY WRONG");
 
        debug(0, "pdu->length == %08x", pdu->length);
        debug(0, "pdu->id == %08x", pdu->id);
        debug(0, "pdu->status == %08x", pdu->status);
        debug(0, "pdu->sequence_no == %08x", pdu->sequence_no);
 
        /* Panic  */
 
        return -1;
}
 
static int charset_smpp_to_iso(char* data) {
 
        int i;
 
        while(*data != '\0') {
               i = 0;
               while( translation_table[i].iso != 0 ) {
                       if( translation_table[i].smpp == *data ) {
                               *data = translation_table[i].iso;
                               break;
                       }
                       i++;
               }
               data++;
        }
 
        return 1;
}
 
static int charset_iso_to_smpp(char* data) {
 
        int i;
 
        while(*data != '\0') {
               i = 0;
               while( translation_table[i].iso != 0 ) {
                       if( translation_table[i].iso == *data ) {
                               *data = translation_table[i].smpp;
                               break;
                       }
                       i++;
               }
               data++;
        }
 
        return 1;
}
Read full history - An example SMS Server component

Featured Video

Featured Article

Poems