If you have just sprained your ankle or twisted your knee, remember to do RICE Treatment i.e. Rest, Ice, Compression, Elevation.
Rest the injured part and discontinue play.
Apply ice for 15 - 20 minutes only. Use ice cubes or crushed ice in a plastic bag and add water to ensure it isn't too cold! You may insulate it with a dry cloth. You would soon find the swelling less painful and swollen. Repeat the icing after every 4 hours for 2-3 days.
Apply a crepe bandage for compression. Ensure that it isn't too tight to restrict blood circulation of your toes or fingers.
Keep your injured limb elevated above the level of the heart. This would help it drain the swelling.
Do not try to massage the injured limb as it may worsen the condition. Check with your sports doctor first!